How do I set up FTP on localhost?

On my old machine (back on Lucid!) I used XAMPP for local dev work. XAMPP installed everything for you, including setting up FTP to your localhost (/var/www) directory, since permissions don't allow you to write directly to it.

I have a new machine running Precise, and decided to do things the grown-up way. I installed everything using tasksel, and got apache, php, mysql, and phpmyadmin up and running. But it's kind of a pain to have to create and edit all my files via gksudo gedit on the command line, and sooner or later I'm going to have to upload images.

How can I set up FTP so that I can "upload" files to my localhost server?

Edit to add

Followed the first video, but when I got to the point where he was creating files (around 7:25 in), I get hung up. Here's what my terminal looks like when I try to get into the /srv directory (which I verified does exist in Nautilus):

enter image description here

What do I need to do to get past this?

3 Answers

Well, I was just trying to do this exact same thing...

I looked it up on Youtube, he explains how to do it with a GUI. It is basically the same thing with a CLI, if that's what you are using, just all with text- obviously.

Here is part one editing the .conf file for vsftpd:

Configuring FTP in Ubuntu - Part 1

And part two, where he finishes adding permissions and access control:

Configuring FTP in Ubuntu - Part 2

Best of luck...

4

I wanted to get something similar to a trick of quickly starting HTTP server

python -m SimpleHTTPServer

which I use to download (not upload) files, i.e. I wanted something like this but for FTP server

  • no security concerns about my network (e.g. localhost)
  • no or minimal installation
  • no configuration, like creating users, etc.
  • no system-wide registration, I need this ftpd only once
  • quickly start server and serve for the current path

I ended up with

sudo pip install pysendfile
sudo pip install git+git://
wget
sudo /usr/bin/python unix_ftpd.py

Your working folder should be the one to serve into. Tip: checkout on github there are more demos with other/no authorization handlers. Performance wise this python based server is not that bad if compared to vsftpd

1

You can use vsftpd to set up a local FTP server. Install it using

sudo apt install vsftpd

Configuration

In your case, you'll have to update the config to allow users to log in to their home directories, by adding/uncommenting the following lines in /etc/vsftpd.conf:

chroot_local_user=YES
allow_writeable_chroot=YES

⚠ Warning: This will allow any system user to sign in via FTP and use their username/and password to read and modify files. Be sure to disable it when not in use (see below).

Next, you will need to create a new user, setting the home directory to the your web root:

sudo adduser ftpuser
sudo usermod --home /var/www/html ftpuser

Restart the vsftpd server to use the updated settings:

sudo systemctl restart vsftpd

Now, you should be able to log in and modify files in /var/www/html by logging in using the username/password of the user you just created.

Disabling the system

As a side-effect, the current setup also allows any system user to sign in via FTP using their username and password, which is a potential security risk. You can probably edit /etc/vsftpd.conf to fine-tune these permissions (I don't know it well enough to instruct you).

However, I would suggest disabling the vsftpd server when you are not using. This can be done with the following command:

sudo systemctl disable vsftpd

This will prevent vsftpd from starting automatically on boot. You can then manually start it using

sudo systemctl start vsftpd

and stop it again when you're done using it

sudo systemctl stop vsftpd

This will stop the vsftpd server and disable all FTP connections until you start it again.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like