05.01.2013 Views

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

388<br />

CHAPTER 22 LEOPARD AS A WEB SERVER<br />

Open httpd.conf in your text editor of choice. I personally recommend using BBEdit, or its<br />

free equivalent, TextWrangler. With BBEdit, you can use the disk browser to easily navigate here,<br />

since it can see the hidden folders. It will also take care of overwriting the old file, which is readonly.<br />

That said, you can also use Nano, Emacs, or Vi, as detailed in Chapter 18.<br />

The configuration file is very long, but don’t be scared. Lines that start with the pound sign<br />

are comments, which is to say they are ignored. The file mainly consists of hints explaining what<br />

the various sections do. There’s very little actual content here, and even less you have to worry<br />

about.<br />

ServerRoot<br />

Much as UNIX considers ~ to be a shortcut for your user directory, the ServerRoot command tells<br />

Apache where it should look for any files that are not explicitly named. Since these files are all<br />

for its internal use, there’s really no need to change the default value.<br />

Listen<br />

Like any server process, Apache listens on a particular port or socket. Normally, it answers any<br />

incoming calls on port 80. If you need to change the port for some reason, or you want to bind<br />

to a specific IP address, you can edit this.<br />

One particular use for Listen is to limit who can see your page. Remember how I said you<br />

could load your page by one of several means? What if you don’t want people to be able to load<br />

your page elsewhere on the network? By binding Apache to 127.0.0.1:80, you will only be able<br />

to view the page locally. Dialing in to the actual IP address would simply return an error page.<br />

Another use for the Listen directive is to use a port other than the default. For example,<br />

your ISP may block access to port 80 in an effort to prevent you from running a web server from<br />

your home. You could instead bind to port 8080.<br />

You can bind to multiple ports and sockets by issuing multiple Listen directives. So, for<br />

example, to view the site locally on the standard port, but to let others only see it on a secret<br />

port, you could say this:<br />

Listen 127.0.0.1:80<br />

Listen 1984<br />

You could then load your site by simply pointing to 127.0.0.1, but someone else on the network<br />

loading your site would get an error unless they knew to append the correct port to the end<br />

of your IP address. So, for example, if your IP address were 10.0.0.1, they would have to point<br />

their browser to http://10.0.0.1:1984.<br />

Dynamic Shared Object (DSO) Support<br />

This is a fancy name for the LoadModule directive. Modules extend the functionality of Apache.<br />

There are several modules loaded by default. We will come back to LoadModule when we are<br />

ready to add PHP to our web server.<br />

User/Group<br />

Since Apache operates on your system, it needs to be able to access files. You could run it as root,<br />

but that would be a security risk. Instead, Apache runs as the user www as part of the group www.<br />

Should you want to change this, you would do that here. Honestly, though, you probably don’t<br />

need to.

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

Saved successfully!

Ooh no, something went wrong!