05.01.2013 Views

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

If you’re developing web content, you probably want your local server setup to mirror your<br />

remote setup as closely as possible. Since ~username sites went out of fashion with Geocities, you<br />

probably want to use the document root.<br />

If you’re the only user on your computer, that’s certainly an option. However, writing personal<br />

project files to a directory with administrative privileges is potentially problematic, and<br />

/Library/WebServer/Documents is not exactly a convenient location to have to remember.<br />

There are a couple of options. The easiest method, which I recommend, is to simply create a<br />

symbolic link that points the expected document root to your local Sites directory.<br />

NOTE Symbolic links and shortcuts are similar in concept but very different in practice. Links<br />

are a UNIX file system construct, while shortcuts belong to the Finder. Using a shortcut to redirect<br />

your document root will not work.<br />

To redirect your document root using symbolic links, navigate to the /Library/WebServer<br />

directory. Move aside the original Documents folder. You could delete it, but simply renaming it to<br />

something like OldDocuments will do the trick.<br />

Launch the Terminal application from /Applications/Utilities, or, if you’re a true power<br />

user, from the Dock. Invoke the following command:<br />

sudo ln -s ~/Sites /Library/WebServer/Documents<br />

This means, using superuser privileges (sudo), create a link (ln) that is symbolic (-s) from my<br />

local Sites directory (~/Sites) at the path /Library/WebServer/Documents.<br />

Since you’re using sudo, this will prompt you for your password. After entering it, invoking<br />

ls on /Library/WebServer will show a file called Documents. In the Finder, it will appear to be a<br />

shortcut. Loading the root site in your browser of choice should show your personal home site.<br />

TIP Your browser may have the old page cached, so you might need to reload or even empty<br />

your cache to see the change.<br />

Configuring Apache<br />

CHAPTER 22 LEOPARD AS A WEB SERVER 387<br />

Since Apache is a UNIX application, it doesn’t have a convenient GUI preference pane, nor does<br />

it use a standard <strong>Mac</strong>intosh property list. Rather, it has its own configuration file in its own<br />

directory using its own peculiar scheme.<br />

Fortunately, the configuration file, like everything else about Apache, is well documented<br />

and, honestly, not that complicated. The default home pages all contain links to the Apache manual,<br />

as does the dire warning that begins the configuration file itself. You can always just go<br />

straight to Apache’s documentation home page: http://httpd.apache.org/docs/.<br />

NOTE The name of the Apache HTTP server has an interesting history. Originally, httpd was<br />

the NCSA HTTP Server, a project at the National Center for Supercomputing Applications.<br />

When its creator, Robert McCool, left NCSA, the project stalled. A group of developers continued<br />

working on patches for the NCSA code base, creating “a patchy” HTTP server in its<br />

stead.<br />

Apache’s configuration files live in the directory /private/etc/apache2. Unless you’ve turned<br />

on the ability to see invisible files in the Finder, you’ll have to navigate there in Terminal. Listing<br />

the contents of the directory shows the file we’ve come here to see: httpd.conf.<br />

NOTE Although it’s called Apache, the name of the UNIX executable is httpd, which reflects<br />

its role as a background process (daemon) that serves the Hypertext Transfer Protocol.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!