1.安装依赖工具
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel pcre
2.下载NGINX
wget http://nginx.org/download/nginx-1.15.7.tar.gz
3.解压和编译安装
tar -zxvf nginx-1.15.7.tar.gz
cd nginx-1.15.7
./configure && make && make install
4.配置环境变量并重新编译 /etc/profile 文件
vim /etc/profile
export NGINX_HOME=/usr/local/nginx
export PATH=$PATH:$NGINX_HOME/sbin
source /etc/profile
5.使用nginx
启动 ./nginx
重启 ./nginx -s reload
判断配置文件是否出错 ./nginx -t
查询nginx主进程号
ps -ef | grep nginx
从容停止 kill -QUIT 主进程号
快速停止 kill -TERM 主进程号
强制停止 kill -9 nginx
若nginx.conf配置了pid文件路径,如果没有,则在logs目录下
kill -信号类型 '/usr/local/nginx/logs/nginx.pid'
6 开机启动
1.添加至服务管理列表,并让其开机自动启动
chkconfig --add nginx
chkconfig nginx on
chkconfig nginx --list
2、nginx启动、停止、无间断服务重启
service nginx start
service nginx stop
service nginx reload