FTP-able server with correct Apache permission settings

If you’re setting a local server you may want some trusted admins to upload to, one good way is the vsftp server. DigitalOcean has a good tutorial on it, but there are some odd issues.

First, if you haven’t already, set the vsftp conf as in that tutorial, and add users one per line to /etc/vsftpd.userlist.

Set local_root=/var/www/whatever, in your /etc/vsftpd.conf and it will go there in Filezilla, but… no uploads available to Apache!?

The solution: set the primary group of the user you created and uploaded file will be that user group.

usermod -g www-data username

Note there should also be GROUP readability and writability for Apache (but not EVERY user on the system ideally), so as documented here you may want to

sudo nano /etc/vsftpd.conf

add:

file_open_mode=0775
local_umask=0011

to your config as described here along with the other values, then restart, and your uploads will be usable to Apache!

sudo service vsftpd restart

Now go ahead and try, upload a test.php file and try to access it and Apache should find it with the right permissions now.

One final note – if you use WordPress, it can be picky about permissions and in some cases it may have permissions issues, and must have its files be the same user as apache – so after adding or changing files you may need to use

sudo chown -R www-data:www-data /var/www/html/

or similar.

Leave a Reply

Your email address will not be published. Required fields are marked *

eight ÷ two =