Assuming you have read the first part of the tutorial, let us now take the next few steps on the path to hosting our own blog.
FTP turned out to be the only difficult step in the whole process. I have chosen to use Pure-ftpd 1.0.29 (as was recommended to me) and all in all, I am satisfied with it. Once you get around it’s couple of quirks it is very to the point. Before we get into that though, I wanted to talk a bit about interacting with our shell Ubuntu server that we setup last time. As I said before, I am a windows guy and since I set this server up as a console I needed a way to interface into it without having to set up a whole other KVM. The software I found is PuTTY. This little SSH front-end is very nice and light weight. Everything I have done in my server (after installing from the CD of course) was done through this. That was one of the main goals behind my choice to setup a console server. I wanted to be able to turn the machine on, stick it in a corner and forget about it. So far, this has been acheived!
Pure-FTP is an FTP server. So even after it is setup on the Ubuntu box, I still need a way to use/test it. For this I chose the FileZilla client. This client is run on my windows machine and is how I interface with my Pure-FTP. So, spin up your shell, and log in. Then create a temporary directory for which to download the Pure-FTP server. Once you have navigated to that directory, run the following command:
$ wget ftp://ftp.pureftpd.org/pure-ftpd/release/pure-ftpd-1.0.29.tar.gz
This command will download the tarball into our current directory. You can then extract the tarball using the following command:
$ tar xzf pure-ftpd-1.0.29.tar.gz
This command will spill the contents of the archive into your current directory. After you have extracted the archive, we will need to compile the server. This requires some extra tools that do not yet exist on our Ubuntu box. We get those “coding essentials” by running the following command:
$ sudo apt-get install build-essential
Once the installer finishes, we now have all the compilers and linkers we will ever need for our Ubuntu server. To compile pure-ftp, follow this documentation. The third section is the one you are interested in, titled: ——Compilation—— (use this switch: --with-puredb). If you wish to skip the documentation on compiling (which I would never recommend), here is the short of it:
Create group for Pure-FTP
$ sudo groupadd pure-ftpd
Create user for Pure-FTP
$ sudo useradd -g pure-ftpd -d /var/empty -s /etc pure-ftpd
Create make file
$ sudo ./configure --with-puredb
Run make file
$ sudo make install-strip
Since we have compiled using the puredb switch, we now need to create users to be able to login to our ftp server. I created two users. One “master” user and a wordpress user. See this documentation on adding user accounts.
(Set the home directory of your wordpress user to: /var/www)
Create linux group for virtual users
$ sudo groupadd ftpgroup
Create linux user for virtual users
$ sudo useradd -g ftpgroup -d /dev/null -s /etc ftpuser
Create virtual user for wordpress
$ sudo pure-pw useradd wordpress -u ftpuser -g ftpgroup -d /var/www
(you will be prompted to enter, then reenter a password for this user)
Update virtual user database
$ sudo pure-pw mkdb
Repeat the above steps to create more users. (Note: you can use the same linux group/user for all of your virtual users and this will make permissions a breeze. Though this may not be wise if you plan to use this FTP server for other things besides your wordpress blog.) After you have compiled and created your virtual users, it is time to start the FTP server up. Do so by running the following command:
$ /usr/local/sbin/pure-ftpd -j -lpuredb:/etc/pureftpd.pdb &
Should you want to use a configuration file to startup your ftp server (instead of the command line), see this documentation. If you ever need to kill the server, do so with this command:
$ pkill pure-ftpd
Once your FTP server is up and running, you should now be able to log into it with both accounts you created using your Filezilla client. You can then go into your router (optionally) and setup port forwarding so that you can access your ftp server from outside your local network.
The first time I tried to log into my FTP server, I noticed that I could log in but could not upload/download anything. This was due to the fact that permissions were not set on my home directory for my ftp accounts. When you create your virtual users, you assign them to a linux user group/user. This group/user must have access to read/write to the files in the virtual users home directory. You can set this using the following command:
$ sudo chown -R <uid>:<group> <path>
$ sudo chmod -R 755 <path>
where ‘uid’ is the name of the linux user (created using the useradd command) you have assigned your virtual user to, ‘group’ is the name of the linux group (created using the groupadd command) you have assigned your virtual user to and ‘path’ is the virtual user’s home directory.
In the final part of this tutorial I will go over the actual download/install/setup of WordPress. Very simple stuff!