Local Development, Apache vs Developer - file permissions Local Development, Apache vs Developer - file permissions apache apache

Local Development, Apache vs Developer - file permissions


It doesn't matter, I personally placed it in /var/www/ and put it under the www-data group, and placed my username into the www-data group.

You add yourself into the group with:

sudo usermod -a -G www-data <username>

Change the group to www-data just in case you haven't:

sudo chgrp -R www-data /var/www

Get new files to inherit the permissions (750)

sudo chmod -R 2750 www-data /var/www

Some people prefer to put it in /home/username/www/ which would be easier.


If you prefer to put it somewhere else, like your Eclipse workspace directory, you can change Apache's DocumentRoot (or create a VirtualHost with a different DocumentRoot). Edit Apache's httpd.conf file, and add this at the end:

NameVirtualHost *:80<VirtualHost *:80>  ServerName mytestserver.localhost  DocumentRoot /path/to/project/dir</VirtualHost>

The *s can be left as-is; that means they will work regardless of your IP address.

The ServerName can be anything you want, as long as you add a corresponding entry in your /etc/hosts file, e.g.:

127.0.0.1 mytestserver.localhost

I often make all my local servers end in ".localhost", just as a convention.

Finally, restart Apache. Then you can access the server at http://mytestserver.localhost. Repeat as necessary to use multiple virtual hosts, each pointing to a different project.

As long as the files can be read by everyone, which is usually the default, you should be fine.


It's definitely possible to work on your site directly in your server's /var/www/ directory. however, it's probably better practice to setup a local environment (using something like XAMPP) to edit your website on a development machine and then upload it to your live server when it's ready. that way you don't introduce any bugs or errors into the live site temporarily.