Setting up a webserver

Setting up a webserver on the Mac OS X platform is very straightforward.

Quick and Dirty Setup

Accessing your webserver

To access the pages you are hosting from within the same computer, type "http://127.0.0.1/" or "http://localhost/" as the URL in a web browser. To access the pages you are hosting from a computer on a local network, type "http://nameofcomputer/" where " nameofcomputer" is the name of the computer that is hosting the website. To access the pages you are hosting from a different computer on the internet, you need to make sure that the computer hosting the website is connected to the internet. It also helps if the computer has a static ip. If not, there are ways to deal with this (called dynamic DNS), but you will have to look elsewhere for how to do that. If the computer hosting the website has a static ip address, you can access the webpage from other computers connected to the internet by typing "http://youripaddress/" where " youripaddress" is your ip address. Even better, you can assign a domain name (such as www.mycoolsite.com) to point to your ip address. Then you would simply type "http://www.mycoolsite.com" and you will be in business.

Hosting a website from a user account

The description above tells you how to host a single main website from your computer. Mac OS X also allows each user on the computer to have their own website separate from the main website of the computer. In the home folder of any user, you can slip html, image, php, and other files into the Sites folder. To access these files you can follow the accessing rules above except you will add "~username/" after the main URL address where "username" is the particular username of the user in question. So you could access the website of the user "joe" on the same computer by typing " http://127.0.0.1/~joe/" or "http://localhost/~joe/". This applies also to accessing the website from a computer on the local network or from the internet as well. You just add the "~joe/" (in this case) to the end of the main website URL to access the website "joe" is hosting.

More advanced settings

Some users want to tweak the way that the Apache webserver hosts the website. Perhaps they want to change the main webserver to look in a different directory than the /Library/Webserver/Documents directory. Or perhaps they wish to enable php. For these more advanced needs, you need to modify Apache's configuration file which is located at /etc/httpd/httpd.conf. You need root access to change this file, so many people access it through the Terminal.