Document Root Option

apacheBy default apache installs the document root at /var/www.  This can cause an issue, as only the root user account can access this folder properly.  Here is an alternative setup that overcomes this issue.  

Visit the apache site for more information. 

Document Root

Start by creating a new document root directory.  I've called my directory /apache, but you might want to choose a different, more secure name.

sudo mkdir -p /apache/www

sudo cp -r /var/www/* /apache/www/


Now we need to change the apache config file to match this new directory.

sudo vi /etc/apache2/sites-available/default


Change the following lines...

DocumentRoot /apache/www

<Directory /apache/www>


Apache will need a restart after these changes.

sudo /etc/init.d/apache2 restart


Home Directory Access

I've also created a symbolic link in my home directory (just like the web hosting companies) so I can work simply from my home directory...

sudo ln -s /apache/www/ /home/steven/



The final step is to make sure the permissions are set optimally.  Start by making your user account a member of the www-data group.

sudo usermod -g www-data steven 

Now you can change ownership of the document root.

sudo chown -R steven:www-data /apache/www


Thanks for visiting.