Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I created a custom log directory with the root account, and chmoded it to 777 teporarily.

ls -la /var/mylogs/log/
total 16
drwxrwxrwx 2 root root 4096 Jun 24 06:27 .
drwxr-xr-x 5 root root 4096 Jun 24 06:25 ..

When I try to start the service from a user (lets say "myuser", which is in the sudoers files as myuser ALL=(ALL) ALL), it fails because of the permissions :

sudo /etc/init.d/httpd start

Starting httpd: (13)Permission denied: httpd: could not open error log file /var/mylogs/log/httpd_error.log.
Unable to open logs

However, the following is successfull :

sudo bash
/etc/init.d/http start

So I guess these two methods are not equivalent, although to me doing sudo was the same than logging into the root account and issuing the commands.

Any clue ?

Thank you !

share|improve this question
And what OS are you using? – Andrew Smith Jun 24 '12 at 14:15
Sorry, using Red Hat Enterprise Linux Server release 5.7 (Tikanga) – SCO Jun 24 '12 at 16:57

The system on which the apache2 server is a RedHat 5.6, hence SELinux is activated by default.

The origin of the issue here is that SELinux adds additionnal file permissions on top of the OS ones (ie chmod, chown), see :

man httpd_selinux

The manual says that explicit context must be set to file/directories so that httpd is allowed to acess them.

Hence, I used the following :

chcon -R user_u:object_r:httpd_log_t /var/mylogs/logs

You can check the man to get the other permission tokens ( content, scripts..).

share|improve this answer

The apache2 process should be owner of logging directory instead of root. You can fix this issue by changing owner of log directory (i.e. www-data or group to which apache2 belongs to)

share|improve this answer
on redhat this is httpd. – Oneiroi Jun 24 '12 at 21:31
You are right, this is step 1 ! Although the answer doesn't make it ;) I'll post why in a few secs. – SCO Jun 25 '12 at 10:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.