Configuring www folder on Ubuntu (Amazon EC2)

After running Amazon EC2 instance with Ubuntu Linux you may have problems with permissions on /var/www/ folder.

Your default user you login to Amazon instance may have no permissions to create files in www folder. To fix this you need to add your user to www-data group (on Ubuntu).

 

To best share with multiple users who should be able to write in /var/www, it should be assigned a common group.

The default group for web content on Ubuntu and Debian is www-data.

Make sure all the users who need write access to /var/www are in this group.

[codesyntax lang="bash"]
sudo usermod -a -G www-data <some_user>
[/codesyntax]

Then set the correct permissions on /var/www.

[codesyntax lang="bash"]
sudo chgrp -R www-data /var/www sudo chmod -R g+w /var/www
[/codesyntax]

Additionally, you should make the directory and all directories below it “set GID”, so that all new files and directories created under /var/www are owned by the www-data group.

[codesyntax lang="bash"]
sudo find /var/www -type d -exec chmod 2775 {} \;
[/codesyntax]

Find all files in /var/www and add read and write permission for owner and group:

[codesyntax lang="bash"]
sudo find /var/www -type f -exec chmod ug+rw {} \;
[/codesyntax] These instructions were found here. 

3 thoughts on “Configuring www folder on Ubuntu (Amazon EC2)”

Leave a Reply

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

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>