简体   繁体   English

启动后 PID 文件 /usr/local/apache2/logs/httpd.pid 不可读(还没有?)

[英]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.

相关问题 Apache2:尝试启动它时“地址已在使用中”(“ httpd.pid”问题?) - Apache2: “Address already in use” when trying to start it ('httpd.pid' issue?) 错误! 服务器退出而不更新PID文件(/usr/local/var/mysql/Bridge.local.pid) - ERROR! The server quit without updating PID file (/usr/local/var/mysql/Bridge.local.pid) systemctl restart httpd 启动失败 Apache HTTP 服务器 httpd pid 已经运行 - systemctl restart httpd Failed to start The Apache HTTP Server httpd pid already running postgresql:数据目录无效 | 启动后无法打开 PID 文件 /var/run/postgresql/10-main.pid(还没有?):没有这样的文件或目录 - postgresql: Invalid data directory | Can't open PID file /var/run/postgresql/10-main.pid (yet?) after start: No such file or directory 启动 httpd - 检索 pid 文件时出错(空) - Starting httpd - Error retrieving pid file (null) Hhvm重新启动后无法读取任何有意义的pid的pid文件/ var / run / hhvm / pid - Hhvm Unable to read pid file /var/run/hhvm/pid for any meaningful pid after reboot '/usr/sbin/apache2 -k start' 进程太多 - Too many '/usr/sbin/apache2 -k start' processes httpd(pid 1766)已经在运行,但是我无法加载localhost并在浏览器上看到apache确认 - httpd (pid 1766) already running but I can't load localhost and see apache confirmation on browser 当我遇到pid冲突并且服务器未处理php时如何重新启动apache2 - How to restart apache2 when I get a pid conflict and php not processed by the server 服务器重启后无法启动 Apache HTTPD - Unable to start Apache HTTPD after server reboot
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM