Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When trying to start Apache by using:

/etc/init.d/httpd start

I get the following error in /var/log/httpd/error_log:

Unable to change directory to /root

Anyone have any idea what this means?

share|improve this question
    
Where do you get the error (stderr, syslog, ...) and how are you starting it? –  Oliver Salzburg Mar 21 '12 at 9:25
    
I start with command /etc/init.d/httpd start, I get the error in /var/log/httpd/error_log –  marvin Mar 21 '12 at 9:32
    
Is your apache conf some vanilla packaged default, or have you customised it in any way; is this a source install or an OS package, or what? –  Kristian Glass Mar 21 '12 at 9:46
    
it is freshly installed centos 6. I didn't touch apache conf. –  marvin Mar 21 '12 at 9:54
    
Is there a ChrootDir directive in your http.conf file (or one of the million other files CentOS uses to configure Apache)? –  Chris S Mar 21 '12 at 12:49

3 Answers 3

up vote 1 down vote accepted

Its SELinux.

because you have it enabled, you need to starte service using

service httpd start

edit your SELinux config and either disable it or set it to permissive:

nano /etc/sysconfig/selinux

# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=disabled

Once chenged then you will be able to start httpd using: /etc/init.d/httpd start

If you need to keep SELinux enabled, then just use the service script to start/stop/restart the service.
( # service httpd start/stop/restart )

share|improve this answer

The ServerRoot has apparently not been set (properly.)

If unset, this default to $HOME.

Edit httpd.conf and set a proper ServerRoot (usually /etc/httpd or /etc/apache2.)

share|improve this answer
    
ServerRoot is set as "/etc/httpd" –  marvin Mar 21 '12 at 9:31
    
Use apachectl start instead. –  adaptr Mar 21 '12 at 9:38
    
still getting the same error –  marvin Mar 21 '12 at 9:53
    
@marvin Can you post the output of apachectl configtest ? –  Swapneel Patnekar Mar 21 '12 at 11:47
    
[Wed Mar 21 11:53:42 2012] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:httpd_t:s0 [Wed Mar 21 11:53:42 2012] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) [Wed Mar 21 11:53:42 2012] [error] Unable to change directory to /root –  marvin Mar 21 '12 at 11:58

If you want to run it without disabling SELinux, then don't try to run http start/stop command inside /root directory.

This is temporary fix but always work, just switch to /tmp (cd /tmp) and run the command to start apache (/etc/init.d/httpd start)

share|improve this answer

Your Answer

 
discard

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.