0

My PHP application and all the files are owned by www-data however I am currently logged in to the server using my username ruser. I'm developing on the same machine so everytime I want to test changes to my php code I have to go back and forth between file owners.

Is this the best practice or is there a different way I can set this up to make my development smoother?

3 Answers 3

3

Make your user part of the www-data group, or make the www-data user part of your group. Then give group access to your files:

usermod -a -G www-data yourusername

In terms of best practice, you should be developing on a different machine anyway. Then deploy your code and use scripts to set up whatever secure configuration is right for your project.

Sign up to request clarification or add additional context in comments.

Comments

2

There are a few options open to you.

1) You can change all the files to the www-data group while keeping them owned by you

from your site's root directory run:

chmod -R ruser:www-data ./*

2) The best method is to set up an ACL if your distribution supports it: http://bit.ly/Lat25d

3) Or the simplest method (on a dev machine only - don't do this on a live server) is to chmod everything to 777 from the site's root directory

chmod -R 777 ./*

1 Comment

@AntonioCS I presume you meant the third option is the least favourable..? I've edited my post to make it more obvious that there's a 2nd option hidden in the middle! :)
1

You can change the files to be owned by any user, i.e use the following command: chown username:groupname file.php

Only require Apache to own the files if Apache is going to write to the files or overwrite the files.

So change the ownership to the FTP user to avoid constant ownership changes.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.