一、安装yum依赖关系
yum -y install pcre-devel zlib-devel openssl-devel gcc*
二、下载nginx包,解压
[root@localhost src]# wget http://nginx.org/download/nginx-1.12.2.tar.gz
[root@localhost src]# tar xf nginx-1.12.2.tar.gz
三、编译安装
[root@localhost src]# cd nginx-1.12.2
[root@localhost nginx-1.12.2]# ./configure --prefix=/usr/local/nginx
[root@localhost nginx-1.12.2]# make && make install
四、检测运行
[root@localhost sbin]# ./nginx -t #测试是否正常
[root@localhost sbin]# ./nginx #启动nginx
[root@localhost sbin]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf #启动nginx
[root@localhost sbin]# ./nginx -s stop #停止nginx
[root@localhost sbin]# ./nginx -s reload #加载nginx