![8c6703f1cb9c290aa8df2514a06d2248.png](https://img-blog.csdnimg.cn/img_convert/8c6703f1cb9c290aa8df2514a06d2248.png)
有好几个人问我用cloudcone建站后重启服务器打不开,是因为nginx没有开机自动启动
首先创建nginx.service文件
vim usr/lib/systemd/system/nginx.service
然后,用下面内容替换原内容
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
保存
设置开机自启
systemctl enable nginx.service