16.01.2014 Views

Beginning Python - From Novice to Professional

Beginning Python - From Novice to Professional

Beginning Python - From Novice to Professional

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.

CHAPTER 15 ■ PYTHON AND THE WEB 329<br />

Installing<br />

Installing mod_python and getting it <strong>to</strong> work is, perhaps, a bit more difficult than doing so for<br />

many of the other packages I’ve discussed so far. If nothing else, you have <strong>to</strong> make it cooperate<br />

with Apache. So, if you plan <strong>to</strong> install mod_python yourself, you should either use some form<br />

of package manager system (which will install it au<strong>to</strong>matically) or make sure you know a bit<br />

about running and maintaining the Apache Web server. (You can find more information about<br />

Apache at http://httpd.apache.org.) If you’re lucky, of course, you may already have access <strong>to</strong><br />

a machine where mod_python is installed; if you’re uncertain, just try and see. (And then you<br />

could bug your ISP or administra<strong>to</strong>r <strong>to</strong> install it for you . . .)<br />

If you do want <strong>to</strong> install it yourself, you can get the information you need in the mod_python<br />

documentation, available online or for download at the mod_python Web site (http://<br />

modpython.org). You can probably also get some assistance on the mod_python mailing list<br />

(with subscription available from the same Web site). The process is slightly different depending<br />

on whether you use UNIX or Windows.<br />

Installing on UNIX<br />

Assuming you have already compiled your Apache Web server (version 2.0.40 or newer—or use<br />

an older version of mod_python) and you have the Apache source code available, here are the<br />

highlights of compiling and installing mod_python.<br />

First, download the mod_python source code. Unpack the archive and enter the direc<strong>to</strong>ry.<br />

Then, run the configure script of mod_python:<br />

$ ./configure --with-apxs=/usr/local/apache/bin/apxs<br />

(Modify the path <strong>to</strong> the apxs program if this is not where it is found; on my Gen<strong>to</strong>o system, for<br />

example, I would use /usr/sbin/apxs2. Or, rather, I would install mod_python au<strong>to</strong>matically<br />

with the Portage package system, but that’s beside the point.)<br />

Make a note of any useful messages, such as any messages about LoadModule.<br />

Once this configuration is done, compile everything:<br />

$ make<br />

Once everything has been compiled, install mod_python:<br />

$ make install<br />

Installing on Windows<br />

At the time of writing, the binary version of mod_python for Windows requires <strong>Python</strong> version 2.3.<br />

You cannot use version 2.4. Download the mod_python installer from http://www.apache.org/<br />

dist/httpd/modpython/win/ and double-click it. The installation is straightforward and will<br />

take you through the steps of finding your <strong>Python</strong> and Apache installations.<br />

You may get an error at the end of the process if you did not install Tcl/Tk with <strong>Python</strong>,<br />

though the installer tells you how <strong>to</strong> finish the install manually. To do this, copy<br />

mod_python_so.pyd from <strong>Python</strong>’s Lib\site-packages folder <strong>to</strong> the modules direc<strong>to</strong>ry under<br />

your Apache root folder.

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

Saved successfully!

Ooh no, something went wrong!