1.安装httpd服务,安装后httpd的启动脚本会在 /usr/lib/systemd/system 目录下
[root@server1 ~]# yum install -y httpd
[root@server1 ~]# cd /usr/lib/systemd/system
[root@server1 system]# ls
2.将httpd的启动脚本复制给nginx (一般系统中自己写的启动脚本放在/etc/systemd/system/目录下)
[root@server1 system]# cp httpd.service /etc/systemd/system/nginx.service
[root@server1 system]#
[root@server1 system]# cd /etc/systemd/system
[root@server1 system]# ls
3.修改复制过来的启动脚本
[root@server1 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.打开服务
[root@server1 system]# systemctl start nginx.service
[root@server1 system]# systemctl status nginx.service
6.关闭服务
[root@server1 system]# systemctl stop nginx.service
[root@server1 system]# systemctl status nginx.service