点赞
评论
收藏
分享
举报
采用systemd配置开机启动NGINX服务
发表于2021-06-19 18:35

浏览 987

文章标签


NGINX安装好后,我们都希望配置当系统启动后,能自动启动NGINX服务,在Linux系统中,现在比较多采用systemd来管理服务的启停,以下为在CentOS 7上通过systemd配置开机直接启动NGINX服务的一些操作:

1.       通过yum命令直接安装NGINX Plus版本后的配置操作:

CentOS7上采用yum命令安装NGNIX Plus的过程,可参考:

https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-plus/#install_rhel_centos

安装完成后,系统会自动在/lib/system/system目录下生成nginx.service文件:

采用Systemctl enable命令直接配置系统启动时启动NGINX服务即可:

[root@nginxplus2-14 ~]# systemctl enable nginx.service

2.       通过yum命令直接安装NGINX Open Source版本后的配置操作:

CentOS7上采用yum安装NGINX Open Source版本的过程,可参考:

https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-open-source/#prebuilt_redhat

安装完成后,系统会自动在/lib/system/system下生成nginx.service文件:

采用Systemctl enable命令直接配置系统启动时启动NGINX服务即可:

[root@nginxoss-2-15 system]# systemctl enable nginx.service

3.       自己编译安装的NGINX Open Source版本后的配置操作:

自己编译安装NGINX Open Source,请参考:

https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-open-source/#sources

完装完成后,需要自己手工创建生成/lib/systemd/system/nginx.service文件(请根据自己的环境修改PIDfilenginx命令的路径):

采用Systemctl enable命令直接配置系统启动时启动NGINX服务:

[root@nginxoss1 system]# systemctl enable nginx.service


可以采用systemctl is-enabled命令来检查nginx服务是否enable:

[[root@nginxoss-2-15 system]# systemctl is-enabled nginx.service

enabled

已修改于2023-03-06 02:21
本作品系原创
创作不易,留下一份鼓励
leozou123

暂无个人介绍

关注



写下您的评论
发表评论
全部评论(0)

按点赞数排序

按时间排序

关于作者
leozou123
这家伙很懒还未留下介绍~
1
文章
0
问答
1
粉丝
相关文章