0

After a fresh install of Ubuntu, I am trying to change the localhost directory of Apache2 (2.4.7). As always, it's not simple at all and it doesn't work right now.

Here's what I have done so far:

$sudo apt-get install apache2

Then in /etc/apache2/apache2.conf:

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /home/louisro/Documents/www>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Require all granted
</Directory>

in /etc/apache2/sites-enabled/000-default.conf:

#DocumentRoot /var/www/html
DocumentRoot /home/louisro/Documents/www

in /etc/apache2/sites-available/000-default.conf:

#DocumentRoot /var/www/html
DocumentRoot /home/louisro/Documents/www

Then

$ sudo chmod go+r /home/louisro/Documents/www
$ sudo chown -R louisro:www-data /home/louisro/Documents/www

When I try to access localhost throught the browser, I get:

Forbidden

You don't have permission to access / on this server.

Apache/2.4.7 (Ubuntu) Server at localhost Port 80

And the log gives:

$ cat /var/log/apache2/error.log
[Fri Jan 22 09:13:38.792577 2016] [core:error] [pid 12934:tid 140432965080832] (13)Permission denied: [client ::1:56772] AH00035: access to / denied (filesystem path '/home/louisro/Documents') because search permissions are missing on a component of the path
  • The error may also mean that directory listing is not allowed. Do you have a index.html file in your Documents/www folder ? – Shantanu Jan 22 '16 at 8:21
  • no I don't have an index.html file. I have the directories of all the websites I am working on. – Louis Jan 22 '16 at 8:24
  • It seems that I had to this: $ sudo chmod 755 /home/louisro/Documents ; sudo chmod 755 /home/louisro ; sudo chmod 755 /home – Louis Jan 22 '16 at 8:24
  • can you access localhost/websitename/filename ? – Shantanu Jan 22 '16 at 8:26
  • @louis Your document root directory probably is just missing the x permission for the group owner. sudo chmod g+x /home/louisro/Documents/www should have been enough. What you did is somewhat of a security risk, specially if you're not the only user on the system. You gave access to everyone to list the content of your home directory. – Dan Jan 22 '16 at 8:33
1

Here's what solved the problem:

$ sudo chmod 745 /home/louisro/Documents ;
sudo chmod 745 /home/louisro ;
sudo chmod 745 /home
|improve this answer|||||
0

Try to change apache2.conf to:

<Directory />
        Options FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>
<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>
<IfModule mod_userdir.c>
    UserDir enable louisro
    UserDir public_html
</IfModule>
<Directory /home/*/Documents/www>    
    Options +Indexes +Includes +FollowSymLinks +ExecCGI
    AllowOverride All   
    Require all granted
</Directory>

Command:

$ sudo chmod 755 /home/louisro/Documents/www
$ sudo chown -R louisro /home/louisro/Documents/www

remove .htaccess if exist and create index.txt file then try to access http://localhost/index.txt

|improve this answer|||||
0

You are missing one essential step. After modifying the default DocumentRoot in 000-default.conf. To take effect you should enable 000-default.conf and restart apache2.

sudo a2ensite 000-default.conf
sudo service apache2 restart
|improve this answer|||||
0

I solved as:

First, I gave permission to the directory root. In my case this directory was:

/home/paulo/Documentos/SERVER

I run the following command:

$ sudo chmod 777 -R /home/paulo/Documentos/SERVER

After, I edited the file apache2.conf with the following command:

$ sudo nano /etc/apache2/apache2.conf

In the apache.conf I changed the following lines:

to

And I edited the file 000-default.conf in /etc/apache2/sites-available/000-default.conf and /etc/apache2/sites-enabled/000-default.conf. I changed the following lines:

DocumentRoot /var/www/html to DocumentRoot /home/paulo/Documentos/SERVER

Finally, I restarted the apache with the following command:

sudo systemctl restart apache2

I really hope this run in your machine;

|improve this answer|||||

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.