Nginx管理的命令
#启动
/usr/sbin/nginx -c /etc/nginx/nginx.conf
#重新加载配置文件
/usr/sbin/nginx -s reload
#停止退出
/usr/sbin/nginx -s stop
/usr/sbin/nginx -s quit
配置文件
[root@ALiYunOgenes ~]# systemctl status nignx
Unit nignx.service could not be found.
#查看nginx路径
[root@ALiYunOgenes ~]# which nginx
/usr/sbin/nginx
#查看nginx配置文件路径
[root@ALiYunOgenes ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
#查看pid路径
[root@ALiYunOgenes ~]# grep pid /etc/nginx/nginx.conf
pid /var/log/nginx/nginx.pid;
#注意修改nginx和配置文件和pid的路径
[root@ALiYunOgenes ~]# vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx - high performance web server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/home/run/nginx/nginx.pid
ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/usr/sbin/nginx -s reload
ExecStop=/usr/sbin/nginx -s stop
ExecQuit=/usr/sbin/nginx -s quit
[Install]
WantedBy=multi-user.target
启动nginx
[root@ALiYunOgenes ~]# systemctl status nginx
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Dec 17 17:21:48 ALiYunOgenes systemd[1]: [/usr/lib/systemd/system/nginx.service:12] Unknown lvalue 'ExecQuit' in section 'Service'
[root@ALiYunOgenes ~]# systemctl start nginx
设置开机自启动
[root@ALiYunOgenes ~]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
[root@ALiYunOgenes ~]# systemctl is-enabled nginx
enabled