RHEL/CentOS 7中Nginx的systemd service

在线安装预构建的Nginx,默认会创建Nginx的systemd服务,对应的服务文件是/usr/lib/systemd/system/nginx.service。文件内容如下:

[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/usr/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

为了启动Nginx的systemd服务,步骤如下:

1. 设置nginx.service文件的权限
chmod 664 /usr/lib/systemd/system/nginx.service

2.开启服务启动时执行
systemctl enable nginx.service

3.启动服务
systemctl start nginx.service

4.查看服务状态
systemctl status nginx.service

5.验证服务
curl -I 127.0.0.1:8080

 

参考链接:

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html-single/system_administrators_guide/index

https://www.nginx.com/resources/wiki/start/topics/examples/systemd/

https://www.nginx.com/resources/wiki/start/topics/examples/initscripts/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值