linux nginx管理
Posted hnhycnlc888
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux nginx管理相关的知识,希望对你有一定的参考价值。
1、添加 nginx 服务
vim /lib/systemd/system/nginx.service
添加如下内容:
[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
Restart=on-failure
RestartSec=20s
[Install]
WantedBy=multi-user.target
启动 Nginx 设置开机启动
启动: systemctl start nginx
查看状态:systemctl status nginx
设置为系统默认启动: systemctl enable nginx
2、查看当前nginx进程启用的配置文件
[root@VM_58_118_centos system]# netstat -anop | grep 0.0.0.0:80 tcp 0 0 0.0.0.0:8009 0.0.0.0:* LISTEN 7107/java off (0.00/0/0) tcp 0 0 0.0.0.0:8079 0.0.0.0:* LISTEN 7107/java off (0.00/0/0) tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 1695/httpd off (0.00/0/0) tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 17785/nginx: master keepalive (0.07/0/0) [root@VM_58_118_centos system]# ll /proc/17785/exe lrwxrwxrwx 1 root root 0 10月 20 23:59 /proc/17785/exe -> /usr/sbin/nginx [root@VM_58_118_centos system]# /usr/sbin/nginx -t nginx: [warn] conflicting server name "chart.syhuo.net" on 0.0.0.0:80, ignored nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful [root@VM_58_118_centos system]#
以上是关于linux nginx管理的主要内容,如果未能解决你的问题,请参考以下文章