How to change Apache's DocumentRoot
Is there a way to change Apache's DocumentRoot? In /etc/apache2/default-server.conf there is this line: DocumentRoot "/srv/www/htdocs" I changed it to another directory and restarted Apache. systemctl restart apache2 But http://localhost shows this text: Access forbidden! You don't have permission to access the requested directory. There is either no index document or the directory is read-protected. But there IS an index document in the new directory and nothing is read-protected. What has to be done more than this?
On maandag 29 januari 2024 14:53:56 CET Siard via openSUSE Users wrote:
Is there a way to change Apache's DocumentRoot? In /etc/apache2/default-server.conf there is this line:
DocumentRoot "/srv/www/htdocs"
I changed it to another directory and restarted Apache.
systemctl restart apache2
But http://localhost shows this text:
Access forbidden! You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
But there IS an index document in the new directory and nothing is read-protected. What has to be done more than this? Most likely you need to change the ownership / group, and/or the perms of the document root of your choice.
-- Gertjan Lettink a.k.a. Knurpht openSUSE Board openSUSE Forums Team
On Mon, Jan 29, 2024 at 5:10 PM Knurpht-openSUSE <knurpht@opensuse.org> wrote:
On maandag 29 januari 2024 14:53:56 CET Siard via openSUSE Users wrote:
Is there a way to change Apache's DocumentRoot? In /etc/apache2/default-server.conf there is this line:
DocumentRoot "/srv/www/htdocs"
I changed it to another directory and restarted Apache.
systemctl restart apache2
But http://localhost shows this text:
Access forbidden! You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
But there IS an index document in the new directory and nothing is read-protected. What has to be done more than this? Most likely you need to change the ownership / group, and/or the perms of the document root of your choice.
And possibly adjust AppArmor profile/SELinux policy to allow access as well.
On Mon, 29 Jan 2024 17:20 +0300, Andrei Borzenkov wrote:
On Mon, Jan 29, 2024 at 5:10 PM Knurpht-openSUSE wrote:
On maandag 29 januari 2024 14:53:56 CET Siard via openSUSE Users wrote:
Is there a way to change Apache's DocumentRoot? In /etc/apache2/default-server.conf there is this line:
DocumentRoot "/srv/www/htdocs"
I changed it to another directory and restarted Apache.
systemctl restart apache2
But http://localhost shows this text:
Access forbidden! You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
But there IS an index document in the new directory and nothing is read-protected. What has to be done more than this?
Most likely you need to change the ownership / group, and/or the perms of the document root of your choice.
And possibly adjust AppArmor profile/SELinux policy to allow access as well.
After further searching and experimenting, the problem appeared to be caused by something else. Except for this line: DocumentRoot "/srv/www/htdocs" /etc/apache2/default-server.conf also contains this: <Directory "/srv/www/htdocs"> .... .... </Directory> Here, '/srv/www/htdocs' had to be changed to the new directory as well. Duh!
On woensdag 31 januari 2024 14:21:13 CET Siard via openSUSE Users wrote:
On Mon, 29 Jan 2024 17:20 +0300, Andrei Borzenkov wrote:
On Mon, Jan 29, 2024 at 5:10 PM Knurpht-openSUSE wrote:
On maandag 29 januari 2024 14:53:56 CET Siard via openSUSE Users wrote:
Is there a way to change Apache's DocumentRoot?
In /etc/apache2/default-server.conf there is this line: DocumentRoot "/srv/www/htdocs"
I changed it to another directory and restarted Apache.
systemctl restart apache2
But http://localhost shows this text: Access forbidden! You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
But there IS an index document in the new directory and nothing is read-protected. What has to be done more than this?
Most likely you need to change the ownership / group, and/or the perms of the document root of your choice.
And possibly adjust AppArmor profile/SELinux policy to allow access as well.
After further searching and experimenting, the problem appeared to be caused by something else.
Except for this line:
DocumentRoot "/srv/www/htdocs"
/etc/apache2/default-server.conf also contains this:
<Directory "/srv/www/htdocs"> .... .... </Directory>
Here, '/srv/www/htdocs' had to be changed to the new directory as well. Duh! Nice
That said, I suggest to have a folder inside the document root, f.e. /srv/www/htdocs/example.com/ This makes maintenance easier IME -- Gertjan Lettink a.k.a. Knurpht openSUSE Board openSUSE Forums Team
participants (3)
-
Andrei Borzenkov
-
Knurpht-openSUSE
-
Siard