Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I would like to utilize Ubuntu server as web server, but I want to make sure I follow best practices for setting things up. I want to ensure I set the directory up in the best location and understand how to configure the appropriate security on that folder. I would like to be able to FTP to the server and push files into the web folders, so I would like to under stand how to ensure that my PureFTPd user can manipulate files/directories within the web folders.

share|improve this question
add comment

4 Answers

What I did on my server so that my user could sftp things straight into /var/www is:

sudo chgrp -R www-data /var/www
sudo usermod -aG www-data $(whoami)
sudo chmod -R 775 /var/www/*
sudo chmod 2775 /var/www

This will put your user into a group that has group ownership on /var/www and all its child directories, set everything in /var/www recursively to allow your group write access, and set the setgid bit on the /var/www directory so that all files later created under /var/www maintain the same group ownership rather than having the group set to the creator's primary group.

share|improve this answer
    
This would be a good method, but only if you create a different group from www-data which is the group that the web server itself already runs under. As a result, any compromise of the web server scripts means the files under /var/www could be changed. Just change www-data to something like web-users (and create that group first, with sudo addgroup web-users). –  Kees Cook Oct 26 '10 at 18:25
add comment

This is a very general question.

Obviously, you don't want to run your web server as root. However, the Ubuntu install already does that in the right way.

Furthermore, on the apache website are some tips how to properly configure your directory.

In regards of ftp. You want to make sure you use a secure ftp server that does not send your usernames and passwords in plain text over the network. The Ubuntu help pages have a tutorial how to set up such an ftp server.

share|improve this answer
    
I appreciate the information, I do realize it is general, I was hoping there might be a rather general take on the best practices for setting things up. –  JPrescottSanders Aug 20 '10 at 13:52
add comment

I found this answer on serverfault.com, and found it very useful. A lot of the comments are great tidbits for dealing with this topic.

share|improve this answer
add comment

When I have just an Ubuntu server, with multiple users using the server as a web server I scrap the /var/www directory because to me - /var/www is where you put web files globally. I update the /etc/skel directory and add a public and private folder with a symlink www -> public and update all my virtual hosts DocumentRoots to point to /home/<user>/public.

I don't see /var/www as the place to put multiple user-level folders and files. That's what the /home/ directory is designed for! It keeps paths and directory structures clean.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.