-1

Can't change Apache web root directory on Ubuntu.

file exists in sites-enabled folder

I changed /etc/apache2/sites-enabled/mynewsite.conf file document root

<Directory /media/saptarshi/BAAA7114AA70CDFF/webdev>
    Options Indexes FollowSymLinks
    Allow from all
    AllowOverride None
    Require all granted
  </Directory>

and, also I changed /etc/apache2/apache2.conf file document root

<Directory /media/saptarshi/BAAA7114AA70CDFF/webdev>
Options Indexes FollowSymLinks
AllowOverride None
Allow from all
Require all granted
</Directory>

After changing those I restart the apache then it not worked. Shows

403 error. Forbidden You don't have permission to access this resource. Apache/2.4.41 (Ubuntu) Server at localhost Port 80

But magically when I change the path within the home directory(/home/saptarshi/test) then it work. So , Is it possible to change apache root directory outside the home folder in ubuntu?

  • You describe changing `document root`, but actually what you've shown is changing ``. Are you also changing `DocumentRoot`? Does Apache have permissions to read that directory? Have you checked all the suggestions in https://stackoverflow.com/questions/5891802/how-do-i-change-the-root-directory-of-an-apache-server, https://stackoverflow.com/questions/10873295/error-message-forbidden-you-dont-have-permission-to-access-on-this-server, https://stackoverflow.com/questions/27160209/debugging-why-i-get-you-dont-have-permission-to-access-in-apache-2-4 ... etc? – Don't Panic Aug 06 '21 at 07:56
  • hi , Yes I changed DocumentRoot to /media/saptarshi/BAAA7114AA70CDFF/webdev , apache have the permissin to read the directory and check all the suggession but it didn't work... – saptarshi tah Aug 07 '21 at 08:47

1 Answers1

0

Two things I would like to mention. Firstly, because of something isn't working, don't write the same configurations into multiple apache config files. It will create more problems rather than solving one. Secondly, you should always edit the respective site config file in the /etc/apache2/sites-available/ directory rather than editing the file in the /etc/apache2/sites-enabled/ directory. It's a symlink, so, it's always better to edit the main file and reload the config.

Now your problem might or might not be related to directory path only. It might be a user permission related problem as well. Could you please attach the entire apache2.conf file and the mynewsite.conf file? Also, what's the host you're trying to access it with?

Supratim Roy
  • 842
  • 11
  • 16
  • hii, I have recently uninstall the apache server and again reinstall it. Now, still the multiple apache config file exists which I have created previously. – saptarshi tah Aug 15 '21 at 10:29
  • For now I have just edited the /etc/apache2/ directories apache2.conf file's following code ` Options Indexes FollowSymLinks AllowOverride None Require all granted ` entire apache2.conf file is attached into the following link, [link] (https://drive.google.com/file/d/1ho-w7xzwI6ri3CYPnUvf94puFJFIr4K9/view?pli=1) – saptarshi tah Aug 15 '21 at 10:29
  • We, have also edited the /etc/apache2/sites-enabled/ directory's 000-default.conf file to the following code, `DocumentRoot /media/saptarshi/BAAA7114AA70CDFF/webdev` entire 000-default.conf file is attached into the following link, [link] (https://drive.google.com/drive/search?q=000-default) Host that I am trying to access is following: /media/saptarshi/BAAA7114AA70CDFF/webdev – saptarshi tah Aug 15 '21 at 10:30
  • @saptarshitah the config that you have added just allows you to use a directory outside of the /usr/share and /var/www directory. The link that you have shared for the 000-default.conf file looks like a folder and doesn't contain that config file! Need to see that file. – Supratim Roy Aug 17 '21 at 01:53
  • hi sorry for late. check this link, https://drive.google.com/file/d/1j7s4bm1LNRNG88gUefI-ITKCjsLdF6ct/view?usp=sharing . Here I add 000-default.conf file. – saptarshi tah Sep 01 '21 at 02:55