# Nginx开机自动启动
切换到/lib/systemd/system/目录,创建nginx.service文件vim nginx.service
cd /lib/systemd/system/
vim nginx.service
1
2
2
文件内容如下:
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx reload
ExecStop=/usr/local/nginx/sbin/nginx quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
退出并保存文件,执行systemctl enable nginx.service使nginx开机启动
systemctl enable nginx.service
1
本文来自 stinkstone 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/stinkstone/article/details/78082748?utm_source=copy (opens new window)