nginx 自启动失败:Failed to parse PID from file: Invalid argument

Nginx自启动配置问题解决记录

记一次nginx自启动配置的问题
我的配置如下:

[Unit]
Description=A high performance web server and a reverse proxy server
After=network.target

[Service]
Type=forking
PIDFile=/home/u24/nginx/pid/nginx.pid
ExecStartPre=/home/u24/nginx/sbin/nginx -t -q -g 'daemon on; master_process on;'
ExecStart=/home/u24/nginx/sbin/nginx -g 'daemon on; master_process on;'
ExecReload=/home/u24/nginx/sbin/nginx -g 'daemon on; master_process on;' -s reload
ExecStop=/bin/kill -s TERM $MAINPID

[Install]
WantedBy=multi-user.target

执行 systemctl start nginx.service 后启动失败,提示

Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.

于是根据 journalctl -xeu nginx.service 中的提示,先是报找不到 /home/u24/nginx/pid/nginx.pid 这个文件,于是我手动创建了这个文件。
再次启动报 Failed to parse PID from file /home/u24/nginx/pid/nginx.pid: Invalid argument,确认了nginx.pid 文件的访问权限后,发现 nginx 的配置中,没有指定 pid 的文件文件,于是修改 nginx.conf ,在最外层添加配置

user  u24;
worker_processes  1;
#新增
pid        /home/u24/nginx/pid/nginx.pid;

再次启动,成功。

ov 29 13:37:41 RK3588-Tronlong systemd[1]: at606-nginx.service: Failed to parse PID from file /opt/at606-nginx/logs/nginx.pid: Invalid argument Nov 29 13:37:41 RK3588-Tronlong systemd[1]: Started AT606 nginx. -- Reboot -- Nov 29 16:13:24 RK3588-Tronlong systemd[1]: Starting AT606 nginx... Nov 29 16:13:33 RK3588-Tronlong systemd[1]: at606-nginx.service: Failed to parse PID from file /opt/at606-nginx/logs/nginx.pid: Invalid argument Nov 29 16:13:33 RK3588-Tronlong systemd[1]: Started AT606 nginx. -- Reboot -- Nov 29 16:42:24 RK3588-Tronlong systemd[1]: Starting AT606 nginx... Nov 29 16:42:32 RK3588-Tronlong systemd[1]: at606-nginx.service: New main PID 1335 does not exist or is a zombie. Nov 29 16:42:32 RK3588-Tronlong systemd[1]: Started AT606 nginx. -- Reboot -- Nov 29 17:00:47 RK3588-Tronlong systemd[1]: Starting AT606 nginx... Nov 29 17:00:56 RK3588-Tronlong systemd[1]: at606-nginx.service: Failed to parse PID from file /opt/at606-nginx/logs/nginx.pid: Invalid argument Nov 29 17:00:56 RK3588-Tronlong systemd[1]: Started AT606 nginx. -- Reboot -- Nov 29 17:04:36 RK3588-Tronlong systemd[1]: Starting AT606 nginx... Nov 29 17:04:46 RK3588-Tronlong systemd[1]: Started AT606 nginx. -- Reboot -- Nov 29 17:22:55 RK3588-Tronlong systemd[1]: Starting AT606 nginx... Nov 29 17:23:04 RK3588-Tronlong systemd[1]: at606-nginx.service: Failed to parse PID from file /opt/at606-nginx/logs/nginx.pid: Invalid argument Nov 29 17:23:04 RK3588-Tronlong systemd[1]: Started AT606 nginx. -- Reboot -- Nov 29 18:02:44 RK3588-Tronlong systemd[1]: Starting AT606 nginx... Nov 29 18:02:52 RK3588-Tronlong systemd[1]: Started AT606 nginx. -- Reboot -- Nov 29 18:16:25 RK3588-Tronlong systemd[1]: Starting AT606 nginx... Nov 29 18:16:34 RK3588-Tronlong systemd[1]: at606-nginx.service: Failed to parse PID from file /opt/at606-nginx/logs/nginx.pid: Invalid argument Nov 29 18:16:34 RK3588-Tronlong systemd[1]: Started AT606 nginx. -- Reboot -- Nov 29 18:18:24 RK3588-Tronlong systemd[1]: Starting AT606 nginx...
12-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值