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…

1 year ago

Merrimu Reservoir drone images

Merrimu Reservoir from drone. Click images to view larger.

1 year ago

FTP getting array of file details such as size using PHP

Using FTP and PHP to get an array of file details such as size and…

2 years ago

Creating Laravel form requests

Creating and using Laravel form requests to create cleaner code, separation and reusability for your…

2 years ago

Improving the default Laravel login and register views

Improving the default Laravel login and register views in such a simple manner but making…

2 years ago

Laravel validation for checking if value exists in the database

Laravel validation for checking if a field value exists in the database. The validation rule…

2 years ago