CentOS7怎么将Nginx添加系统服务
作者:暮色微凉
时间:2025-04-01
浏览:7
查看服务首先查看nginx的服务状态,输入systemctlstatusnginx,结果如下没有找到相关的服务,下一步就是添加系统服务。添加系统服务在/usr/lib/systemd/system目录中添加nginx.service,根据实际情况进行修改,详细解析可查看下方参考资料中的文章。内容如下[unit]description=nginx-highperformancewebserverdocumentation=http://nginx.org/en/docs/after=network.targ
本文目录
查看服务
首先查看 nginx 的服务状态,输入 systemctl status nginx,结果如下

没有找到相关的服务,下一步就是添加系统服务。
添加系统服务
在 /usr/lib/systemd/system 目录中添加 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
添加完成后再来看下

设置开机自动启动
首先测试一下,重启然后来查看 nginx 服务

确实没有启动。输入 systemctl start nginx 启动

可以使用 systemctl 启动,说明之前添加的 nginx.service 没有问题。然后输入 systemctl enable nginx 设置开机启动

最后重启检查下是否设置成功

没有问题,到此关于 nginx 的编译安装完成,接下来是 php 的安装。
作者最新文章
长网页转PDF怎么避免断图?网页转PDF怎么设置分页
2026-11-01 09:31
夸克资源库蓝光资源每日更新经典电视剧全集
2026-10-30 11:54
会声会影怎么导入音频 支持格式及步骤
2026-10-29 12:23
WPS表格常用功能实操:从录入到排序筛选的完整流程
2026-10-29 09:57
B站免费入口永久有效网址推荐
2026-10-28 16:37
上一篇:
PPT制作一个垃圾分类宣传图的操作方法
下一篇:
讲解ppt的技巧有哪些
热门文章
更多
精品专题
更多
Mac软件
更多
WINDOWS
更多

































