gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 17:17:00 27 4
gpt4 key购买 nike

我在 CentOS 7 中安装了 httpd 2.4.27。我将 httpd.service 配置为 systemd 服务。但是每次我得到这个错误 PID file/usr/local/apache2/logs/httpd.pid not readable (yet?) after start. 当我启动或重新启动 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 ~]#

错误信息如下:

[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 ~]#

这里是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 ~]#

我发现手动更改 httpd.pid 文件的权限是没有用的,因为当服务停止时该文件会自动删除。开启服务后会生成新的httpd.pid文件。

注意:我看到一些帖子说更新/usr/lib/tmpfiles.d/httpd.conf 会起作用。但是我没有这个文件,因为我从源代码安装了 apache。我认为只有“yum install httpd”有这个。

有人可以帮忙吗?我只想启动一个没有错误或警告的干净服务。谢谢。

最佳答案

你可以设置/lib/tmpfiles.d/httpd.conf如下:

d/usr/local/apache2/logs/httpd.pid 700 Apache Apache

关于linux - PID 文件/usr/local/apache2/logs/httpd.pid 启动后不可读(还?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46010004/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com