22.2. FTP

 <  Day Day Up  >  

22.1. Web Sharing

Using the Sharing panel of System Preferences, you can turn your Mac into a Web site (or server ), accessible from the Web browsers of people on your office network, the Internet at large, or both.

This feature assumes, of course, that you've already created some Web pages. For this purpose, you can use Web-design programs (Macromedia Dreamweaver, for example, or the free Netscape Composer) or the File Save as Web Page command of a program like Microsoft Word. Or you could let Mac OS X build Web pages for you using iPhoto or Image Capture.

After you provide your friends and co-workers with your Mac's Web site address, they can view your Web pages, graphics, and documents in their own Web browsers. And whenever you're online, your Web site is also available to anyone on the Internet ”but you don't have to pay a penny to a Web-hosting company.


Tip: Web sharing is also an easy and efficient way to share your Mac files with Windows PCs, either those on your office network or those on the Internet. No special software or translation is required, and posting your files on the Web page avoids all the usual complexities of sending files by email.

Don't mistake Mac OS X's Web Sharing feature, by the way, with the relatively feeble equivalent features in Mac OS 9 or Windows, which are designed to handle only a handful of visitors at a time (and can't handle anything fancy like CGI scripts). Inside Mac OS X is Apache , one of the strongest and most popular Unix Web server programs ”precisely the same one that drives 60 percent of the Internet's commercial Web sites.

UP TO SPEED
IP Addresses and You

Every computer connected to the Internet, even temporarily, has its own exclusive IP address (IP stands for Internet Protocol). What's yours? Open the Sharing pane of System Preferences to find out (see Figure 22-1). As you'll see, an IP address is always made up of four numbers separated by periods.

Some Macs with broadband Internet connections have a permanent, unchanging address called a fixed or static IP address. Clearly, life is simpler if you have a fixed IP address, because other computers will always know where to find you.

Most other Macs get assigned a new address each time they connect (a dynamic IP address). That's virtually always the case, for example, when you connect using a dial-up modem, or when your laptop discovers a new wireless network. (If you can't figure out whether your Mac has a static or fixed address, ask your Internet service provider.)

You might suppose that Mac fans with dynamic addresses can't use any of the remote-connection technologies described in this chapter. After all, your Mac's Web address changes every time you connect, making it impossible to provide a single, permanent address to your friends and co-workers.

The answer is a dynamic DNS service that gives your Mac a name, not a number. Whenever you're online, these free services automatically update the IP address associated with the name you've chosen (such as macmania.dyndns.org ), so that your friends and colleagues can memorize a single address for your machine.

To sign up for one of these services, just go to their Web sites ”www.dyndns.org, www.no-ip.com, and so on.

You'll also need to download and run a utility called an update client , which contacts your DNS service and keeps it up to date with your latest IP address, regularly and automatically. Check your DNS service's Web site for a list of compatible update clients .

