Hosting Your Own Web Site


Ever wanted to host your own Web site? All you need, other than a network or Internet connection, is Web server software and some Web pages. Mac OS X includes the Apache Web server, which is in use at many commercial sites hosting large, active sites. This industrial-strength Web server is easy to set up thanks to Mac OS X’s Web sharing feature. It gets your Web site on the Internet or your local network in about a minute. (No, this does not include the time it takes to actually create your Web pages!)

Although you could use Web sharing to host a large Web site, you probably wouldn’t want to. Web sharing is best suited to hosting a personal Web site. Your Web site is as sturdy as large Web sites, thanks to the Apache server software and Mac OS X’s Unix core. System resources, not reliability, are the limiting factor. Unlike administrators of large Web sites, you probably don’t want to dedicate your computer to hosting a Web site. Most likely, you want to host some Web pages for other’s use or convenience, or perhaps you would like to have access to some pages on your computer from any location, be it home, work, or elsewhere. However, this being your personal computer, you will probably use other applications at the same time. If you use Web sharing to host a large, busy Web site, you’ll probably find that your computer is not responsive enough when you use other applications at the same time. Web sharing is ideally suited for distributing information to coworkers on a local network or to family and friends on the Internet.

If you want to host a Web site on the Internet, your computer needs a continuous, high-capacity Internet connection. A DSL or cable modem connection should be adequate for a personal Web site. However, many DSL and cable modem connections upload files (send to the Internet) much slower than they download files (receive from the Internet). For example, your computer may download files at over 140KB per second but only be permitted to upload at less than 14KB per second. If this is the case with your connection, then visitors to your Web site will receive Web pages from your computer at the slower upload rate. Nevertheless, DSL and cable modem connections are much faster than a modem connection. You don’t want to frustrate your Web site visitors with spotty, slow service via a modem connection.

Starting Web sharing

You can get a Web site set up on your local network or your Internet connection in a minute or less. Simply open System Preferences and choose View Sharing (or click the Sharing button). Click the Services tab, and then click the Start button that is below the words Web Sharing Off. Web sharing takes a few seconds to start up. Then the Start button becomes a Stop button and the text above it reads Personal Web Sharing On. Clicking the Stop button turns off Web sharing. Figure 16-2 shows the Sharing preference pane with Web sharing ready to be turned on.

click to expand
Figure 16-2: Start Web sharing in the Sharing pane of System Preferences.

If the Sharing preference pane settings are locked, you must unlock them before you can start Web sharing. When the settings are locked, they are dim and the lock button at the bottom of the window looks locked. To unlock the settings, click the lock button and enter an administrator’s user account name and password in the dialog that appears.

Loading Web site files

Turning on Web sharing in the Sharing preference pane gets a Web site on the air, but it’s not your Web site until you put your site’s files into the right folder. In the meantime, you have an introductory site supplied with Mac OS X, as shown in Figure 16-3.

click to expand
Figure 16-3: Visitors to your personal Web site see a provisional home page until you place your Web site’s files in your home folder’s Sites folder.

Loading a personal Web site

You can put files for a Web site in two places. Files for a personal Web site should go in the Sites folder in your home folder, where other users of your computer can’t change them. Naturally, other users of your computer can create their own personal Web sites, and you can’t change them. Each user’s personal Web site has a unique URL.

Loading the common Web site

Files for a joint Web site that all users of your computer can change go in the Documents folder in the WebServer folder in the main Library folder; the path is /Library/WebServer/ Documents/. This folder initially contains a provisional home page in several languages. Each language has a separate HTML file. These files all have names beginning with index.html and ending with a suffix that indicates the language. For example, index.html.en is the English version and index.html.es is the Spanish (Espa ol) version. You can make any of these HTML files the provisional home page for your Web site by removing the language-designation suffix so that the file name is just index.html. (You do not need to rename the index.html.en file because the Mac OS X Apache Web server automatically uses it if no files are named index.html.) Figure 16-4 shows the joint Web site’s provisional home page in English.

click to expand
Figure 16-4: Visitors to your computer’s common Web site see another provisional Web page until someone using your computer puts Web site files in the /Library/WebServer/Documents/ folder.

Tip

If you have no other use for your computer’s common Web site, make it an index to your computer’s personal Web sites. This index can be a simple Web page containing a list of links to the personal Web sites. For example, if users Ender and Laz both have personal Web sites, the index page would have a link to /~ender/ and another link to /~laz/.

start sidebar
Designing and Creating a Web Site

Designing a Web site and creating all the files that go into it can be a lot of work. If your needs are simple, you may be able to produce a satisfactory Web site with a word processing application. For example, recent versions of Microsoft Word and AppleWorks can convert a word processing document to an HTML file. Word or AppleWorks word processing documents can include formatted text, tables, graphics, and links to places in the same document or to other documents. If the original word processing document includes graphics, the graphics are converted to separate image files. You must put the image files together with the HTML file in your Sites folder or the /Library/WebServer/Documents/ folder.

Both Microsoft Word and AppleWorks convert simple documents more accurately than complex documents. You can experiment to see whether your word processing application can generate Web site files that meet your needs.

Of course if you have experience with HTML authoring, you’ll be comfortable using TextEdit to create raw html files, or you can use either Adobe’s GoLive or Macromedia’s Dreamweaver for a more WYSIWYG approach to authoring.

end sidebar

Setting up a file listing

Instead of displaying a home page, your Web site can display a list of the files in your Sites folder or in the Documents folder of the WebServer folder (path Library/WebServer/ Documents/). To make this happen, simply remove the file named index.html or index.html.en from the folder. If the folder doesn’t contain a file by either of these names, the Mac OS X Web server creates a Web page that is a list of the folder’s contents, as shown in Figure 16-5.

click to expand
Figure 16-5: If your Web site folder has no home page, visitors see a listing of the folder’s contents.

Visiting your Web site

People visit your personal Web site (the one in your Sites folder) at an Internet address (URL) like one of these:

  • http://192.168.0.1/~craigz/

  • http://mycomputer.mydomain.com/~craigz/

Substitute your computer’s IP address or name, and substitute the short name of your user account at the end of the Internet address. Be sure to include the ending slash (/) or Apache will not know exactly which file to deliver, and an error message will be displayed. Notice that neither of these Internet addresses has a www prefix. Your Web site’s Internet address doesn’t include the www prefix unless it is part of the name you have obtained for your computer as described at the beginning of this Chapter.

The joint Web site (the one with files in Library/WebServer/Documents/) has an Internet address like one of these:

  • http://192.168.0.1

  • http://mycomputer.mydomain.com

Substitute your computer’s IP address or name. Here again, your Web site’s Internet address doesn’t include the www prefix unless it is part of the name you have obtained for your computer.

Tip

If your computer has only an IP address, put a note on your home page advising people who connect to add a bookmark for your page so that they don’t have to remember and retype the IP address to visit again.




Mac OS X Bible, Panther Edition
Mac OS X Bible, Panther Edition
ISBN: 0764543997
EAN: 2147483647
Year: 2003
Pages: 290

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net