I always have trouble with file security on Ubuntu with my Apache and ProFTPD installs. I write this article to document my steps to setup Apache and ProFTPD so I don't have problems with file permissions all the time.

Note 1: This article expect that Apache and ProFTPD is already installed and working.

Note 2: This article is only supposed to be used on a single site Ubuntu install. When several users share the web server the setup is different.

1. Your ftp user need to be part of the www-data group and the home folder need to be "/var/www/html". (I normaly use webmin to create the user but I will add the command line command here.)

sudo useradd -m -d /var/www/html ftp-username www-data

 2. You web files directory should be in the correct permissions. The user and the group should have Read+Write permissions.

sudo chmod -R g+w /var/www

 3. All your web files should be set to user www-data and group www-data.

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

 4. You need to setup Apache to add Group write permissions when it creates a file. Open "/etc/apache2/envvars" in your text editor and add the following line to the bottom.

umask 007

 5. You also need to tell ProFTPD to write files with the Group write permissions. Open "/etc/proftpd/proftpd.conf" in you text editor and find the Umask line.

Change the following line

Umask  022  022

to the following

Umask  007  007

 6. You need to restart your Apache and ProFTPD server.

sudo service apache2 restart
sudo service proftpd restart

Hope this article help. enjoy.

Reference Link 1: https://www.whatmarkdid.com/web-servers/setting-apache-permissions-www-data-ftp-user/

Reference Link 2: https://linuxize.com/post/how-to-create-users-in-linux-using-the-useradd-command/