首页 > 其他 > 详细

centos7配置nginx开机自启动

时间:2020-09-28 01:05:36      阅读:35      评论:0      收藏:0      [点我收藏+]
centos7安装openresty

cd /usr/local/src/openresty
yum -y install pcre-devel openssl openssl-devel
yum install -y gcc gcc-c++ zlib-devel pcre-devel openssl-devel readline-devel
wget https://openresty.org/download/openresty-1.9.7.5.tar.gz
tar xzvf openresty-1.9.7.5.tar.gz
cd openresty-1.9.7.5
./configure --prefix=/usr/local/openresty --with-luajit --with-http_iconv_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module
gmake && gmake install
#### start
/usr/local/openresty/nginx/sbin/nginx -p /data/www/src/online/
#### reload
/usr/local/openresty/nginx/sbin/nginx -p /data/www/src/online/ -s reload

systemd启动nginx多应用文件进程

more /usr/lib/systemd/system/nginx.service

[Unit]
Description=The NGINX HTTP and reverse proxy server

[Service]
ExecStart=/root/start.sh

[Install]
WantedBy=multi-user.target

nginx多应用文件启动脚本

more /root/start.sh 
#!/bin/bash
/usr/local/openresty/nginx/sbin/nginx -c /data/www/src/online/conf/nginx.conf -t
/usr/local/openresty/nginx/sbin/nginx -c /data/www/src/online_gray/conf/nginx.conf -t
/usr/local/openresty/nginx/sbin/nginx -c /data/www/src/online/conf/nginx.conf
/usr/local/openresty/nginx/sbin/nginx -c /data/www/src/online_gray/conf/nginx.conf

chmod +x /root/start.sh

systemctl daemon-reload #生效配置文件重载
systemctl enable nginx.service #设置开机启动
systemctl list-unit-files |grep nginx #查看nginx应用开机状态
systemctl start nginx.service #查看nginx应用启动状态
systemctl status nginx.service

systemd配置nginx开机启动

more /usr/lib/systemd/system/nginx.service

[Unit]
Description=The NGINX HTTP and reverse proxy server

[Service]
Type=forking
ExecStartPre=/usr/local/openresty/nginx/sbin/nginx -c /data/www/src/online/conf/nginx.conf -t
ExecStart=/usr/local/openresty/nginx/sbin/nginx -c /data/www/src/online/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

centos7配置nginx开机自启动

原文:https://blog.51cto.com/11676712/2537309

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!