Ok, so last night I decided to start a bit of a tutorial on getting your own small web hosting setup(as if there aren’t enough out there already). I started listing all of the things I would want to include. I wanted this to be an all-encompassing tutorial, as much as possible. I hate having to go to all different places to look up information on one thing. I then realized, there is no way I can do this all in one post. Anyway, here’s part 1, which focuses on just getting the server up and running. I hope you don’t mind the lack of screenshots, I am doing the first installation steps from memory, they are simple, but feel free to comment any questions you may have.
-edit, this is just for a base system; i do not install a gui/desktop on my servers, the command is “sudo apt-get ubuntu-desktop” i would run it after everything else is running.
First, hardware all depends on what you will end up doing. For testing purposes, this will run perfectly well on anything with 512MB RAM, 1.0Ghz CPU, and 20GB HDD. I find that the most reliable web servers are LAMP(Linux, Apache, MySQL, PHP) servers, and the easiest linux to work with tends to be Ubuntu. Go ahead and grab Ubuntu Server Edition here. I use 8.04 LTS(Long Term Support), since they provide updates until 2013, but 9.04 should configure pretty much identically. Once you have downloaded the proper iso, burn it to a CD using whatever tool you prefer(I use Burn4Free).
-For more information on verifying CD data and burning see here and here.
Throw in the CD and boot up the installer. It starts with the language settings and keyboard layout, then it configures networking with DHCP. Put in your server’s hostname and time zone. Now comes hard drive partitioning/configuration. For testing, the automatic configuration may be ok, but I always like to do it myself. First, I configure the /boot partition (100MB is the standard) as ext3 at the beginning of the disk. Next, I would configure the swap partition, this is like pagefile in Windows. Go with the 1.5x however much RAM you have in the system. Then, I would put in /var as ext3. This directory has all of your highly variable information, including log files and most importantly, your web documents. Give this about 5-10GB(assuming a 20GB HDD). Finally, there comes the /(root) directory. This also needs its own partition, it will contain all the system files, user’s files and everything else on the server. Since it is a server, I don’t generally expect to have any users with documents sitting around, so again, 5-10GB. Those should be the only partitions you need. There are hundreds of ways you could partition your drives, but this is just a bsaic config to get us going and give us a little bit of separation.
The base system will then install; you will add a user, this user will have root(administrator) privileges via the sudo command. Now, you have the option to install additional packages. The only thing you will want here, is LAMP server, this will install the basics of what you need to get your web server running. Finally, the last step before rebooting is to set the clock to UTC. you now have a Ubuntu LAMP web server. The first thing you will need to do after rebooting is run updates on your server. Aptitude is one of the best package managers I have seen and there is too much information for Aptitude for me to include here, so Google to your heart’s content, but it’s simple enough you shouldn’t really have to. Here are the commands to update your system:
sudo apt-get update
sudo apt-get upgrade
The first updates the repository files, the second actually downloads and installs the newer software versions. Just like any machine, run the updates regularly. Also, it is good practice to update the repositories before installing any new programs. This ensures you install the most up-to-date programs.
Alright, let’s go ahead and set you up with a static IP address. We will use vim to edit the network configuration file. the file is located at /etc/network/interfaces
sudo vim /etc/network/interfaces

This is pretty simple, I am assuming everyone reading this knows what their subnet, gateway, andavailable IP is. Match it up to the format you see above. After updating, you will need to restart networking on the server. Use the command:
sudo /etc/init.d/networking restart
Now, you will need to open port 80 in your firewall to be forwarded to your server. This varies greatly depending on your router/firewall setup, so I will trust you know how to do this. Next, we will install OpenSSH server for remote administration of the server and vsftpd for uploading(and downloading) files to your server. To install OpenSSH, type the following command:
sudo apt-get install openssh-server
If you want access to your server outside of your network, be sure to open port 22 on your firewall. That’s it, you can now use a tool like putty to remotely administer your server. You can also change the port ssh runs on for more security, but we will get into that in the coming security post. Now on to installing vsftpd for uploading/downloading files remotely. Run the command(dont forget to update repositories first):
sudo apt-get install vsftpd
The default configuration file for vsftpd is /etc/vsftpd.conf. We will need to edit this to allow users to transfer files.
sudo vim /etc/vsftpd.conf
uncomment this line to allow local users to logon.
local_enable=YES
to disable anonymous logons change the following line
anonymous_enable=YES
to
anonymous_enable=NO
then to allow uploading of files, add the following line:
write_enable=YES
That should be all you need for the ftp configuration on the server, now let’s restart to vsftpd service to set the changes in effect.
sudo /etc/init.d/vsftpd restart
Now, just open port 21 on your firewall, if you want access from outside your network. I use WinSCP for file transfers.
Now all you need to do is put your site files in /var/www and it should be serving up pages right away. For those of you at home without a static IP, head over to DynDNS.com to set up a dynamically updating domain name to access your site. Come back soon and I should have more detailed sections on:
- Configuring security for openssh, vsftpd, and apache (including brute-force dropping via iptables)
- Configuring virtual hosts in apache (multiple domains/sites on one server)
- Configuring apache for immproved performance
- Scripting Ubuntu linux updates and backups
- anything else i can think of to add