Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proper owner of var/www/html [closed]

I am running apache2 in Ubuntu 14.04. I have been having trouble with permissions with FTP clients and CMS that use backend FTP. I never seem to be able to get the permissions right. Should www-data be the owner of /var/www/html and root as a user assigned to that group?

like image 322
Unique Depiction Avatar asked Mar 07 '15 19:03

Unique Depiction


People also ask

Who should own files in var www html?

Normally the webserver user owns that directory. If you're using apache2 then usually its www-data user/group that owns them. You may have 1 process that root runs, but the rest should be the apache2 user.

What does var www html mean?

/var/www/html is just the default root folder of the web server. You can change that to be whatever folder you want by editing your apache.conf file (usually located in /etc/apache/conf ) and changing the DocumentRoot attribute (see http://httpd.apache.org/docs/current/mod/core.html#documentroot for info on that)


1 Answers

Some CMSes and Wordpress is especially bad about that because it's actually in the code to use the web user.

BTW you should never need to use root for ftp. www-data the default apache user on ubuntu should own your web files/directory to work properly with many cmses.

So this is what has worked before and what we did for clients with the same issue. chown the whole web root as www-data for both user and group.

So if your document root is /var/www/html, cd or change directory to /var/www and run this to change ownership on all files and directories.

chown -R www-data: html/

while still in the /var/www directory add write permissions to the group for files and directories by running this command.

find html -type f -exec chmod 664 {} + -o -type d -exec chmod 775 {} +

Finally add your FTP user to the www-data group.

usermod -a -G www-data username

Replace usename with your FTP client username

Now this setup should allow you to use manage files and still allow the CMS ftp backend to still function and write to the direc. Let me know how that works for you.

like image 108
Panama Jack Avatar answered Sep 23 '22 19:09

Panama Jack