February 19, 2012
As I state in the "about" box, this site is an experiment. It is as much for me to learn something as it is to share the things I've learned. From its inception my intent has been to publish a live site, but I needed to gain experience before going live, so I set up a local web server. This page details how I set up that server. If you want to set up your own experimental web server, read on. Your mileage may vary.
I use a mac so the web server is built in; it's only a matter of turning it on (system preferences/sharing/Web Sharing - check). That's all that is needed to have a place to experiment. I'm sure you can do the same thing on a Windows computer, but since switching in 2003 I haven't done much to keep up with the Windows OS so you'll need to do a little more googling.
I also wanted to experiment with PHP, which is a server side, web programming technology, so I needed to set up a PHP server as well. It turned out to be pretty easy to do that also. First, turn off the web server (system preferences/sharing/Web Sharing - uncheck), then open up terminal and edit the http daemon configuration file. Don't worry, it's only a matter of removing a hash (#) from the front of a line in the file. I used nano to edit the file so I didn't have to change permissions or move the file. Type this in the terminal:
Sudo is a command allowing you to temporarily do things as the super-user and requires that you type your password. After typing your user password, nano will open the httpd.conf for editing. There will be a screen full of commands and warnings about not messing with things you don't undertand. These warnings are important. Don't mess around with anything else in this file unless you know what you are doing, and you don't know what you're doing otherwise you wouldn't be reading this. Scan through the file and find a line that looks like this:
#LoadModule php5_module libexec/apache2/libphp5.so
Remove the hash at the front of the line. Save the file with control-o (^o) and then exit (^x). That's it! Switch on the web server and you will have a PHP-enabled web server running on your mac.
Ready to experiment? You will need, at the minimum, a file named "index.html" in your user web site folder (~/Sites --BTW, ~ is a shortcut to your user folder). If you don't have anything in ~/Sites, you can download webTemplate and extract it to your site folder. You can access your site by opening "localhost/~username" in your favorite web browser. Replace username with your short user name and don't type the quotes (e.g., http://localhost/~brian if your short user name is brian--like me). You should be rewarded with your page being displayed in your browser.
Continue with Setting Up A Website: Next Steps