apache wont follow symlinks | 403 permission denied
i finally solved my problem with following solution, may it help anyone in the future...
sudo chown me:www-data /home/me
sudo chmod 710 /home/mesudo chown -R me:www-data /home/me/myWebDirectory
sudo chmod -R g+r /home/me/myWebDirectory
Caution : you may for example not want all subdirectories to be readable by apache, so adapt the -R(ecursive) directive.
But important is to give the apache user group read access to ur home then read access to the concerned infant.
LauDem
People call me an agile Tech leader with a feeling for sales. I personnaly simply consider we live in a volatile, uncertain, complex and ambiguous world where successfully achieving digital transformation is no longer a simple option for nowadays companies, but an absolute imperative. Technical Stack : Databases : SQL (MySQL, Postgre), NoSQL (MongoDB, CouchDB, Firebase, Firestore, HBase / Hadoop), ElasticSearch Development : Javascript, TypeScript, PHP, HTML, CSS Frameworks & libraries : NodeJS, Angular (JS & 2-10), Symfony (1,2,3), Laravel (5+), GraphQL, Webpack, RabbitMQ, Apache Kafka DevOps : Linux (Debian / Ubuntu), Docker, GCP (Google Cloud), OpenVZ & LXC (proxmox), Vagrant & VirtualBox
Updated on September 18, 2022Comments
-
LauDem over 1 year
I'm using Ubuntu 14.04, and have a problem with the Apache configuration:
I created a Symlink from
/var/www/html
torwards/home/me/myWebDirectory
but
localhost/myWebDirectory
renders a403-permission denied
and in fact,
sudo -u www-data ls /home/me/myWebDirectory
returns a permission denied tooapache2.conf had following directive :
<Directory /var/www> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>
I changed it for
<Directory /var/www/html>
, but no result.I tried to add the
me
user towww-data group
with this commandsudo usermod -a -G groupName userName
, but that didn't help eitherwhat is it that I missed?
EDIT: I changed the group of
/home/me/myWebDirectory
into www-data with rx rights, but no success either...As I said, I was well aware that I had a reading permission problem as this
sudo -u www-data ls /home/me/myWebDirectory
returning me a permission denied too (which means www-data doesn't have the rights to see what in it).But I need certain point of your answer to be clearer :
Also you should use url "localhost/html" instead of "localhost/myWebDirectory".
Actually I've made the Symlink like follow :
cd /var/www/html
ln -s /home/user/me/myWebDirectory myWebDirectory
so I think accessing
localhost/myWebDirectory
is the right address, no?chown -R www-data:www-data /var/www/html
- since ubuntu 14.04, Apache DocRoot is
/var/www/html
, why should i chhange its owner (like many other deamons, roots by default). /localhost/testfile.html
works fine (undertsand testfile is in/var/www/html
)/localhost/phpmyadmin
works too, even if it's a SymLink to/usr/share
(while m trying to have a symLink to/home/user
...)
chmod +r /var/www/html # add read permission to dir
chmod +r /var/www/html/* # add read permission to files in dir
- Add read permission to who? to myUser?
- But that is exactly what I don't want to do.
- I actually want apache to be able to read in /home/me/myWebDirectory and not myUser to go write in apache's directories.
NB: I know there's another way to do it, while activating the apache
mod_userdir
and that's probably what i'll be going to do next. But first i'd like to understand how to make this "simple" solution work...