Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I keep getting this error when I restart httpd:

DocumentRoot does not exist

What else can I do besides disable editing /etc/sysconfig/selinux to fix it?

share|improve this question
1  
Which operating system and which version/distribution are you using? which httpd? –  Nils Dec 5 '12 at 21:20
1  
At least post your Apache configuration, and tell us what distribution you're running. –  Gilles Dec 5 '12 at 23:13

2 Answers 2

Don't disable SELinux. That's just asking for trouble.

As for solving the problem, I'm just going to quote myself here:


It appears you've created a new directory outside the standard filesystem hierarchy to hold your web documents.

When you do this, SELinux is not aware of your custom directory structure, and doesn't know that Apache (httpd) should have access to it. You will see messages in /var/log/audit/audit.log showing denials in this case.

To actually fix the problem, you need to tell SELinux that Apache can access the directory. Do this using the semanage fcontext command:

semanage fcontext -a -t httpd_sys_content_t "/volume1/web(/.*)?"

The pattern matching is done with regular expressions, so this will match /volume1/web and everything below it. The fact that it uses regular expressions also means you need to quote it as shown above.

Then relabel the files:

restorecon -r -v /volume1/web

SELinux will now permit Apache to access files in /volume1/web.

share|improve this answer
    
Michael, I have since got everything working but admittedly have forgotten about selinux so would you say this security is not working in the background regardless of no apache errors ? –  freja Dec 11 '12 at 0:21

Open /etc/selinux/targeted/booleans file using a text editor:

# vi /etc/selinux/targeted/booleans

Append or modify value for httpd_disable_trans as follows:

httpd_disable_trans=1

Save and close the file. Type the following two commands:

# setsebool httpd_disable_trans 1
# /etc/init.d/httpd restart

PostInstallerF may help you

You can take help from the following resources

share|improve this answer
    
I can't find the file to edit, on CentOs I have /etc/selinux/mls/setrans.d/ –  freja Dec 5 '12 at 6:46
    
is it /etc/grub.conf ? –  freja Dec 5 '12 at 6:55
    
I don't want to disable it because it is important security and although I am getting a warning in httpd I can still access pages so shouldn't I leave selinux alone? –  freja Dec 5 '12 at 7:04
    
anyway sestatus -vi says command not found so don't know if it is installed –  freja Dec 5 '12 at 7:09
    

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.