Here is my problem. I am developing a web application in PHP/MySQL and I am having some problems setting up the accounts I need to use.
Development workstation: WinXP SP3, Eclipse PDT
Development server: Debian 6.0, Apache2, MySQL 5, XDebug
Connected through a LAN.
While I am developing I upload code that needs to be tested to the server. I use GIT and ssh:root@myserver.
As expected, the files end up being owned by root in the server.
My web application needs to update some of the files. To allow that I ran chmod in the server to change ownership of the files to www-data. This works fine.
The problem is that every time I change a file and upload it again it reverts back to root ownership and I have to manually change it back to www-data.
I don't think this will be a problem in the production environment because I can ensure the files will have the correct ownership when they go live. However it is a pain the development process.
What I am thinking:
1 - I probably should not be uploading with a root account. I tried connecting to the server through ssh using the user www-data. However it asks for a password and after some reading I found out that it is probably not a good idea to mess with www-data user.
2 - I could probably create another account for development purposes and upload the files with that account. The problem is that I don't know how to configure my web application to use that account when connecting to the server and database.
3 - I could probably configure my application and database to run as root in the development environment. This would resolve the problem. However as stated in 2 above, I don't know how to do it and I something tells me that this would not be a good idea.
So I am looking for advice on how to solve my problem. I could go with any one of the three alternatives above (or even a 4th one that I haven't considered). Thanks.
Update - 2011-09-13
One solution from the responses below (thank you cdp1337) is to run a script to update the file permissions when I upload files to the development server. In my case, I could run
chown -R www-data:www-data *
in the root of my website. NOTE: this is NOT in the production environment and the development web server cannot be accessed outside our company. This is not a solution to deploy to production environment.
Any other ideas? Thanks.