Nginx的脚本启动
1.安装httpd服务,安装后httpd的启动脚本会在 /usr/lib/systemd/system 目录下
[[email protected] ~]# yum install -y httpd
[[email protected] ~]# cd /usr/lib/systemd/system
[[email protected] system]# ls
2.将httpd的启动脚本复制给nginx (一般系统中自己写的启动脚本放在/etc/systemd/system/目录下)
[[email protected] system]# cp httpd.service /etc/systemd/system/nginx.service
[[email protected] system]#
[[email protected] system]# cd /etc/systemd/system
[[email protected] system]# ls
3.修改复制过来的启动脚本
[[email protected] system]# vim nginx.service
1 [Unit]
2 Description=The Nginx HTTP Server
3 After=network.target remote-fs.target nss-lookup.target
4
5 [Service]
6 Type=forking
7 ExecStart=/usr/local/nginx/sbin/nginx
8 ExecReload=/usr/local/nginx/sbin/nginx -s reload
9 ExecStop=/usr/local/nginx/sbin/nginx -s stop
10
11 KillSignal=SIGCONT
12 PrivateTmp=true
13
14 [Install]
15 WantedBy=multi-user.target
4.先用原来的方式关闭nginx服务
5.打开服务
[[email protected] system]# systemctl start nginx.service
[[email protected] system]# systemctl status nginx.service
6.关闭服务
[[email protected] system]# systemctl stop nginx.service
[[email protected] system]# systemctl status nginx.service