设置编译参数:
./configure \--prefix=/usr/local/nginx \--sbin-path=/usr/sbin/nginx \--conf-path=/etc/nginx/nginx.conf \--error-log-path=/var/log/nginx/error.log \--http-log-path=/var/log/nginx/access.log \--pid-path=/var/run/nginx.pid \--lock-path=/var/run/nginx.lock \--user=nginx \--group=nginx \--with-http_ssl_module \--with-pcre \--with-http_v2_module \--with-http_realip_module \--with-http_addition_module \--with-http_sub_module \--with-http_dav_module \--with-http_gunzip_module \--with-http_gzip_static_module \--with-http_random_index_module \--with-http_secure_link_module \--with-http_stub_status_module \--with-http_auth_request_module
然后执行 make && make install
完成安装后在 centos7 中为nginx的启动、重启、重载配置添加脚本:
vi /usr/lib/systemd/system/nginx
添加内容:
[Unit]Description=nginx - high performance web serverDocumentation=http://nginx.org/en/docs/After=network.target remote-fs.target nss-lookup.target [Service]Type=forkingPIDFile=/var/run/nginx.pidExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.confExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.confExecReload=/bin/kill -s HUP $MAINPIDExecStop=/bin/kill -s QUIT $MAINPIDPrivateTmp=true [Install]WantedBy=multi-user.target
相关操作:
systemctl is-enabled nginx.service #查询nginx是否开机启动systemctl enable nginx.service #开机运行nginxsystemctl disable nginx.service #取消开机运行nginxsystemctl start nginx.service #启动nginxsystemctl stop nginx.service #停止nginxsystemctl restart nginx.service #重启nginxsystemctl reload nginx.service #重新加载nginx配置文件systemctl status nginx.service #查询nginx运行状态systemctl --failed #显示启动失败的服务
总结
以上就是CentOS 7.2安装Nginx 1.10.2的详细教程,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。