I'm trying to set up an Apache 2 server on my Arch Linux machine. Everything works great so far, including https and php, but now I want to change the DocumentRoot
from the default /srv/http
to /var/www/foo
. I changed DocumentRoot /srv/http
and <Directory "/srv/http">
to DocumentRoot /var/www/foo
and <Directory "/var/www/foo">
respectively and reloaded the configuration using systemctl restart httpd
. Now I'm getting 403 errors when trying to access https://localhost
or anything within.
Further investigation turns out that changing the <Directory ...>
declaration has an effect, but changing the DocumentRoot
doesn't. When I set Require all granted
in <Directory />
to eliminate these 403 errors, it turns out Apache is still trying to serve documents from /srv/http
. For instance, I put a test.php file containing <?php echo exec('pwd'); ?>
into both /srv/http/
and /var/www/foo/
and accessing https://localhost/test.php
outputs /srv/http
to my browser. Trying to access documents located in /var/www/foo
but not in /srv/http
will result in 404 errors.
Why is Apache still using /srv/http
? I changed absolutely every occurence of /srv/http
to /var/www/foo
in /etc/httpd/conf/httpd.conf
and restarted Apache several times, but my document root just won't change. According to the Apache Arch Wiki article, I've done everything that's necessairy.
I could of course just symlink /srv/http
to the desired location, but that doesn't seem like the proper way to go.
Here are the parts of my httpd.config
that I think might be relevant:
<Directory />
AllowOverride none
Require all granted # Will of course change to denied again once everything works
</Directory>
DocumentRoot "/var/www/foo"
<Directory "/var/www/foo">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Of course, /var/www/foo
itself and all parent directories have at least 755
permissions.