Score:0

Redirecting Apache2 public directory to directory: www inside /home/user in Ubuntu 21.04 for local development

cn flag

I have changed the Apache2 public directory for years changing the content of file
/etc/apache2/sites-available/000-default.conf

so:

DocumentRoot /home/user/www
<Directory "/home/user/www">
   Require all granted
</Directory>

In the file: /etc/apache2/apache2.conf
I wrote the follow line as last line

ServerName localhost

Then I go to restarted Apache with:

sudo /etc/init.d/apache2 restart

All the past times this have resulted but in Ubuntu 21.04 when I go In my Web Browser to:
http://localhost it show me 403 error:

Forbidden
You don't have permission to access this resource.

I see it have changed somthing in Apache. How can I fix that?

Thanks

raj avatar
cn flag
raj
Does the user under which Apache is running (may be 'apache', 'www-data' or similar) have access to your `/home/user/www` directory? Also look at the Apache error log, you may find more detailed explanation there.
cn flag
Ok Thanks. It's a problem with the permissions
Score:0
cn flag

I have solved the situation not moving the directory, only I have asigned permissions to my user to the directory var/www/html

sudo chgrp www-data /var/www/html
sudo usermod -a -G www-data user
sudo chmod -R 775 /var/www/html
sudo chmod -R g+s /var/www/html
sudo chown -R user /var/www/html
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.