Ubuntu 18.04 LAMP Server – Quick Setup and FTP to Webserver

I recently setup an Ubuntu 18.04 webserver to test webpages locally. I used tasksel to quickly install the LAMP server role as follows:

sudo apt update
sudo apt install tasksel
sudo tasksel install lamp-server

With the webserver up and running I needed to be able to FTP into the var/www/html directories to upload my HTML and CSS.

As Ubuntu server comes with SSH installed be default I decided to use that for FTP instead of installing something like vsftd (Very Secure FTP Daemon). FTP over SSH turned out to be a much simpler and quicker setup.

Warning: These steps do not restrict access to folders outside of the /var/www/html directories. As such this setup is not recommended for any kind of production server.

First create a new directory under /var/www/html:

cd /var/www/html
sudo mk dir newdirectory

Create a new user and give the user a password:

sudo adduser ftpuser
sudo passwd ftpuser

Finally give the new user the permissions that they need. Change the directory ownership and group:

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

Give the group write permissions to the directory:

sudo chmod -R 775 /var/www/html/newdirectory

Add the new user to the www-data group:

sudo usermod -a -G www-data ftpuser

With this done I configured FileZilla to establish a secure FTP connection to my webserver.

Filezilla: Secure FTP using SSH File Transfer Protocol.

Sources:

https://www.digitalocean.com/community/questions/permissions-on-var-www-html-for-uploading-web-site-files-via-sftp

Ubuntu Server – Very Quick FTP Setup

ubuntu-server-logo

To get an FTP daemon running on Ubuntu Server we will install vsftpd (Very Secure FTP Daemon) as follows:

sudo apt-get update
sudo apt-get install vsftpd

The next step is to configure vsftpd by editing the /etc/vsftpd.conf file. Issue the following commands to install the nano editor (if you haven’t installed it before) and edit the file:

sudo apt-get install nano
sudo nano /etc/vsftpd.conf

The basic configuration of vsftpd.conf involves simple editing and un-commenting of the existing parameters:

Un-commenting is the removal of the # sign from the start of a line. For example changing #local_enable=YES to local_enable=YES (which we will do later).

  • To disable anonymous access change anonymous_enable=YES to anonymous_enable=NO.
  • Un-comment #local_enable=YES to allow local users to login to the FTP server.
  • Un-comment #write_enable=YES if you want users to be able to upload to the FTP server.

Vsftp.conf contains an explanation of its parameters – so it should be relatively self-explanatory if you wish to configure other options.

The final step is to restart the vsftp daemon. On older Ubuntu servers you will probably use sudo /etc/init.d/vsftpd restart but a more recent installation will prefer:

sudo service vsftpd restart

Enjoy!