0

I have a server (OS is CentOS) which has Apache. My default folder is /var/www/html/. When I add my domain this folder it works.

But when I do this in httpd.conf

<VirtualHost *:80>
    ServerAdmin webmaster@mydomain.com
    DocumentRoot /space/www/htdocs

    <Directory /space/www/htdocs>
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

    ServerName mydomain.com
    ServerAlias www.mydomain.com
    ErrorLog logs/mydomain.com-error_log
    CustomLog logs/mydomain.com-access_log common
</VirtualHost>

403 happens. What should I do?

6
  • 1
    Is your /space/www/htdocs folder has same permissions & ownership as /var/www/html
    – Raza
    Jun 20, 2013 at 20:15
  • Yes both are root:root.
    – borayeris
    Jun 20, 2013 at 20:19
  • root:root, but permissions ? it must be 755 Jun 20, 2013 at 20:23
  • Yes all directories are 755 and files are 644.
    – borayeris
    Jun 20, 2013 at 20:29
  • try <Directory "/space/www/htdocs"> instead of <Directory /space/www/htdocs>
    – Raza
    Jun 20, 2013 at 20:46

1 Answer 1

1

Your setup seems ok.

but you may need to modify the SELinux file context database, or change the SELinux type of certain file.

Run the following command,

semanage fcontext -a -t httpd_sys_content_t '/space(/.*)?'

restorecon -vR /space

by default the file content of your web server is public_content_t, so you need to change into httpd_content_t to allow web server the contents out.

2
  • First of all thank you very very much. My OS is CentOS and it doesn't have semanage by default. So I istalled policycoreutils-python. That way I could use your commands. I've been using *nix amateurishly for 10 years and never heard this type of file permission. I want to learn more about this. What is it?
    – borayeris
    Jun 21, 2013 at 19:54
  • 1
    Its comes under the topic of SELinux (Security Enhanced Linux). Refer the link for more info, drupalwatchdog.com/2/2/apache-selinux Jun 24, 2013 at 4:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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