Score:0

Solved: Apache doesn't resolve symbolic links in /var/www

us flag

SOLUTION(thanks to Dan):

<Directory /var/www/exams>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted
</Directory>

and

chmod -R 775 ~/Sviluppo
chown -R www-data ~/Sviluppo/mysite

BEFORE THE SOLUTION

I read all other questions and don't solved the problem. I have a Ubuntu server 21.10 with lamp(Apache 2.4.48) I made a symboliclink with ln -s ~/Sviluppo/myWeb /var/www/myWeb and it is ok. Then in apache a made this module:

    <VirtualHost *:80>
   ServerName myWeb
   DocumentRoot /var/www/myWeb/public
    <Directory /var/www/myWeb>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
    ErrorLog /error.log
    CustomLog /access.log combined
</VirtualHost>

And I enabled it with sudo a2ensite myWeb. Then I setted privileges with

    sudo chown -R www-data myWeb

Now I have a Forbidden error: you don't have permission....

But the same configuration worked for me in Ubuntu 20.04 . It seems that Apache doesn't follow symlink!!! What can I verify? Bye. Thank you very mutch.

in flag
This may be AppArmor blocking access to the directory, as Apache is limited to resources in `/var/www` only (despite the symbolic link). If you run `sudo systemctl disable apparmor` and restart Apache, are you able to load the page correctly? If so, you may want to modify your AppArmor profile for Apache. It's a good idea to have AppArmor running if this server is connected to the web, so don't leave it off for too long.
user2994206 avatar
us flag
Thank you very mutch for your help. I disabled the apparmor service but it doesn't solved.
ar flag
Please don't put SOLVED in the question title in this question answer site. The green check mark ✅ is sufficient. You can answer your own question below and mark your answer as the accepted answer with ✅ instead of @Dan s answer.
Score:1
jp flag
Dan

In Apache 2.4, the Order and allow directives have been removed in favour of the Require directive.

In your case, you need to change the two lines to the following:

Require all granted

Even after making that change, make sure that the www-data user has read access to the ~/Sviluppo/myWeb directory if you are still facing a problem.

Apache will also need the execute permission on the parent directories to be able to traverse the path.

chmod o+x ~/
chmod o+x ~/Sviluppo

WARNING: Keep in mind that the last two commands give any user on your system access to your home directory. So if this is a shared system, I would recommend having your site's code somewhere outside your home directory and give read/write access to your user and read access to the www-data user on that directory.

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.