Laravel Bitnami Linux File Permissions

Candidates for file permission fails:

  1. /storage/*
  2. temporary directories
  3. cannot write sitemap
  4. shell scripts
  5. wp-content/*
  6. etc…

You might see something like: “unable to write permissions error”

The cheap way would be to set everything to 777 open to world (not recommended, but ok for local development).

The better way to solve this is to do the following:

  1. SSH login into your server using bitnami user
  2. add all relevant users to the www-data group
  3. change group ownership of the document root directory to www-data
  4. set created directories to inherit the www-data group by default
  5. change the permissions of the document root directory to the daemon user
  6. restart apache (optional)

#2. adding users to the www-data group
sudo usermod -a -G www-data bitnami
sudo usermod -a -G www-data root
sudo usermod -a -G www-data daemon

#3. changing the web dir to ownership of www-data
sudo chown -R www-data:www-data /opt/bitnami/apache2/htdocs/back-end/

#4. created directories inherit the group
sudo chmod g+s /opt/bitnami/apache2/htdocs/back-end/

#5. change file permissions owner to deamon
sudo chown -R daemon /opt/bitnami/apache2/htdocs/back-end/

#6. restart apache
/opt/bitnami/ restart apache

That’s it, now your application should have access to read/write to folders and files but it should be blocked to the outside world.

Sam Deering

Sam Deering is a web developer from England (currently living in Australia). In his spare time he enjoys coding, playing chess, reading and investing.

Leave a Reply

Your email address will not be published. Required fields are marked *