Serve a site yourself – a noob guide

Since this site is for educational purposes I should document some of the difficulties I’ve had and how I overcame them.  First, this is a really old machine (read the boombox post) and I really don’t care if I break it.  In fact, it has been suggested to me that I TRY to break it.  How else can one learn?

So I started with a fresh install of Centos 5.5 from a startup CD.  The majority of the install came from online repos though which were fairly easy to connect to.  I wiped the entire 80gb internal drive and installed with no server or GUI.  I was a DOS kid.  I’ll be a CLI linux user.

I used yum to install the Mysql, Apache, PHP package:

$ yum install httpd

Then I had to figure out how to configure Apache and the network interface to work with my network.  Here it is in a nutshell:

All the important network configs live in /etc/sysconfig/

The first one to make sure is working properly is the “network” config file.  Here is the cat:


That wasn’t too hard to figure out from examples (the Centos Wiki is amazing) and watching over my friend’s shoulder (sometimes virtually via screen).  The GATEWAY is my Belkin router’s ip address.

Then I had to configure the network interface.  The file for that lives in /etc/sysconfig/network-scripts/.  Since my network interface is eth0 the config is called ifcfg-eth0.  Makes sense!  Here’s the cat:


So this sets up my static LAN ip address to be which is below the DHCP range on my router of 100-whatever.  DHCP is the automatic ip address gizmo that lives in your router.  I made the static ip for boombox outside of the range for any automatic ip addresses.

It took plenty of tinkering for me to get these two files right!  If you are diving into linux for the first time I suggest keeping a notepad handy to write down the function and location of important config files!  Since I was doing this in my spare time I would forget and have to go hunting for these little guys.

At this point it is smart to set up your router.  Most routers are set up to handle normal internet traffic so they must be tweaked a little to be able to serve a page from a computer on their network.  Do this by setting up port forwarding.  Since most www traffic happens on port 80 insert this into the port forwarding (sometimes called Applications and Gaming) feature of your router:

External port = 80 Internal port = 80 for both TCP and UDP to the ip address ( in this example) of your server.  Be sure it is enabled.

You may also want to make another entry for port 21 for ftp and 22 for ssh (so you can log into your box from the outside world).  However there are some security risks involving the use of standard ports…

Change your ssh port in the config file /etc/ssh/sshd_config.  Just change the port number in there to one you know to be available (let’s say port 99).  Then enter that port as above into the port forwarding feature of your router.

You can now log into your box with this command:

$ ssh -l billybob 69.345.34.78 -p 99

This means you are logging in as billybob to your external ip address using port 99.  You know your external ip address, right 😉

That brings me to the next issue, your external ip address.  I have a normal DSL connection so my external ip address (the one the rest of the world sees) is always changing.  This can be resolved a few ways.  You can use a service like, (they aren’t .org anymore).  I chose to use the ddns feature offered by my domain host,

I haven’t been able to get a ddns client to work on this Centos machine though.  Still working on that!  However, I do have a Windows computer that is on regularly.  I installed namecheap’s easy-to-use Windows ddns client on that computer and set it to transmit my external ip address to namecheap every 15 minutes.  It works great!  The ip address gets saved as an A record for the subdomain I set up in namecheap.  That is why you see here.  The boombox subdomain is the one that has the dynamic ip transmitted to it.

Whew!  There is a lot to write about even in this watered down form.  I’ll make a new post shortly documenting my Apache/PHP/Mysql adventures.  If there is something you want clarification on I’ll try to do so.  If you are a newbie like me we will be the blind leading the blind!  Fun times! 🙂

Leave a Reply