Tutorial: Apache Web Server + Dynamic DNS in 5 mins
We all know OS X has many tricks up its sleeve, but the built-in Apache web server is often overlooked. With a bit of fiddling, you can make your Mac host its very own website in just a few clicks.
Apache is the most common web server used on OS X. It is the industry standard and is actually the most widely used web server software available. While the nuts and bolts of Apache are out of the scope of this article, I’ll show you how to quickly set up the server, as well as make it internet accessible with an easy to remember free domain name.
First, go to System Preferences and then click on Sharing. From here, you need to tick the ‘Personal Web Sharing’ check box. This starts up Apache.

The next step is to decide where to store the web files. Your best bet is to put files in /Library/WebServer/Documents. These files will show up in the top level of your web site. You can also put files in the Sites folder within your home folder.
Just for fun let’s drop to a command line by firing up terminal. Type:
httpd -v
You should see something like this:
Server version: Apache/1.3.33 (Darwin)
Server built: Aug 19 2006 07:55:18
So you can clearly see your version of Apache along with the date it was compiled and installed. Another important piece of information is to know where Apache stores its logs:
/var/log/httpd
If you have problems be sure to check the most recent error.log file for clues.
Apache has a plethora of useful configuration flags, which again is really outside of the scope of this quick guide. The Apache configuration file is at:
/etc/httpd/httpd.conf
The Apache configuration file is fully commented, but do yourself a favor and check out some literature on the configuration before messing around. O’Reilly has a decent guide for Mac users here.
Okay you’ve learned a tiny bit about Apache so lets copy a photo, movie, song or text file to the /Library/WebServer/Documents folder. Once you’ve done that, go to http://127.0.0.1/hello.mov (or whatever file you chose) in your browser. Did you see your file okay? Hooray! 127.0.0.1 is what’s called the “localhost” IP address. It will always redirect to your current computer without you having to know what your network IP is.
So now you can publish your site to this folder. For example, in iWeb, publish your site to a folder; then copy the contents of that folder to the appropriate web server folder, mentioned above. The key is that you must have the index.htm(l) file in that root directory. The same is applicable for all other publishing apps, or even basic html in a text editor.
So, if you’ve managed to get this far, you can go to http://127.0.0.1 (or http://127.0.0.1/~username) and you’ll see your page.
So now you can access your files anywhere on your local network. Simply visit your local IP address, which is shown on the Sharing Preference Pane when Personal Web Sharing is selected. You should see it in the white box, and you can simply click on it to test it, or bookmark it to make it easier to find.
So this is fine and dandy but if you can map your router so that incoming requests come to your Mac, then you can view your website from any internet connected computer in the world. Now that could be useful. This will usually work by logging into the configuration for your router, and using web forwarding to point port 80 to your Mac’s internal ip address. It’s different for all router brands but I bet if you do some Googling you’ll figure this step out.
Now simply go to your external IP (which you can find here) and you should see your web accessible Mac. Ensure that you are properly firewalled, because leaving ports open on the internet is a bad idea.
So what do you do if you are using an ISP that changes your IP dynamically or you want to have an easier to remember domain instead of an IP? There are some great dynamic DNS services out there, but the one I use is from no-ip.com. The service is free and they have a decent list of domains to choose from as well as provide a great simple to use client for Mac. Make an account at no-ip and under Hosts/Redirect > Manage you will need to create a Host name, and select a root domain to use. Be creative!

Now download and fire up the Mac client from no-ip. This is the program that tells no-ip what your IP is and keeps it updated. You will need to login with your no-ip username and password as well as set the client for an update interval. I use 1 hour for this but a better setting might 5 mins if your IP changes frequently.

If you are going to be operating like this a lot you also might want to enable Launch Deamon at System Startup under the Deamon tab so that np-ip launches at startup.
So that’s about it! Keep in mind there is lot more I could have said about Apache web server, its configuration, security and its other many facets but I will leave that for another article(s). For now, as long as the no-ip client, and Apache is running ok you should have a publicly accessible web server with an easy to remember domain name. This is a great way to quickly share files, do some web development, or simply be that much more l33ter than everyone else. Have fun!
*Editor: If you are looking for a full-on LAMP (Linix, Apache, MySQL, PHP) style development server check out our recent MAMP review.

You might need to learn how to get through your router / firewall if applicable. Another tutorial?
Well, every router is going to be different and all but the older models are usually going to be pretty straight forward. Something like:
Incoming port: 80 Forwards to machine: IP
[...] * Tutorial: Apache Web Server + Dynamic DNS in 5 mins http://macapper.com/2007/09/24/tutorial-apache-web-server-dynamic-dns-in-5-mins/ [...]
[...] an Apache server ready to go (just turn on Personal Web Sharing in the System Preferences and here’s a couple of articles about what to do next). Or, better, by downloading Mamp (opensource free love) [...]