当前系统Centos7.4,关闭selinux,关闭防火墙(或自行设置)
1、配置好yum源,安装依赖
1 |
yum install wget gcc gcc-c++ pcre pcre-devel openssl openssl-devel zlib zlib-devel |
2、创建nginx启动用户
1 |
useradd -s /bin/false -M www |
3、下载解压nginx
1 2 3 4 |
cd /usr/local/src/ wget http://nginx.org/download/nginx-1.12.2.tar.gz tar zxf nginx-1.12.2.tar.gz cd /usr/local/src/nginx-1.12.2 |
4、编译nginx
1 2 3 |
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module make make install |
5、设置软链接
1 |
ln -sv /usr/local/nginx/sbin/nginx /usr/local/sbin/ |
6、设置systemctl
1 |
vi /usr/lib/systemd/system/nginx.service |
1 2 3 4 5 6 7 8 9 10 11 12 |
[Unit] Description=nginx After=network.target [Service] Type=forking PIDFile=/usr/local/nginx/logs/nginx.pid ExecStart=/usr/local/nginx/sbin/nginx ExecReload=/usr/local/nginx/sbin/nginx -s reload ExecStop=/usr/local/nginx/sbin/nginx -s stop PrivateTmp=true [Install] WantedBy=multi-user.target |
7、启动nginx
1 |
systemctl start nginx |
8、最后访问http://IP即可看到nginx欢迎页
原文链接:nginx1.12.2编译安装,转载请注明来源!