Linux安装openresty

yum install yum-utils
yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo

yum install openresty

安装成功后 会在默认的目录如下:

/usr/local/openresty

默认已经安装好了nginx,在目录:/usr/local/openresty/nginx 下

#user nobody; 配置文件第一行原来为这样, 现改为下面的配置
user root root;

Nginx开机自启

vi /usr/lib/systemd/system/nginx.service
---------------------------------
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target
 
[Service]
Type=forking
PIDFile= /var/run/openresty.pid
ExecStartPre=/usr/bin/rm -f  /var/run/openresty.pid
ExecStartPre=/usr/local/openresty/nginx/sbin/nginx -t
ExecStart=/usr/local/openresty/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
KillMode=process
KillSignal=SIGQUIT
TimeoutStopSec=5
PrivateTmp=true
 
[Install]
WantedBy=multi-user.target

 

保存,重新加载 systemd

systemctl daemon-reload

设置nginx服务开机自启动

systemctl enable nginx.service

nginx服务常用操作

#启动nginx服务
systemctl start nginx.service
#停止nginx服务
systemctl stop nginx.service
#重启nginx服务
systemctl restart nginx.service
#重新读取nginx配置(这个最常用, 不用停止nginx服务就能使修改的配置生效)
systemctl reload nginx.service


 
posted @ 2020-08-12 15:36  Dreamvv  阅读(249)  评论(0编辑  收藏  举报