[英]PID file /usr/local/apache2/logs/httpd.pid not readable (yet?) after start
I installed httpd 2.4.27 in CentOS 7. I configured httpd.service as systemd service.我在 CentOS 7 中安装了 httpd 2.4.27。我将 httpd.service 配置为 systemd 服务。 But everytime I got this error PID file /usr/local/apache2/logs/httpd.pid not readable (yet?) after start.但是每次我在启动后收到这个错误PID文件/usr/local/apache2/logs/httpd.pid not readable(还没有?)。 when I start or restart httpd.service.当我启动或重新启动 httpd.service 时。
Here is my configuration of httpd.service:这是我对 httpd.service 的配置:
[root@localhost ~]# cat /usr/lib/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)
[Service]
Type=forking
ExecStart=/usr/local/apache2/bin/apachectl -k start
ExecReload=/usr/local/apache2/bin/apachectl -k graceful
ExecStop=/usr/local/apache2/bin/apachectl -k graceful-stop
PIDFile=/usr/local/apache2/logs/httpd.pid
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[root@localhost ~]#
Here is the error info:这是错误信息:
[root@localhost ~]# systemctl start httpd.service
[root@localhost ~]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Fri 2017-09-01 22:30:48 EDT; 1s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 2173 ExecStart=/usr/local/apache2/bin/apachectl -k start (code=exited, status=0/SUCCESS)
Main PID: 2176 (httpd)
CGroup: /system.slice/httpd.service
├─2176 /usr/local/apache2/bin/httpd -k start
├─2177 /usr/local/apache2/bin/httpd -k start
├─2178 /usr/local/apache2/bin/httpd -k start
└─2179 /usr/local/apache2/bin/httpd -k start
Sep 01 22:30:47 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
Sep 01 22:30:48 localhost.localdomain systemd[1]: PID file /usr/local/apache2/logs/httpd.pid not readable (yet?) after start.
Sep 01 22:30:48 localhost.localdomain systemd[1]: Started The Apache HTTP Server.
[root@localhost ~]#
Here is the permission of httpd.pid file:这是 httpd.pid 文件的权限:
[root@localhost ~]# ll /usr/local/apache2/logs/
total 8
-rw-r--r--. 1 root root 0 Sep 1 20:46 access_log
-rw-r--r--. 1 root root 3270 Sep 1 22:30 error_log
-rw-r--r-- 1 root root 5 Sep 1 22:30 httpd.pid
[root@localhost ~]#
I found there was no use to change the permission of httpd.pid file manually, because the file will be removed automatically when service gets stopped.我发现手动更改 httpd.pid 文件的权限是没有用的,因为服务停止时该文件会自动删除。 And new httpd.pid file will be generated once service is turned on.服务开启后会生成新的 httpd.pid 文件。
Note: I see some posts saying updating /usr/lib/tmpfiles.d/httpd.conf will work.注意:我看到一些帖子说更新 /usr/lib/tmpfiles.d/httpd.conf 会起作用。 But I don't have this file since I installed apache from source.但是我没有这个文件,因为我从源代码安装了 apache。 I think only 'yum install httpd' has this.我认为只有 'yum install httpd' 有这个。
Anyone can help?任何人都可以帮忙吗? I just want to have a clean service start with no error or warning.我只想有一个干净的服务启动,没有错误或警告。 Thanks.谢谢。
你可以设置/lib/tmpfiles.d/httpd.conf
如下:
d /usr/local/apache2/logs/httpd.pid 700 apache apache
vim /etc/systemd/system/httpd.service
Add parameter of "ExecStartPost" is work,添加“ExecStartPost”参数是可行的,
[Unit]
Description=httpd service
After=syslog.target network.target
[Service]
Type=forking
PIDFile=/usr/local/apache2/logs/httpd.pid
ExecStart=/bin/sh -c '/usr/sbin/apachectl -f /etc/httpd/httpd.conf -k start'
ExecStop=/bin/sh -c '/usr/sbin/apachectl -f /etc/httpd/httpd.conf -k stop'
ExecReload=/bin/sh -c '/usr/sbin/apachectl -f /etc/httpd/httpd.conf -k graceful'
ExecStartPost=/bin/sh -c '/usr/bin/chown apache:apache -R /usr/local/apache2/logs/httpd.pid'
[Install]
WantedBy=multi-user.target
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.