0
votes

I'm setting up a new website on a new Ubuntu droplet at Digital Ocean. I set this up previously on a different droplet and rsynced the website contents to it. I followed directions I found on the web, but didn't keep detailed-enough notes. I'm just trying to replicate this on the new Droplet. But I've messed up somehow. My knowledge of permissions, etc. is rudimentary :-(


My server has: /var/www/html

This is what I did:

• sudo usermod -a -G www-data [myusername] • sudo chown -R www-data:www-data /var/www • sudo chmod -R g+rw /var/www • sudo chmod -R g+rws /var/www

I then created “/var/www/howardmann.us/public_html” for my website.

(I didn't put the public_html directory in var/www/html. I didn't on my other Droplet. Perhaps I should.)


sudo ls -la /var/www

total 16 drwxrwsr-x 4 www-data www-data 4096 Feb 25 15:43 . drwxr-xr-x 14 root root 4096 Feb 24 14:27 .. drwxr-sr-x 3 root www-data 4096 Feb 25 15:43 howardmann.us drwxrwsr-x 2 www-data www-data 4096 Feb 25 15:42 html


sudo ls -la /var/www/howardmann.us/public_html total 8 drwxr-sr-x 2 root www-data 4096 Feb 25 15:43 . drwxr-sr-x 3 root www-data 4096 Feb 25 15:43 ..


Now, excerpts of rsync script (successful to my other Droplet) result from my laptop now:

1.

howardm$ ./deploy.sh sending incremental file list rsync: failed to set times on "/var/www/howardmann.us/public_html/.": Operation not permitted (1)

  1. rsync: recv_generator: mkdir "/var/www/howardmann.us/public_html/css" failed: Permission denied (13) * Skipping any contents from this failed directory *

3.

rsync: mkstemp "/var/www/howardmann.us/public_html/.DS_Store.8zaaQg" failed: Permission denied (13)


Question: How do I fix ownership and permissions on the server directories for 1) proper permissions for a website and 2) permit a rsync deploy?

For comparison, here is the status of my current working web site on the other Droplet:


howardm@howardmann:~$ ls -la /var/www/ total 20 drwxrwxr-x 5 howardm www-data 4096 Mar 5 2016 . drwxr-xr-x 13 root root 4096 Mar 28 2015 .. drwxrwxr-x 4 howardm www-data 4096 Jun 8 2016 howardmann.us drwxrwxr-x 2 howardm www-data 4096 Mar 29 2015 html


Thanks!

Howard

1

1 Answers

0
votes

Well, I fixed this after reading some more about permissions for a website.

My website folder is titled howardmann.us, which contains a public_html folder with the website contents.

So: /var/www/howardmann.us/public_html. (/var/www also contains a html directory)

I achieved the relevant ownership/permissions with:

  1. sudo chown -R howardm:www-data /var/www/

I'm the owner, and www-data the group.

  1. sudo usermod -a -G www-data [myusersername]

I'm a member of the www-data group

  1. sudo chmod -R 2775 /var/www/

This yields the proper permissions, I believe for a web site.

I made sure the same owner:group applied to all these directories:


ls -l /var/www total 8 drwxr-sr-x 3 howardm www-data 4096 Feb 26 19:23 howardmann.us drwxrwsr-x 2 howardm www-data 4096 Feb 25 15:42 html


ls -l /var/www/howardmann.us total 4 drwxr-xr-x 11 howardm www-data 4096 Feb 5 2017 public_html


Now rsync works without errors.

If anyone believes these ownership/permissions for a website are (substantially) improper, please comment.

Howard