我在CentOS 7中安装了httpd 2.4.27。我将httpd.service配置为systemd服务。但每次我启动或重新启动httpd. service时,都会出现此错误**PID file /usr/local/apache 2/logs/httpd.pid在启动后不可读(还没有?)。
下面是我对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 ~]#
下面是www.example.com的权限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 ~]#
我发现手动更改www.example.com文件的权限是没有用httpd.pid的,因为当服务停止时,该文件会自动删除。并且一旦服务打开,就会生成新的httpd.pid文件。
注意:我看到一些帖子说更新/usr/lib/tmpfiles.d/httpd.conf可以工作。但是我没有这个文件,因为我是从源代码安装apache的。我想只有“yum install httpd”有这个文件。
有人能帮忙吗?我只想有一个干净的服务启动,没有错误或警告。谢谢。
2条答案
按热度按时间uurv41yg1#
您可以将
/lib/tmpfiles.d/httpd.conf
设置为:d /usr/local/apache2/logs/httpd.pid 700 apache apache
个np8igboo2#
添加的参数“ExecStartPost”是工作、