CHMOD files was created by root

June 11, 2014 1.9k views
Hello, I'm New DigitalOcean user, I creat a new Droplets (Ubuntu 14.04)and I install VestaCP to control web sites. the Problem is:- when I get files by ssh as "root"(Ex. Wordpress.tar.gz) and put it inside (public_html) in any sites and extract it as root the files&folders from (Wordpress.tar.gz) get CHMOD (nobody- nogroup) and web site's admin can't edit or create folders inside this folder. and my public_html is in: /home/admin1/web/user1/public_html not like /home/user1/public_html admin1: which is creat by VestaCP as a user (for creating websites and Data) user1: which is creat by VestaCP as a website Any solution ?
2 Answers
I'm now using this commands :
sudo chown -Rv username directory 
sudo chown -v username file
to give the user permission,but I think that isn't general solution !

The command you list are correct for changing ownership of files that you've already created. In the future, however, you should use the "user1" account whenever you are working on the site to ensure you don't have any future problems. There are two reasons for this:

  1. Depending on your configuration Vesta may use suexec to run scripts. for security purposes, suexec will not allow a script to run if it is owned by a user that is not the one running the process. Since all scripts run under the user that the site is assigned to, files owned by root in the public_html directory will not work if your server is configured this way.
  2. As a general rule, you should only use root when you need it. Root is all powerful, so it can be really easy to accidently do things you don't mean to do, like deleting important files because you aren't in the directory you thought you were. Working as "user1" is safer because you won't be able to don anything that effects the entire server or the files owned by any other user.
Have another answer? Share your knowledge.