Tutorials, Guides, Tips, and Tricks from Everyday Experiences

This is my attempt at guiding new webmasters (like myself) through the setup process of setting up a simple web server for friends and family (and possibly, with a little bit of creativity on your side, a full-blown web host like those you usually pay for). I will provide commands to execute in the Linux terminal, the programs needed, and some programs that I would highly suggest.

As a prelude , I want to make sure that this tutorial is something that you feel that is right for you. The following are the steps that I personally took to get my “Hildreth Server” up and running (no longer active). Now, the Hildreth Server is just a very simple website with two pages: 1.) a main page with links to various locations of mine (including the actual files on my computer), and 2.) a home page that serves as an “About” page. This is essentially what I will be walking you through how to do. Here’s a screenshot of what I’m talking about:

So, let’s get started. It may initially appear to be daunting and hard, but stick with it… it’s not bad at all. Also, another caveat to consider is that this was done in Fedora 8 Linux, so your flavor of Linux may be just a little different but the principle is the same.

The configuration of the web server by default will be fine for most users, but if you’d like to make it your own, the files are located here:/etc/php.ini
/etc/httpd/conf/*
/etc/httpd/conf.d/*

2.) Setup port forwarding in router:

This step is probably the most important. Basically, it will route all incoming web server requests to the correct computer by forwarding port 80 using both TCP and UDP protocols to the IP address of your computer (web server). I’m not going to explicitly list all instructions in this tutorial, but I will lead you to a great guide for the popular routers:

In Fedora 8 Linux, this port is blocked by default and needs to be opened. Goto System -> Administration -> Firewall. You will be asked for you password to run as a privileged user (root). Once you’re here, scroll down and find the HTTP entry and put a check mark next to it to allow HTTP traffic through (as show below).

4.) Test to see if port forwarding has worked:

This is an important step as well. Goto the “CanYouSeeMe” port checker by going to http://www.canyouseeme.org and in the “What Port” box, type in “80”, and click “Check”. You should see a message that states

“Success: I can see your service on <your ip address> on port (80)”.

If you don’t, go back and check that 1.) you have the HTTP service enabled and running in the background by going to System -> Administration -> Services and look for “httpd”, 2.) the correct ports are forwarded to the correct IP address of your computer and they are enabled, and finally, 3.) make sure your firewall has allowed HTTP traffic.

5.) Test the server (Apache) by visiting your external IP address:

Goto www.whatismyip.org and get your IP address. Then copy/paste it into your browser (Firefox) and see if you get the default Apache test page. If you see something similar to the following screenshot, then you’ve gotten your web server setup properly!

6.) Setup a dyndns.org account:

Your internet connection is probably setup with a dynamic IP address, meaning it’s going to change eventually. When it changes, there is no way to get to your web page without knowing what your IP address is (unless you’re really good a guessing IP addresses). So, a service that will track your IP address and give your website a domain name is very handy. This is where dyndns.org comes into play.

Goto http://www.dyndns.org and register for a new account. Once you have created an account and you’ve signed in, you’ll want to click on the “My Services” link on the left followed by the “Host Services” link. This is where you’re going to add services, so add one by clicking on “Add New Hostname”. You’ll see something similar to this:

This is the fun part because you get to choose what your web address (URL) is. I chose sendderek.dyndns.org because it’s easy for me to remember. Choose what you like in the “Hostname” field. The only other thing you need to change is the “IP Address” field by clicking on blue link that states “Use auto detected IP address xx.xx.xx.xxx“. That’s it for that part. For the next part, you’ll want to setup your router with dyndns.org (may not be supported on all routers).

The reason you want to get dyndns.org setup with your router is that when your IP address changes, your router will notify the dyndns.org service of the new IP address so that dyndns.org can change it. On a Linksys router, the option is under “Setup -> DDNS”. Choose the DynDNS.org service and then enter in your account information. Pretty simple.

7.) Setup the web pages:

Congratulations! If you’ve gotten this far, you officially have a self-hosted website! Now, to add some content and some fancy HTML pages! Maybe even a wordpress.org blog of your own or an e-commerce business selling stuff. If you’re going to be trying to sell some stuff though, I would recommend you purchase a domain name that people can associate with. Either way, the folder to put your content into is located on your file system at /var/www/html/. Just be sure to name the main page “index.html” and then add pages from there.

And if you don’t have any experience with HTML programming or website design, I would suggest grabbing a nice template from somewhere of your choosing. I highly suggest using Open Source Web Design for such a purpose. I used the template called “Deep” by Vacant for the Hildreth Server.

If you’re going to use a template, you’ll have to make it your own somehow with links that actually lead to places on your website. So, use an HTML editor to do just that. I used bluefish which is an excellent editor for several web development languages. Unfortunately, it’s not a “What You See Is What You Get” (WYSIWYG) editor. If you’re just starting, you’ll probably want something like that. I suggest NVU or Kompozer (both of which are very closely related) for just that. Personally, I like Kompozer better because it’s easier to install for Fedora 8.

Have fun with it! It’s your website… do what you want to do with it! You website address is whatever you created in your dyndns.org account, so visit it in Firefox (or your browser) to see what your site looks like.

8.) Optional: Setup a symbolic link to local directories:

On the Hildreth Server, I allow my family and friends direct download access to my pictures and music directories. In order to do this, I created a symbolic link in my /var/www/html/ directory by using this command in the terminal:ln -s [source][/source][destination]
For example:ln -s ~/pictures/var/www/html/pictures

9.) Optional: Install the AutoIndex script code:

I found AutoIndex (by Justin Hagstrom) when Google searching for a way to present my pictures directory in a more user friendly manner with thumbnails and a way to download an entire folder rather than just a picture at a time. This script does more than just thumbnails and folder downloads though. Explore it and find out what it’s capable of. Just install it into the directory that you want to share. Here’s the link:

I chose to use this step for personal reasons. You may or may not want to use a password to lock people out, but I suggest it. There are two files that control the password. One is called httpd.conf and the other is .htpasswd. The file httpd.conf has already been created and is located in the /etc/httpd/conf/ directory. The other file needs to be created by you and placed into the directory you want to protect. An easy way to do this is to type these commands into the terminal: touch .htpasswd
Give it a password by using the htpasswd command where “guest” is the username you would like: htpasswd -c .htpasswd guest
You can add more users as well by using the same code.

Then, you’ll need to setup the httpd.conf file. Open the httpd.conf file by using the commandsudo gedit /etc/httpd/conf/httpd.conf
and then add these lines to the bottom of the document after the last line (replacing the text in red with the directories and description according to your directory structure):
<Directory “/var/www/html/pictures“>
AllowOverride AuthConfig
AuthName “Are you privledged for pictures?”
AuthType Basic
AuthUserFile /var/www/html/pictures/.htpasswd
AuthGroupFile /dev/null
require valid-user
</Directory>

11.)

11.) Enjoy!

That’s it! You’re finished. Try it out on a computer outside of your network and see that it works! Also, if you like to tinker, there are some good guides about optimizing your new Apache server through this link and this other link.

I have also written a couple of other tutorials on how to take advantage of the new web server:

There's 26 Comments So Far

I registered with dyndns.org, but I already have my “own” DNS. The thing is my server is going to go down soon, so how can I have my dynamic IP resolve to my DNS, and maintain the site on my personal machine?

sendderekJanuary 28th, 2008 at 11:17 pm

@ Elias:

I’m glad that you’ve asked a question, but as a beginning web admin on my own, I’m not really sure how to answer that one. I can take a stab at it though.

Before I do, I’m kind of confused about your description. By “my ‘own’ DNS”, do you mean you have a domain name registered? And why is your server going down? Do you shut it off sometimes, or is it going down for maintenance?

My site was put together by a more experienced web developer when I didn’t even have my own computer. Since then, I have purchased a new computer and am trying to migrate everything over to my own box and avoid any hastles with the person who initially helped me set the site up.
So, I have my own FQDN (purchased from who I don’t quiet know exactly, yet) But … the server that is currently hosting my site (which is not related to the site my DNS was purchased from) is going to let my site go. I have been reading a post on Fedoraforums and believe I have found parts of a whole that will ultimately become a solution.
I have port 80 open and registered with easydns.com and am going to install ddclient shortly to help forward my address.
I initially wanted a static IP address, because I wanted to experiment with Asterisk and Trixbox, but where I live (in Seoul [I teach English]) they are asking $140/month. That’s another issue though.

sendderekJanuary 29th, 2008 at 1:55 pm

Wow… I’d hate to admit this, Elias, but you’re in way over my head. I’m sorry, but I’m not going to be able to help you out much.

However, you have given me some new terminology to explore!

tamirJanuary 31st, 2008 at 11:07 am

well keep the great job man thanks what about the mail server how to setup that in fedora 8 ?
would u also post some tutorials in how to d o that …thanks

sendderekJanuary 31st, 2008 at 11:25 am

Tamir:

You’re welcome! Thanks for showing your appreciation!

I can sure try to write up a tutorial on how to get a mail server going, but to be honest, it looks like howtoforge has a great tutorial on the matter located here:

Thanx for the tutorial, I’m very much new in linux, anyway, It was alright till port forwarding(as it says success), but I cant see/test the server (Apache).

what was wrong or what else can I check !

sendderekFebruary 13th, 2008 at 10:28 am

Sorry to hear you ran into a bump!

I would be sure to double check your firewall. Also, if you’re running Fedora Linux (or any other distro that uses the SE Linux Policy Management) set that to disabled for now for testing purposes. Also, make sure that the httpd service is running.

fumiFebruary 14th, 2008 at 11:56 pm

My firewall and SE Linux is disabled and also httpd is running.

SimFebruary 26th, 2008 at 11:53 am

Thanks, your tutorial was great. I am up and running. The problem I have know is that when I veiw my web site, it just shows the index of index.html and lists the file that I added. It didn’t open as a normal web page. What configuration changes are needed? Please help!

sendderekFebruary 26th, 2008 at 12:22 pm

@Sim:
As of right now, I’m not sure what would be causing such a problem. The only thing I can think of is that the file called “index.html” is outside of the var/www/html/ directory or that it’s not named correctly. Check to make sure that it’s index.html not just index.htm or something similar. I’ll try and think of what could be happening in the meantime…

SimFebruary 29th, 2008 at 8:35 am

Yes, you were right. I found the problem. I had created a folder named index.html inside the html folder. I deleted the folder that I created and put my file directly in html and it worked just fine.
Thanks

simFebruary 29th, 2008 at 9:11 pm

Hey,I am back with a question. I have been doing a lot of reading about locking down the server with some security tweaks. When I go to etc/httpd I find two main folders for configuring Apache named (conf )and (conf.d)The(conf) folder has (httpd.conf) and when opening the file it tells me that is a main file for configuring Apache. There is also a (system-config-httpd.conf) file in folder (conf.d) which is used for configuring Apache. Which configuration file should I be modifying with changes?

sendderekFebruary 29th, 2008 at 11:27 pm

You want the (conf) directory. So, the full path is:
/etc/httpd/conf/httpd.conf
That’s the proper file to edit and make changes to Apache. Just remember to restart the httpd service to apply the changes.

I’m glad to hear that your first issue was resolved, by the way.

Tweety32September 11th, 2008 at 3:34 pm

Hi there,

I have gone through all of your steps and did the following:
1- Forward Port to a Local IP
2- Check port from http://www.canyouseeme.org/ and it is successful.
3- Apache up and running, checked from same system and another system on the LAN
4- Firewall on the system accepts traffic to the HTTP port

But I am not able to explore my default apache setup page from the external IP. When I goto the url using my external IP, the browser just keeps trying to connect but after a while it fails.

Sendderek, your tutorial is excellent, very useful. I have learned a lot about Apache and servers.

HJdM

Mahua ChakrabartyAugust 12th, 2009 at 4:42 am

I have Fedora 9 installed on my computer as a “Stand Alone Computer”. I am a new bee. Fedora was installed with default intallation mode and I dont know what is its ip address. I have Apache, Perl, PHP, MySql installed and running well. I have a domain and I have access to DNS Management.
I want to use my computer for Academic/Experiment purpose as a web server with my own domain say xxxx.net.

How do I know ip address of my computer and how do I change it?
I want to set my Primary and Secondary DNS of my domain as “ns1.xxxx.net” & “ns2.xxxx.net” and then how do I configure my computer with that DNS setting so that the computer becomes home web sever?

The IP address of your computer ought to be listed under ‘eth0’ of the ‘ifconfig’ command. In order to change your IP address, it’s as simple as running this command: “ifconfig eth0 192.168.1.100”. I’m not sure about the second question you had.

Benjamin BvalaniNovember 11th, 2009 at 7:57 am

This is very nice Derek, i am a linux newbie and thanks for the Tutorial chief it will help me setup my first webserver, i too just got my Bsc in Computing(Hons) and secured some admin Job.