Setting up FTP for an Apache website under Ubuntu

Once you have set up a website under Apache, you would need FTP access to the website to be able to upload files. The steps below explain how to do this.

 

1.Install VSFTPD server :

sudo apt-get install vsftpd

 

2.Make changes to the vsftpd configuration file by uncommenting or adding write_enable=YES and chroot_local_user=YES  and enabling local_umask=022

# Enable this to allow users to write files to their web folder
write_enable=YES

# To restrict users to specific web folders and block access to parent folders
chroot_local_user=YES

local_umask=022

 

3.Create a user for FTP and ensure that it is part of the www-data group. We are using ftpvc as an example user and assume that the website home folder is /var/www/html

useradd -s /usr/sbin/nologin ftpvc

sudo passwd ftpvc # you will be prompted to enter a password twice

sudo usermod -d /var/www/html ftpvc

usermod -a -G www-data ftpvc

4.Now make sure that the ftp user has not shell to login to the system directly.

Add the following line in /etc/shells

/usr/sbin/nologin

Save the file

5.Restart vsftpd server

service vsftpd restart

6.Make sure that the website folder is owned by the ftp user and the www-data group.

 

 

 

Be the first to comment

Leave a Reply

Your email address will not be published.


*