Localhost configuration and problem with file permissions Whenever I work on my local machine I am almost always experiencing problems related to file permissions settings, and since I guess they may be related with my local machine configuration I would like to explain how did I configure it in order to get advice on how to configure it properly (Since my knowledge on server configuration is quite limted and I am far from being a sysadmin).

My local machine is using ubuntu as OS and I installed php5, php5-mysql, mysql-server, apache2 and phpmyadmin separately using ubuntu's packages. The only custom configuration I made is that I don't place the websites in etc/apache2/www folder as default but on a specific folder at my home partition ~/www . In order to make this settings work I have to do follow this steps:


I edit /etc/apache2/sites-enabled/000-default as to point to that folder by replacing /var/www with the path to ~/www
Restart apache (sudo /etc/init.d/apache2 restart)
Create a symlink inside ~/www which points to /usr/share/phpmyadmin (#  ln -s /usr/share/phpmyadmin /home/carlos/www/phpmyadmin )


This configuration has the following benefits which are quite important to me:


I can keep my code safe whenever I install a new ubuntu release (this is, every six months) yet at the same time I can format / partition without losing any data.
I don't need extra permissions (sudo) every time I want to edit any file (which is often, since it's my development environment), update modules and so on.


However, it also has some drawbacks like the ones I mentioned with file permissions, and I think they are related to the fact that the owner of the files and folders is not www-data user but my own user.

Is there any way to prevent problems with file permissions but also preventing having to place the files in etc/apache2/www folder?
The web server must have a properly configured file structure to operate. The files should be placed under /var/www or /usr/local, not under /home. The /etc directory is for system and configuration files, not web data files.

There should be no reason for you to format the root partition when maintaining a system, but if you insist on doing so, put /var /usr and /home on a separate drive, and mount them under the root during boot. That way you will not lose any data.

If you are so desperate to ease the editing, work as root and learn to be careful. But make sure the files are under the correct group and owner for the web server to operate.