How to make your own web server
By: Kevin | December 12, 2013
If you’re a tech nerd like me then you wanna know how everything works, start to finish. This is my attempt to tell you how to create your own server and host it from the comfort of your own home.
When I started researching how to build my website, every Google search pointed me to different companies offering web hosting and site builders like GoDaddy.com or Wix.com. Although these options work for many people, they are almost too easy – you don’t get the full sense how or why things work. So, I changed my search to “how to create your own server”.
Here’s what you’ll need to build your own server to host your own web site.
- A solid internet connection
- An “always-on” PC (monitor not needed after setup)
- Apache server software (free download)
- Domain name service provider (DNS), covered more in a minute
Your PC doesn’t need to be top-of-the-line, and in fact, virtually and PC will do. My server is a hand-me-down Dell tower my parents were going to throw out. Ideally, the PC you use will only be used as a server. Reason being, if you want your site accessible 24/7 then it needs to be powered on 24/7. Since I only use my server/tower machine as a server I did a clean wipe of windows before I started – just to have a clean slate.
Head over to http://www.apache.org/dyn/closer.cgi and download the server software. Apache is an open source software that was started back in the 90’s. It has evolved and is used by many servers all over the world. The full history can be found on apache.org, (which I recommend reading to get a full appreciation of Apache).
Apache is the software that turns your computer into a server, an HTTP server to be exact. Simply put, its the software that listens for requests, finds the file that was asked for, and then sends it back to you. If you’re reading this article, it means that my server sent your computer this page (file) when you clicked the link to get to here. Simple, right? This is how the entire internet is in existence. Servers all over the world, connected.
Install the server and follow the typical instructions. One recommendation is to install Apache in a root folder, like C:/Apache. This way it’s easy to find later. Apache also needs to know where to listen for requests, so when your’re going through the installation be sure to specify your computers IP address in “Network Name” and “Server Name”. To find yours (on a Windows machine) go to Start and type “cmd” into the search, then type in “ipconfig”. This will bring up some random information, but what you want to know typically starts with 192.168…. This is the case if you are connected to the internet through a router of some sort.
If you are using a router, you’ll need to do something called port forwarding. Picture this, every internet connection has an IP address assigned by your internet service provider (ISP).
Most people these days have multiple devices (wired or not). Your home router uses the IP address provided by your ISP then assigns all devices in your home their own local IP (usually starting with 192.168.). Doing this allows you to use multiple devices with a single IP address from your ISP. This is important to understand for port-forwarding. When you go to a web address, ie. mcgilln.com, what is really happening is you’re getting pointed to an IP address. Domain names are just a human-friendly way to remember numbers. So, typing in mcgilln.com really brings you to the IP address assigned to me by my ISP. Here is where port-forwarding comes in. Think of the IP as a street address of a big apartment complex that you need to deliver a package. You may get GPS directions to 1212 12th Street but that doesn’t help you get to your desgination because there could be 100 apartments at that address. What apartment does it belong to? Apache, by default, listens for requests on port 80. So what you need to do is log into your router and find the tab for port-forwarding. You need to explicitly tell your router what to do when it gets a request on port 80, which is to relay that request somewhere. Thats your servers local IP address (remember that 192.168….. you used earlier). Set your router to forward requests on port 80 to the 192.168…… You usually select something like “allow From port to port”, just put 80 on both. Save the settings in your router and you’re almost set.
Back to Apache. After you have Apache installed, don’t expect much. It’s extremely light weight and little to no user interface. You should see a small feather on the bottom right of your machine. If you have a red square then the server is not running. Double click and then click Start – if its green then you’re good to go. Open a browser and type in your computer IP address(192.168….). If your server is working properly you should get a page that says “It Works!”. Congrats!
Now, your IP address (192.168..) is for your local network, meaning that it will only work if you’re connected at home. So how do you get to your web server from the rest of the world? You need your ISP IP. (Confused yet?). To find this, open a web browser and type “whats my ip?”. A quick Google search will tell you what your public IP address is. Now as a quick test, grab your smartphone and type in “http://” then the public IP address Google just told you. (MAKE SURE YOUR SMARTPHONE IS NOT CONNECTED TO YOUR LOCAL WIFI OR IT WON’T WORK) If all goes well, you should again get the “It Works!” page. Congrats! And just like that, you’re live to the world.
Now that you’re live you’ll want to update your home page to something a little nicer than the “It Works!”. Your public root folder is called “htdocs” and inside is where you installed Apache. Change the files in there to something awesome that you created…and you’re off!
Lastly, you should know a majority of ISP’s use dynamic IP addresses. This means that even though today you may have a public IP of 184.108.40.206, tomorrow , without notice, it could change to 220.127.116.11. This presents a new problem of hosting your own site. If you use a godaddy.com or something similar to buy a domain name and want to point it to your home server, you’ll soon be SOL (when you IP changes and your domain is pointing to the wrong place).
You need a DNS service to handle the changes for you. I use a DNS service called no-ip.com which offers both free and paid services. The free service gives you a domain name to use to reach your server and provide an easy download that will keep your public IP address and domain name synced.
There you have it!