Okay so these are some example commands that I find useful when I am on my development environment. These are ran on Ubuntu 24, I guess they work for all flavors of Linux just mind the directory structure. Make a folder that you would like to hold your files for example a folder named simple_csv_expenses_parser/ inside the /var/www/ folder.
Now to make it easier to develop without using a superuser every time we need to set permissions. There are 3 major tasks we need to complete:
NB!!! If you have .git folder inside your web resource think about giving it apache2 permission access first. Another way is to create a public folder and point the Document Root to that.
- 1. Give apache2 group, www-data, access to the folders and files
sudo chgrp -R www-data /var/www/simple_csv_expenses_parser/
sudo find /var/www/simple_csv_expenses_parser/ -type d -exec chmod g+rx {} +
sudo find /var/www/simple_csv_expenses_parser/ -type f -exec chmod g+r {} +
- 2. Give the user that is going to develop his permissions
sudo chown -R vagrant /var/www/simple_csv_expenses_parser/
sudo find /var/www/simple_csv_expenses_parser/ -type d -exec chmod u+rwx {} +
sudo find /var/www/simple_csv_expenses_parser/ -type f -exec chmod u+rw {} +
NB!!! Change vagrant to whatever username you have
- 3. Set folder so every new file created has the apache2 www-data group permissions
sudo find /var/www/simple_csv_expenses_parser/ -type d -exec chmod g+s {} +