linux nginx management

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 is set to start boot

    start: systemctl start nginx

    view status: systemctl status nginx

    set as the system default boot: systemctl enable nginx

 

 

 

 

2, view the current active profile nginx process

[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]#

 

Guess you like

Origin www.cnblogs.com/hnhycnlc888/p/11727711.html