Categories: Development

FTP to your Apache root on Ubuntu

Once you have installed Apache on your server you most likely need an easy way to edit or upload files. The root of Apache is /var/www Here is a way that i found the easiest and shortest. This work on Ubuntu 18.04 x64 and will work on previous versions… 16.04 and 17.04. You will need to have root priviledges for this.

Install vsftpd (ftp server)

sudo apt-get install vsftpd

Next youre going to need to do a small edit to the vsftpd config file, this can be done by using

sudo nano /etc/vsftpd.conf

Find the line that is

#write_enable=YES

and remove the # making it just

write_enable=YES

Then press ctrl + o to save and ctrl + x to exit nano

Now create a user and set users home directory to /var/www/

Note ftpusername is the username (it will ask you to set a password)

sudo adduser ftpusername

sudo usermod -d /var/www -m ftpusername

Lets now add the user to the www-data group permissons

sudo usermod -a -G www-data ftpusername

Set the permissons for /var/www

sudo chgrp -R www-data /var/www

sudo chmod -R g+w /var/www

Make all directories below /var/www owned by the www-data group too

sudo find /var/www -type d -exec chmod 2775 {} \;

Set the current file/s in /var/www to the group

sudo find /var/www -type f -exec chmod ug+rw {} \;

Finally restart vsftpd

service vsftpd restart

And you can now edit and uplaod files to the Apache root on your server.

Share

Recent Posts

Kennington reservoir drained drone images

A drained and empty Kennington reservoir images from a drone in early July 2024. The…

2 years ago

Merrimu Reservoir drone images

Merrimu Reservoir from drone. Click images to view larger.

2 years ago

Early September spring shots

Some early September spring shots from a bushwalk, It is still too early for wildflowers.

3 years ago

Cloning an NVMe to SK Hynix Platinum P41 NVMe

I recently needed to clone over a smaller NVMe to a 2TB SK Hynix Platinum…

3 years ago

Using Laravel’s deleteDirectory to delete folders and their contents

If you ever needed a simple solution in Laravel to delete an entire directory and…

3 years ago

How to allow only 1 user to register in a Laravel application

How to enforce only one user to register or be registered in a Laravel web…

3 years ago