linux 系统安装nginx

1,进入/usr/local目录

cd /usr/local

2,下载nginx安装包(linux 联网的话可以直接用wget命令下载下来)

wget -c http://nginx.org/download/nginx-1.24.0.tar.gz

3,安装Nginx相关依赖(centos使用yum命令安装

yum install -y gcc-c++ zlib zlib-devel openssl openssl-devel pcre pcre-devel

4,解压下载好的nginx安装包

tar -zxvf nginx-1.24.0.tar.gz

5,进入nginx-1.24.0目录

cd nginx-1.24.0

6,执行配置脚本(--prefix是自己指定一个安装目录

./configure --prefix=/usr/local/nginx

make & make install

7,启动nginx

启动

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

停止

/usr/local/nginx/sbin/nginx -s stop

重载

/usr/local/nginx/sbin/nginx -s reload

杀掉nginx

/usr/local/nginx/sbin/nginx -s quit

8,设置开机自启动(根据自己需求设置)

vim /etc/rc.local

文本底部追加

/usr/local/nginx/sbin/nginx