I have a web server directory located at /var/www/web
. Inside one of the files, let's say create_dir.php
, I'm creating a directory with mkdir()
. I'm getting the following message.
Warning: mkdir(): Permission denied in /var/www/web/create_dir.php on line 122
Now, I can run this file when I am the owner of the file, or directory. But, when I am not the owner, I cannot edit the files inside PhpStorm.
My user is called josh
and the apache2 user is the default, www-data
.
I essentially need to make a group, or a special/magic user that will allow me to run and edit the files whenever.
Note: I have looked at this superuser answer and it did not work for me. I ran this command to create the group:
sudo groupadd website
I ran these commands to add the users:
sudo usermod -a -G website josh
sudo usermod -a -G website www-data
I ran this command to add it to the web folder:
sudo chgrp -R website /var/www/web
I ran this command and once I reloaded my website, I got a Forbidden error message.
sudo chmod -R 770 /var/www/web
So I ran this command to be able to view the webpage:
sudo chmod -R 775 /var/www/web
And now I'm back to square one.
Any help is appreciated.
ls -ld /var/www/web
to make sure the ownership is what you'd expect. Also, have you restarted apache2 since making the change? Changes to group permissions only take effect when a user logs in again. – terdon Nov 10 '17 at 14:32apache2
withsystemctl restart apache2
works. Thank you. – Josh Murray Nov 10 '17 at 14:39sudo chmod g+s /var/www/html
. – Panther Nov 10 '17 at 15:21