nginx 添加到系统命令中
-
在
/usr/lib/systemd/system
下 新建文件nginx.service
-
nginx.service
内容如下[Unit] Description=nginx - high performance web server Documentation=http://nginx.org/en/docs/ After=network.target remote-fs.target nss-lookup.target [Service] Type=forking PIDFile=/usr/local/nginx/logs/nginx.pid ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target
-
设置开机启动
chkconfig nginx on
-
查看开机启动的服务
chkconfig list
-
查看状态
systemctl status nginx.service
-
开始
systemctl start nginx.service
-
停止
systemctl stop nginx.service
-
重启
systemctl restart nginx.service