nginx添加到系统命令中

在指定的文件中下载文件   ‘nginx.service’

在网上找包

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

相关推荐