You can use Mac OS X to host a website for the Internet or for a local intranet because the web server software you need is already built in to Mac OS X. Serving a website to the Internet is a fairly complex task, and there are many nuances you need to consider. However, serving a website to a local network is fairly straightforward. In either case, you can use Mac OS X to get your site online. Mac OS X includes very powerful and sophisticated web server softwareApache. This software is widely used across the Internet to serve web pages, and Mac OS X users can take full advantage of it out of the box. Although Apache is a Unix application, you can perform the basic tasks of serving a website without messing around with text commands. Of course, to really customize and master Apache, you do need to get your hands into the command line. However, you can get a site up and running without ever interacting directly with Apache. Establishing and maintaining a web server is a complex and challenging task, and explaining all the details associated with hosting a website is beyond the scope of this book. The general process for using your Mac to host a website is the following:
Each user account on your Mac can serve its own website; this means you can serve many websites from your Mac at the same time. To provide a website for a user's account, you place the files for that site in the Sites folder that is contained in that user's Home directory. There is also an overall website for the Mac itself. You should ensure that you add a website for the Mac so that when people move to the home page for your machine, they will see a meaningful site. To start serving a website from your Mac, perform the following steps:
If you see the site, everything is in great shape and your pages are "available." TIP The concept that each user who has an account on your Mac can have a unique website opens many possibilities for you. You can create user accounts for the sole purpose of providing specific websites. For example, if I wanted to host a website for this book, I could create a user account called SEUsing MacOSX with the short name usingosx. I could then place the website in the Sites folder for this account and the site would be published. If you are going to be hosting any web pages on your Mac, you should also configure the root-level website for your Mac. This site will appear if someone accesses the website on your Mac without including a specific user's account in the URL. For example, if someone enters only http://12.34.567.89/, he would see the root-level web page. TIP Consider creating a web page that provides URL links to all the websites that are hosted on your Mac and posting that at the root level. This would make it easy for a visitor to get to any of the sites on your machine. If you open the directory located at Mac OS X/Library/WebServer/Documents/, where Mac OS X is the name of your Mac OS X startup volume, you will see many index pages. Each of these has an abbreviation for the language for which that page is applicable at the end of its filename (for example, the file index.html.en is the English version of the page). The version that Apache serves depends on how your machine is configured. To post a root-level web page, do the following:
NOTE The web server continues to run as long as your Mac is turned on and the website for each user account is served continuously, even if no one is logged in to the system. You can stop the server by shutting down the Mac or by turning off web sharing using the Sharing pane of the System Preferences application. The information in this section has barely scratched the surface of Apache specifically and web serving in general. However, a great deal of information on both topics is available within Mac OS X as well as on the Net. To access the Apache documentation included with Mac OS X, open the manual alias in the Documents folder (contained in the WebServer folder). The Apache folder will open. Open the index.html file and the Apache User Guide will open. To find information on the Web about Apache, visit www.apache.org. There is plenty of information on this site, including some nice tutorials. |