Oce you've got a fixed DNS name associated with your Mac, you'll be able to access it from elsewhere (provided it's online at the time) via File Sharing (Chapter 13), the screen-sharing program called Timbuktu, the Web Sharing and FTP features described in this chapter, and so on.

(If you have a fixed address, you can also pay a few dollars a year to register your own domain name , a bona fide address like www.yournamehere.com . To register one ”or to find out if the name you want is taken ”visit a site like www.networksolutions.com.)


The bottom line: If you build it, they won't necessarily come. But you'll have the capacity to handle them if they do.

22.1.1. Firing Up Personal Web Sharing

Here's how you turn your Mac into a low-budget Web site:

  1. Put the HTML documents, graphics, and files you want to publish into your Home Sites folder .

    Everyone with an account on your Mac has a Sites folder, and therefore the Mac can actually serve up lots of Web sites at once.

    Your Web site's home page, by the way, won't appear unless it's named index.html . (Apple has already put an index.html document into your Sites folder, just to give you the idea; feel free to replace it.)

    Figure 22-1. Use the Sharing System Preferences pane to make designated folders on your hard drive available to anyone on the Internet. Note your Mac's IP address, which appears here in blue underlined type. It's the basis for all of the fun Mac-sharing-over-the-Internet features described in this chapter.


  2. Open System Preferences; click Sharing. Turn on the Personal Web Sharing checkbox (Figure 22-1) .

    You've just made the contents of your Web Pages folder available to anyone who connects to your Mac.


    Tip: Take this opportunity to turn on Mac OS X's firewall , too (Section 12.11). You wouldn't want Internet hoodlums to take advantage of your open Web connection.
  3. Note your IP address .

    In general, your Mac's Web address is based on its IP address (or Network Address). The Mac identifies this address for you at the bottom of the Sharing pane (see Figure 22-1).


    Tip: If you connect to the Internet via dial-up modem, you won't see an IP address here until you're online.
  4. Email your new Web address to your friends and co-workers .

    It might be, for example, http://111.222.3.44/~chris/ (the number is your IP address, and the name should be your short user name). Don't forget the final slash. Tell your friends to bookmark it so they won't have to remember this address, or use one of the DNS naming services described on Section 22.1.


Tip: That IP address with all the numbers is the one that people on the Internet need. If they have Mac OS X 10.2 or later, people on your local office network can use your Mac's Bonjour (Rendezvous) name to connect instead. (The Bonjour name appears at the top of the Sharing pane, as shown in Figure 22-1.)They could, for example, type http://office-mac.local/~chris into their Web browsers, where office-mac.local is your Mac's Bonjour name.

You've just put your folder-based Web page on the Internet for all to see ”that is, all who know your secret Web address. Maybe you'll want to distribute the address only to other people on your office network, using your tiny Web site as a distribution source for documents. Or maybe you'll want to go whole-hog, hosting an e-commerce Web site (read on).

22.1.2. The Mac's Own Web Site

The instructions above show you how to create a Web site in your Home Sites folder. In other words, they guide you through the process of creating a personal Web site.

But if you have an Administrator account (Chapter 12), you can also put your Web pages into the main hard drive window's Library WebServer Documents folder. This is your Mac's main Web site folder, and its address is simply http://111.222.3.44/ . That is, it's just your IP address, no user name needed. (Of course, if you have a DNS name for your Web server, you can use that, as well. And here again, if people will be connecting from across your office network rather than the Internet, they can replace the IP number with your Mac's Bonjour name.)

Working with this primary Web site folder is only slightly different from the personal ones described above. Because you're now working inside an official Mac OS X system folder, you must mind your permissions (Section 12.10). Using the File Get Info command, you should set up the permissions of any folders and documents inside the Library WebServer Documents folder (an Images folder, for example) like this:

  • Owner : Read & Write.

  • Group : Read & Write (or Read Only, if you don't want other administrators to have access).

  • Others : Read Only.

You've just ensured that your visitors will be allowed to see your Web documents ”and that random Internet hoodlums can't make any changes to them.

Figure 22-2. Here's a great way to make files available to other people on your network or collaborators across the Internet. Just put your files into the Sites or Library Web-Server Documents folder and make sure nothing is named index.html. The Parent Directory link takes you to the folder that contains this one ”if you've been given access to it, that is.


22.1.3. The Easiest Way to Distribute Files

Here's a handy secret: If there isn't a document whose name is index.html in your Sites folder (or Library WebServer Documents folder), then visitors see, in their browsers, a handy list of the files that are in that folder (see Figure 22-2).

This is a terrific convenience: It offers a quick, simple way for you to make a bunch of documents available for downloading. All your visitors have to do is click one of these file names . It downloads immediately, no matter what kind of computer your Web visitor is using.

22.1.4. Browser Navigation of Your Own Mac

Once you've turned on Web Sharing, you can navigate the folders of your own machine right from within a browser ”just use localhost as the "Web address."

To see what's in your own Sites folder, for example, type http://localhost/~chris/ (or whatever your short account name is) into your browser's address bar. Or to see what's in the Library WebServer Documents folder, http://localhost/ is all you need.


Tip: Actually, in any address that involves the word localhost (like the previous examples), you can leave out the word localhost to save a little typing. But keep all the slashes that surround it. For example, http: /// is enough to see the list of documents in your Mac's main Web-pages folder.
POWER USERS' CLINIC
CGI Scripts

A CGI script (Common Gateway Interface) is a program ”written in a language like Perl, AppleScript, or Python ”that runs right on your Web page. You've seen these on many a Web page: Web-visitor counters, interactive polls , shopping forms, and so on. Apple even includes a few of them with Mac OS X; they're in your System Library Perl [version number] CGI Scripts folder, for example.

If you've got a CGI script of your own that you'd like to incorporate into your Web page, copy it into your Library WebServer CGI folder. (This means you, administrators.) The script's Web address becomes http://111.222.3.44/cgi-bin/scriptname . (Substitute your actual IP address and the real name of the script file, of course.)

Unfortunately, you won't get far testing out your CGI script, because it comes with its "execute" permissions turned off . To turn them on again, you need to use the chmod (change mode) command.

You can use a permission-changing shareware program like SuperGetInfo, available from the "Missing CD" page of www.missingmanuals.com, or you can do the job in Terminal, as described on Section 17.1.4. (In this case, you'd type sudo chmod 755 test-cgi .)

The chmod command is a quick way to change access privileges ”including Execute permission, which isn't available in the File Get Info window.

The 755 business is a long story, which you can read at any Terminal prompt by typing man chmod and hitting Enter. In short, however, this code is shorthand for "Change the permissions so that everyone else can read and execute (but not make changes to) this file" ”just what you want for a CGI script.

After hitting Enter, you're ready to proceed. Now sudo asks for your administrator's password. Once you've entered it, press Enter; the deed is done. You can test your script either on the same Mac ( http://localhost/cgibin/test-cgi ) or on another one across the network or across the Internet ( http://111.222.3.44/cgi-bin/test-cgi ).


But why stop at HTML documents? You can see the contents of any folder on your Mac, just by typing its folder pathname. For example, to see what's in your Documents folder, type file:///Users/chris/Documents/ into your browser's Address bar. You get a tidy list like the one shown in Figure 22-2, revealing what's in that folder. Click a link to open it. (If you're using Safari, you open a Finder window revealing the folder's contents instead.)

22.1.5. More on Apache

As noted above, Apache is the most popular Web-serving software in the world. As you can well imagine, it's powerful, reliable ”and very technical. It is, after all, a Unix program.

You can read more at any of these sources:

  • The Apache manual . To open it up, type http://localhost/manual/ into your browser's address bar. You won't get far reading this thing if you haven't spent some time at a technical college, but at least you'll know what you're up against.

  • Apache: The Definitive Guide . A book from O'Reilly.

  • MacOSXHints .com .Dozens of Mac OS X fans have posted specific Apachetweaking tips and tricks at www.macosxhints.com.

Note, too, that $350 will buy you a graphic front end for the various Apache settings, in the form of Tenon's iTools program (no relation to Apple's old iTools service). It still requires an understanding of the technical aspects of Web hosting, but at least it spares you from having to type out Unix commands to make your changes.

 <  Day Day Up  >  


Mac OS X. The Missing Manual
Mac OS X Snow Leopard: The Missing Manual (Missing Manuals)
ISBN: 0596153287
EAN: 2147483647
Year: 2005
Pages: 506
Authors: David Pogue

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