I’ve hosted websites in my home for a long time. I started back in the mid 90’s when I was a partner at FiestaNet (now ViaWest). First I was on dialup with a static IP, then ISDN, and finally DSL. The nice thing was that up until 2001, although I had to pay for the connectivity, my bandwidth was free.
Since FiestaNet was an all Microsoft shop, I started with IIS 1.0 on Windows NT 3.51. Basically, it could host static pages. Since no one ever went to my site (www.visible-spectrum.com), it didn’t matter all that much.
Over time I moved through every version of IIS. 2.0 came with NT 4.0. Then the upgrade to IIS 3.0 followed, finally replaced by 4.0 in the NT Option Pack. Windows 2000 brought is IIS 5, 2003 IIS 6, 2008 IIS 7, and finally Windows Server 2008 R2 and IIS 7.5. I put my web server first behind Proxy 2, then ISA 2000, 2004, and 2006. The latest version, Threat Management Gateway 2010 protects my home network even now.
This kept up through many employers, several homes, and a few cities. I always upgraded a little ahead of whatever company I happened to be working at the time. That way I could have some hands on experience before using new versions in production at the workplace. It was a great way to have a lab that I couldn’t neglect or let fall out of “fully functional”.
This finally came to an end in late Summer of 2010. We were selling our home in Germantown, Tennessee, and did not yet have a new home lined up in Phoenix. My wife and children came out ahead of me to a rental home, and I followed once all the various tasks involved with selling the house were complete. Since my servers had no connectivity (or even a home) for nearly 3 months, it was time to move my sites to a hosting provider – in this case GoDaddy.
My sites have been with GoDaddy for about 17 months now, while first we bought a home, remodeled it, moved in, and eventually got around to such tasks as setting up the server room. Now my sites could have a place to live again, but I have not yet purchased a static IP, so for now the sites are still at GoDaddy. I’m torn between having to maintain uptime at home (since CenturyLink’s connection seems fairly unreliable) and the fact that AreMySitesUp reports downtime from GoDaddy at least once a day (as I’m sure they are fairly oversubscribed in the servers that provide the dirt cheap hosting package I purchased).
Since I don’t have a static IP, I can’t easily remote into home to get any files when I need them. (Yes, I could use DynDNS or something like it, but I hate spending money). That also means I can’t use my home web server for development if I am not actually at home.
If only there were a way to work on my sites at home in a dev environment and still have them available to me to play with when I am not at home. Oh wait, there is. Dropbox. (Please sign up and get me more free storage!)
So, my sites are on my IIS web server at home, with the WEBDEV folder shared into my Dropbox account. That means those files are also available on my MacBook Pro all the time, with real time updates no matter which device I make a modification on. The sites are hosted on IIS to internal users at home. Now I just need to be able to serve them locally from the MacBook when I’m not at home. Sounds easy, right?
OK, let’s use my http://www.joking.net site as the example. When I am at home, and I go to http://www.joking.net, I go to the public site GoDaddy. If I go to http://www.joking.dev, I to to my internal IIS server. That works for any device on my LAN. If I leave my LAN, and go to http://www.joking.dev, I get a “server not found” error and I am sad. That is because the joking.dev zone lives on my home DNS server, but nowhere else.
First, I need to make http://www.joking.dev resolve from my MacBook Pro, even when I am not on my LAN. That’s pretty easy, I just need to add http://www.joking.dev to my HOSTS file and have it point to 127.0.0.1. Since my virtual machines all use bridged connections, when I am at home I can use Windows 7 to see http://www.joking.dev on IIS, and OSX to see http://www.joking.dev on the local instance of Apache on the MBP.
I’m running OS X 10.6.8 Snow Leopard, so I have a couple of options.
I can open a terminal window, and type
sudo nano /private/etc/hosts
enter my root password
and I get the hosts file, which I can edit.
If you prefer to use the finder, use the go to folder function, go to /private/etc and open HOSTS. I recommend TextWrangler as the editor if you’re going to go that route. I’m a big fan of Notepad++ in Windows, and TextWrangler is the closest thing to an OS X equivalent.
In this case I add
and save the file.
Now to actually set up the Apache webserver on the MPB.
Apache isn’t enabled by default, but it is very easy to enable. First, go to System Preferences::Sharing and check “Web Sharing”. Otherwise open a Terminal window and enter
sudo apachectl start.
If you go through the Terminal you will again be asked to enter the root password. At this point if you open
in a browser you should see the text “It works!”.
The directory you are seeing when browsing http://localhost is:
In my case my user files are available at http://localhost/~josephking/ and that directory is located at:
which is fine, but not where my web site files are.
All of my website files reside at paths like:
Where WEBDEV is a directory synchronized from my Windows server.
Since I don’t want to move WEBDEV to be under /Sites/ and I don’t want to change the default pathing in Apache, I create a symbolic link in Sites to WEBDEV by opening a terminal and typing:
ln -s /Users/josephking/Dropbox/WEBDEV /User/josephking/Sites
which creates the link, and if I go to the Sites directory in the Finder, I see the link to WEBDEV.
If I go to http://localhost/~josephking/WEBDEV/ however, I get the following:
You don’t have permission to access /~josephking/WEBDEV/ on this server.
Which is because Apache needs permission to not only WEBDEV, but the entire chain all the way to WEBDEV from the root, and also because Apache needs to be configured to follow symbolic links.
I need to enter the following in a terminal window:
chmod 755 /Users/ chmod 755 /Users/josephking/ chmod 755 /Users/josephking/Dropbox/ chmod 755 /Users/josephking/Dropbox/WEBDEV/
which then lets Apache actually get to where I want it to go.
Next, to allow symbolic links:
I edit my username config file for Apache at:
by making it look like the following:
<Directory "/Users/josephking/Sites/"> Options +Indexes +MultiViews +Includes +FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> <Directory "/Users/josephking/Dropbox/WEBDEV/"> Options +Indexes +MultiViews +Includes +FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory>
I then save the file and restart apache by opening a Terminal window and typing:
sudo apachectl restart
and now I can see all of my site documents listed at
How 1995 of us! Look at that URL!
Almost there, just a few changes.
First, I want to go to that directory using http://www.joking.dev/
I go into httpd.conf at /private/etc/apache2/ and I remove the # in front of :
I then edit httpd-vhosts.conf at /private/etc/apache2/extra/ by adding:
<VirtualHost *:80> ServerAdmin email@example.com DocumentRoot "/Users/josephking/Dropbox/WEBDEV/joking.net/www" ServerName www.joking.dev ServerAlias joking.dev # ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log" # CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common </VirtualHost>
I actually added a lot of these, one for each site I have set up in the HOSTS file, but you get the idea.
Last, I go back to httpd.conf for a couple quick tweaks:
<IfModule dir_module> DirectoryIndex index.html index.htm index.shtml index.php default.html default.htm default.shtml default.php </IfModule>
to list all my default documents
Remove the “#” in front of
LoadModule php5_module libexec/apache2/libphp5.so
LoadModule fastcgi_module libexec/apache2/mod_fastcgi.so
to enable PHP and CGI.
Restart Apache again, and voila!
I can get to http://www.joking.dev/ from my MacBook Pro on the local Apache server. If I had other machines who needed to see it, I could edit their hosts files or use DNS to point to my laptop as well.
Easy, right? Now everyone will want to sync IIS and Apache…