Set up a Railo/Apache/MySQL host on Ubuntu - Part 3: install FTP server and set up user access
This article will show you how to install FTP server on Ubuntu (might work with other Unix OS as well) and how to give your users FTP access only to the folders you want them to manage. This is the third article of the series "Set up a Railo/Apache/MySQL host on Ubuntu", which is composed of 4 parts:
- Part 1: install Apache and Railo
- Part 2: install MySQL and enable remote access
- Part 3: install FTP server and set up user access
- Part 4: install subdomains
In the first 2 parts, I showed you how to install Railo, Apache and MySQL server on Ubuntu. If you would like to follow the series from the beginning, you can read part 1 at Set up a Railo/Apache/MySQL host on Ubuntu - Part 1: install Railo and Apache and part 2 at Set up a Railo/Apache/MySQL host on Ubuntu - Part 2: install MySQL and enable remote access. However, the topics of these articles are quite independent. So you don't need to read the first 2 articles if you are only interested in installing FTP server and set up user access.
At the end of every step, if necessary I will include a little part called Step verification for you to know if you have completed that step successfully. It's important that you check this as a step depends on the one before it to be completed. So if you could not get one step done successfully, there is chance you will encounter errors at the steps that follow.
PART 3: Install FTP server and set up user access
1. Assumptions and notes
1.1 You have SSH access
Similar to the first 2 parts, this article assumes that you already installed Ubuntu 9 and you got SSH access to your host. Plus, you have permission to run certain commands on it. If you receive error saying "Permission denied" or something similar, try to use sudo before the command and login with your password when asked at the first time.
1.2 If you are using Windows, you have a Unix-mode editor installed
During this process, you will need to edit some config files. If you are on Windows, make sure you use an editor that supports Unix-mode to do this. A good and free one is Crimson Editor. This is very important. You have to edit the files under this editor otherwise they will cause errors when you reupload them to the server. Do NOT use Notepad.
1.3 You already set up your sites
You should by now have set up your sites and known where the files in those sites are located. If you follow the first article about installing Railo, your sites will be sitting under the /srv/www/ folder.
There are no specifc rules of where these folders have to be. So if someone else installed Railo and set up the sites for you, ask that person where he/she puts the files.
This article assumes that you have set up 2 sites and their files are under the following folders:
- Site 1's files are at /srv/www/mysite1.com/
- Site 2's files are at /srv/www/mysite2.com/
2. Create local user accounts
Before giving users access to FTP, we need to set up local user accounts and give them access to the right folders. Let's assume that we need to grant access for the following users:
- User 1 (username USER1 & password PASS1) needs to have access to site 1.
- User 2 (username USER2 & password PASS2) needs to have access to site 2.
Create and grant user 1 access by typing the following commands at SSH:
$ passwd USER1
(enter the password PASS1 when prompted)
$ chown USER1 /srv/www/mysite1.com/
$ chown USER1 /srv/www/mysite1.com/*
Create and grant user 2 access by typing the following commands at SSH:
$ passwd USER2
(enter the password PASS2 when prompted)
$ chown USER2 /srv/www/mysite2.com/
$ chown USER2 /srv/www/mysite2.com/*
The 2 users have now been created.
3.Install FTP server
Type the following command at SSH to install FTP server:
4.Enable FTP access for local users
Although the 2 user accounts have been created and they could login via SSH, they can't login via FTP yet. By default, FTP server requires separate accounts to be set up for each user. However, I find this unnecessary as I only create accounts on Unix if I want those users to be able to manage the files on their sites.
This step will update the FTP server settings so that local Unix users could login via FTP as well using the same password they use for SSH login. This saves user management time.
Open the FTP config file at /etc/vfstpd.conf and set the following options:
- Remove anonymous user so that only those who have a Unix account can login. Set:
- Allow local user to login. Set:
- Enable write permission. Set:
- Change umask for local user to make sure they have the correct permission. Set:
- You can optionally set the welcome message that users see everytime they login. Set:
ftpd_banner=Put your welcome message here
5. What's next?
This is the end of part 3 of the series "Set up a Railo/Apache/MySQL host on Ubuntu". If you follow the first 2 parts as well, you should now have a host installed with Railo, Apache, MySQL and you could download/upload files via FTP. In part 4, I will show you how to install subdomains.
Finally, thank you for reading. Please let me know what you think about this article by leaving a comment below. Is it too brief? Is it too detailed? Is it easy to follow? And more importantly, does it work for you?