Permission denied for apache

Issues related to configuring your network
Post Reply
mahmood
Posts: 122
Joined: 2017/06/04 12:21:09

Permission denied for apache

Post by mahmood » 2019/04/14 06:04:59

Although I have granted apache:apache to a folder, the service can not be started due to permission error. See

Code: Select all

[root@test conf.d]# cat /etc/httpd/conf.d/vhost.conf
NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin webmaster@example.com
    ServerName test.scu.com
    ServerAlias test
    DocumentRoot /var/www/html/
    ErrorLog /var/www/html/logs/error.log
    CustomLog /var/www/html/logs/access.log combined
</VirtualHost>
[root@test conf.d]# ls -l /var/www/html/logs/
total 0
[root@test conf.d]# ls -l /var/www/html/
total 0
drwxr-xr-x. 2 apache apache 6 Apr 14 10:27 logs
[root@test conf.d]# systemctl start httpd
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
[root@test conf.d]# cat /var/log/httpd/error_log
(13)Permission denied: AH00091: httpd: could not open error log file /var/www/html/logs/error.log.
AH00015: Unable to open logs

Also journalctl -xe says

Code: Select all

Apr 14 10:30:51 test.scu.com systemd[1]: Starting The Apache HTTP Server...
-- Subject: Unit httpd.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has begun starting up.
Apr 14 10:30:51 test.scu.com httpd[15023]: AH00548: NameVirtualHost has no effect and will be removed in the
Apr 14 10:30:51 test.scu.com sshd[15011]: Received disconnect from 218.92.0.209 port 15202:11:  [preauth]
Apr 14 10:30:51 test.scu.com sshd[15011]: Disconnected from 218.92.0.209 port 15202 [preauth]
Apr 14 10:30:51 test.scu.com sshd[15011]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh
Apr 14 10:30:51 test.scu.com systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Apr 14 10:30:51 test.scu.com kill[15024]: kill: cannot find process ""
Apr 14 10:30:51 test.scu.com systemd[1]: httpd.service: control process exited, code=exited status=1
Apr 14 10:30:51 test.scu.com systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has failed.
--
-- The result is failed.
Apr 14 10:30:51 test.scu.com systemd[1]: Unit httpd.service entered failed state.
Apr 14 10:30:51 test.scu.com systemd[1]: httpd.service failed.
Apr 14 10:30:51 test.scu.com polkitd[4534]: Unregistered Authentication Agent for unix-process:15017:48903 (
lines 1424-1465/1465 (END)
What else should I do?

lightman47
Posts: 1521
Joined: 2014/05/21 20:16:00
Location: Central New York, USA

Re: Permission denied for apache

Post by lightman47 » 2019/04/14 11:54:24

I'd change the log paths back to root:root.

mahmood
Posts: 122
Joined: 2017/06/04 12:21:09

Re: Permission denied for apache

Post by mahmood » 2019/04/14 13:23:28

Still I get error

Code: Select all

[root@test html]# ls -l
total 0
drwxr-xr-x. 2 root root 23 Apr 14 10:55 logs
[root@test html]# journalctl -xe
Apr 14 17:11:45 test.scu.com polkitd[4534]: Registered Authentication Agent for unix-process:27206:2454376 (system bus name :1.55 [/usr/bin/pkttyagent --notify-fd 5 --fallback], obje
Apr 14 17:11:45 test.scu.com systemd[1]: Starting The Apache HTTP Server...
-- Subject: Unit httpd.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has begun starting up.
Apr 14 17:11:45 test.scu.com httpd[27212]: AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/httpd/conf.d/vhost.conf:1
Apr 14 17:11:46 test.scu.com systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Apr 14 17:11:46 test.scu.com kill[27213]: kill: cannot find process ""
Apr 14 17:11:46 test.scu.com systemd[1]: httpd.service: control process exited, code=exited status=1
Apr 14 17:11:46 test.scu.com systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has failed.
--
-- The result is failed.
Apr 14 17:11:46 test.scu.com systemd[1]: Unit httpd.service entered failed state.
Apr 14 17:11:46 test.scu.com systemd[1]: httpd.service failed.
Apr 14 17:11:46 test.scu.com polkitd[4534]: Unregistered Authentication Agent for unix-process:27206:2454376 (system bus name :1.55, object path /org/freedesktop/PolicyKit1/Authentic
[root@test html]#

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Permission denied for apache

Post by TrevorH » 2019/04/14 13:52:07

Any attempt to write to files under /var/www will be seen by selinux as an attempt to change your web content and blocked as it thinks it is an attack. Logs should not be under /var/www, that's why there is a /var/log/httpd directory. Put your logs in the right place.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

mahmood
Posts: 122
Joined: 2017/06/04 12:21:09

Re: Permission denied for apache

Post by mahmood » 2019/04/14 16:17:50

Yes. You are right. I dropped the log paths in order to see if the default is working and it was fine.

Post Reply