A bit of a warning, if you read your agreement with your ISP you may find that you are not allowed to run any sort of server. Vodien make a good case for NOT running a home server. Some of it is a bit of a reach, the parts about heat and noise apply more to data centers rather than a lone computer at home. If you're running the server as a business or getting a zillion visitors then you probably should be looking for professional hosting. I've been running a web server from home since June 2003 and never had a problem with my ISP, my neighbours complaining about the noise from the server, the computer exploding or anything else.
This pages uses a lot of links to external websites. These are meant to provide extra information or examples of what I have done.
The last time my web server "The Server in the Cellar" got a major overhaul was on January 16, 2016 when I purchased a Dell Inspiron 3847 and installed WAMPServer on it. I also installed Syncplify.me Server - a FTP, SFTP, FTPS server.
The "Server in the Cellar." My nice new Dell Inspiron 3847 on January 16, 2016
The Dell has an Intel i5-4460 @ 3.2GHz processor. In December 2019 it was upgraded from 8Gb to 16Gb RAM and the 1Tb hard drive replaced with a 1Tb SSD. It was also in December 2019 that I thought about a new design for this site and reinstalling the server software. This page documents what I did and how I did it.
Before I did anything I had to decide whether I wanted to do a complete clean install of Windows 10 or simply delete the existing server software. In the end I decided to do a complete, clean install of Windows 10. Once that was decided I made a complete backup of all the files I would want afterwards - the configuration files, user files, the website files - everything.
I would much rather have the physical media, but most people do not now get that when they purchase a Windows 10 machine anymore. That meant using the Microsoft Windows 10 Media Creation Tool to create a bootable USB drive. Once I'd downloaded the files, it was time to upgrade the computer hardware a little.
The "Server in the Cellar," the Dell Inspiron 3847 during the RAM and SSD upgrade on December 26, 2019
The computer BIOS was already set to boot from a USB device first and the installation went surprisingly well. It took less than an hour to download the files and install them on my new SSD. I then uninstalled everything I could from the fresh install.
Apache does not provide the compiled server files for Windows, but it does give a list of where you can get them from. The last time I installed the server I used WAMPServer, but this time I decided to go with just the Apache files and got them from Apache Haus. I got the VC14 version with LibreSSL. I also had to download the 32bit version of the Microsoft Visual C++ 2015 Redistributable.
The installation was quick and seemed successful. All I had to do then was start the server using a command prompt and typing:
httpd -k start
The installation was tested by typing http://127.0.0.1 or http://localhost into a browser window and up popped the default Apache Haus screen. This is always nice to see because it means Apache is installed properly and the service is running.
The Apache Haus default screen
All that needed to be done now was to put the web site files in the directory or directories they should be. Depending on your operating system and version of Apache that should be in a directory called htdocs or www, but it can be anywhere on your computer that Apache has access to.
As stated in the Apache configuration file, httpd.conf - "Do NOT simply read the instructions in here without understanding what they do. They're here only as hints or reminders. If you are unsure consult the online docs. You have been warned." They mean it. Changing the configuration files without knowing what the result will be can stop the server running or compromise it.
I keep copies of the original configuration files and create a new copy before I edit the current ones. It is important to remember that the HTTPD service must be restarted before any changes to the configuration files take effect.
httpd -k restart
There a couple of reasons to edit the server configuration files:
- To make it do what you need done
- To keep it secure
- To remove unwanted directives
Here's what I changed or added to the main configuration file, httpd.conf. They are listed in the order the directives are found in the file.
ServerAdmin - Added my own email address. This is the address that gets added to any server messages the visitor sees.
ServerName - Changed to my own servername and the port the server uses to identify itself. I changed it to ServerName www.brisray.com:80
Options - To make site-wide changes easily almost HTML page on my site uses at least one include. To make sure the server processes them the following line was added Options +Includes
DirectoryIndex - When a visitor requests a directory and not a specific file the server needs to know what file(s) to give them. Most of my HTML files end it .htm and not .html so index.htm is to be looked for, then index.html. The line DirectoryIndex index.htm index.html was added.
AddType - This maps a file type to a MIME type. I added AddType text/html .shtml .htm .html so that all three file types are mapped to the MIME type text with the subtype HTML.
AddOutputFilter - This tells Apache to process files before they are output. Several lines were added to my httpd.conf file:
AddOutputFilter INCLUDES .shtml .htm .html
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
The first line was to ensure that all .shtml .htm and .html are checked for server-side includes (SSIs) and to process those.
Getting the server to gzip the files takes a little bit of time, but that is more than made up for by sending files that are a lot smaller than the originals. All browsers support gzip decompression so there are no compatibility problems. I found that files I send are now between a third and two thirds smaller than they were. There are lots of sites that can determine the gzip ratio for example the ones at GiftofSpeed and WhatsMyIP.
I run multiple websites from my server. These have registered domain names but Apache's virtual host configuration file can also handle multiple IP addresses and different sites on different ports.
Here's my virtual host entries for brisray.com and hmsgambia.org. These entries tell Apache which directories to use for each domain and where to put the log files. The first entry is a little bit special. The Virtual Hosts file is read from top to bottom and what I wanted to do was create a page for someone who used the server's IP address and not a domain name. For example they used one of the many utilities to find a domain name's IP address such as the ones at WhatIsMyIPAddress or Site24x7. What the unnamed default entry does is direct users to a different page so they can choose which site they want to enter.
ServerAlias brisray.com *.brisray.com
CustomLog logs/brisray.com-access.log combined
ServerAlias hmsgambia.org *.hmsgambia.org
CustomLog logs/hmsgambia-access.log combined
That's it, within 3 hours my web server was upgraded and reconfigured and my websites back online. Unfortunately, if you're starting from scratch the only person who can see your website is you. To understand what happens next you need some understanding of how the internet works.
The internet is just a giant collection of computers. In order to be able to contact each other they need some sort of address so whenever you join it your computer gets an IP (Internet Protocol) address.
When a computer or other device such as a router is connected to the internet it is given an IP address using DHCP (Dynamic Host Configuration Protocol). This is a 32 bit address written as four decimal numbers separated by periods and uniquely identifies that computer on the Internet. Examples of IP address are 184.108.40.206 and 127.123.23.45. Your ISP (Internet Service Provider) owns a block of IP addresses. When you sign onto the Internet your ISP assigns you one of the numbers from the block. When you sign back off, the number is free to be assigned to someone else. These are dynamic IP addresses. Using a dial-up modem means apart from the slow speed, that these numbers change frequently and so isn't recommended for setting up a web server. DSL and other "always on" connections aren't too bad as the IP addresses only change when the computer is completely logged off.
A static IP address is one where the machine keeps the same IP number all the time. Some ISPs can arrange for you to have a static IP address. A domain name such as mine, brisray.com, is just for our convenience. Computers generally do not use them, all they are interested in is the IP addresses. When you type brisray.com into the browser a message is passed to a DNS (Domain Name System) server and that resolves the domain name into the IP address of the computer that owns that name. GoDaddy has a free forwarding service, this means that when the IP address changes you can edit the forwarding address and this new address is sent to the DNS servers. It can take up to 72 hours for the IP address to be propagated throughout the Internet, but I usually find it's done in a couple of hours.
Your computer is probably not connected directly to the internet, instead it probably uses a router to connect. Your router gets the IP address from the ISP to connect to the internet. Meanwhile your router probably issues it's own set of IP addresses to your computers. Think of it as your router acting as a mini-ISP issuing IP addresses to your side of it, with the router itself having both an internal IP number so you can connect to it. The router gets its external IP number from your ISP so it can connect to the internet.
Like your ISP, whenever you disconnect from the router, whenever you join it again it goes through the list of available IP addresses it has and issues you a new one.
There are different protocols for different types of server. Computers have ports, 65,535 of them. The ports are simply gateways to application processes to ensure the packets of information from the protocols are processed correctly. The first 1,023 are ports reserved for use with well known and commonly used protocols. Because of what they do, these first 1,023 ports are designated as "well-known ports."
The ones that deliver web pages are HTTP (HyperText Transfer Protocol, port 80) and HHTPS (HyperText Transfer Protocol Secure, port 443). Others are FTP (File Transfer Protocol, ports 20 and 21), SSH (Secure Shell, port 22), DHCP (Dynamic Host Configuration Protocol, ports 67 and 68), SMTP (Simple Mail Transfer Protocol, email, port 25). There's loads of them, for a full list see Wikipedia.
To put it all together. When someone types a website address into their browser a packet of information is put together by their computer. It contains all sorts of information but the important parts for us is that it contains the address it's from, where it's going and the protocol used. That is sent through your router and out into the internet. It goes to DNS servers to look up the protocol and receiving computer which translates the receiving address to it's IP address. The packet is delivered and the receiving computer sends back a reply. That goes back through your router and that forwards it to the computer that sent the original.
How it all works is complicated and put together by some very clever people, but you need to know a little about DNS, IP addresses, protocols and ports to make your home server work properly.
Server Static IP Address
When someone requests a page from your website your router has to pass the information packet to your server. To do that your server is going to need a static IP address. That is, one that does not change so the router always knows where to send it. To do this you need to know what IP address range your router is capable of issuing. To do that you are going to need access to your router. Even if your ISP gave you your router, they should have also given you a user name and password to get into it.
Tip: If they give you a default username and password change it now if you haven't already done so. This applies to anything that has default usernames and passwords - your Siri, Alexa, maybe your internet connected doorbell or even your fridge. These defaults are very well known and very easy to lookup.
Tip: If at all possible use cable to connect to the router not wifi. Cable is still much faster than wifi and when serving web pages, speed is important.
Modern routers have lots of pages of information but what you're looking for is the one that shows the DHCP information. My router showed it can issue IP addresses in the range 192.168.0.2 to 192.168.0.253. The router itself having the internal IP address of 192.168.0.1.
I've found it's usually best to give your server the IP address at the beginning or end of the router's range so it can be told not to try and issue it to any other computer or device connected to it. While you're in the router lookup what DNS servers it uses and the Subnet Mask - you will need these addresses.
Router general information page
Showing DHCP IP address range and DNS servers
There are several ways of looking up your server's current IP address. I prefer just using the command line and using ipconfig or ipconfig /all which shows a lot more information. There's several other ways of looking up this information, FAQForge and Windows Central show these. It is these settings that need to be changed.
As usual, there are several methods to edit the information, TroubleShooter shows several of them. What you need to do is open the Network Adapter settings.. In Windows 10, type ncpa.cpl into Windows taskbar search. This brings up the computers network adapters. Right click on the adapter you want to change and choose "Properties". In the box that appears scroll down to "Internet Protocol Version 4 (TCP/IPv4)" Click on "Properties."
Computer network adapter settings
Once into this last screen click on "Use the following IP address." You will find that the "Obtain DNS server address automatically" also becomes greyed out and is changed to "Use the following DNS server address:" becomes active. Change the first set of settings to what you determined earlier.
You can use whatever DNS servers you like, you do not have to use the ones decided on by your ISP. Lifewire and TwitGoo both give lists of good, fast DNS servers. In the following screenshot, I have used Google's DNS servers.
Updated computer network adapter settings
Click "OK" and the computer now has a static IP address. Now you have to configure the router..
Configuring the Router
Now you have to configure the router not to try and use the IP address used to set the static one on the server and to open up the server to the outside world.
Log back into the router and find the DHCP page. Limit the DHCP addresses to not include the one that is now assigned to the server. This is why we chose one at the beginning or end of the address series. The page should show which connected computers/devices has a static IP address set.
Router DHCP configuration page
Now find the "Port Forwarding" or plain "Forwarding" page. What needs to happen is that all incoming requests on Port 80, the normal web page port address, are forwarded to your server which is why it was given a static IP address. If that was not done, then every time the computer gets a new IP address from the router this entry would have to be updated.
Router port forwarding page
Once this done by entering your external IP address other people should now be able to type that into their browser and they should be directed to your server. Most providers say it can take up to 24hrs for the address to be widely available but I've found it rarely takes more than a couple of minutes.
The main router information page should say what your external or internet IP address is, but you can always use an online service such as WhatIsMyIPAddress or IPLocation to find it.
Normally what would happen is that when you get a domain name, you set up the DNS records to point to whereever you host the website to, either using the IP address or using the actual URL. You cannot just do that on a domestic ISP account because none of them, as far as I know, offer a static IP address unless you pay more or upgrade to a business account. Some keep the IP address they assign you for a long time, weeks or months, but eventually it will change and you will need to update the domain name records.
Router DDNS setup page
Some ISP's routers automatically update your IP address with a Dynamic DNS service but you are limited by their choices and some may not be free. Mine for example lets me choose between DynDNS or No-IP. I used DynDNS when I first set up my first home server in June 2003 but in 2011 they started downgrading their service and in April 2014 they shut down the free service altogether.
There are several free DDNS choices. Since 2011, I have been using DNSExit.
I buy my domain names from GoDaddy and when I was using a commercial but free host would point the DNS records to the URL of the site using GoDaddy's name servers. When I started using a DDNS service I had to change the name servers to theirs and then edit the DNS records on those. There's only a few things to know about DNS records.
- A Record - This maps the domain name to an IP address
- MX Record - Maps another name such as WWW to the A Record so people can use either the plain domain name or one with www in front of it.
DNSExit and other DDNS services give you a small program that is installed on the server that checks the external IP address every couple of minutes. If it finds it has changed it sends the information to DNSExit who automatically update the A Record.
DNSExit DNS record
When your computer goes to sleep then your server is going to stop running. The easiest way to stop the computer going to sleep is to go to the Power & Sleep settings in Windows settings (Settings > System > Power & sleep).
Windows 10 power settings
Clicking on "Additional power settings" allows you to choose the "High performance" settings, which turns off the screen after 15 minutes (I changed it to 10), but never puts the computer to sleep.
Windows 10 advanced power options
There is something called Wake on LAN (WOL) which allows you to wake a computer up from sleep mode remotely. The problem is that there is nothing that works easily with an HTTP request (that I know of). Besides, it still takes several seconds for a computer to come out of sleep mode to fully working. So it seems unfeasible to use WOL with a web server.
That is it. A couple of hours from start to finish and Windows 10 and Apache was completely reinstalled and my websites back up and running. There is still some tweaking to be done, mainly optimizing Windows, Apache and the web pages for speed and security.
This page created December 28, 2019; last modified December 31, 2019