Thursday, May 20, 2010

mod_python in apache on OS X with Homebrew

Recently had to install mod_python to test something for a customer. It needed some nudging, so including it here. Snow Leopard, Homebrew and default httpd.

clojure:apache2 jabley$ curl -v -o /dev/null http://localhost/
* About to connect() to localhost port 80 (#0)
* Trying ::1... connected
* Connected to localhost (::1) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3
> Host: localhost
> Accept: */*
>
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0< HTTP/1.1 200 OK
< Date: Thu, 20 May 2010 10:53:43 GMT
< Server: Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8l DAV/2
< Content-Location: index.html.en
< Vary: negotiate
< TCN: choice
< Last-Modified: Sat, 20 Nov 2004 20:16:24 GMT
< ETag: "130d9-2c-3e9564c23b600"
< Accept-Ranges: bytes
< Content-Length: 44
< Content-Type: text/html
< Content-Language: en
clojure:local(master) jabley$ brew install mod_python
==> Downloading http://www.ibiblio.org/pub/mirrors/apache/httpd/modpython/mod_python-3.3.1.tgz
######################################################################## 100.0%
==> Patching
patching file src/connobject.c
==> ./configure --prefix=/usr/local/Cellar/mod_python/3.3.1 --disable-debug --disable-dependency-tracking
==> make
==> make install
==> Caveats
* You must manually edit /etc/apache2/httpd.conf to load mod_python.so
==> Summary
/usr/local/Cellar/mod_python/3.3.1: 4 files, 176K, built in 22 seconds
clojure:local(master) jabley$ sudo ln -s /usr/local/Cellar/mod_python/3.3.1/libexec/mod_python.so /usr/libexec/apache2/mod_python.so
Password:
clojure:apache2 jabley$ sudo vi /etc/apache2/httpd.conf
...
LoadModule python_module libexec/apache2/mod_python.so
...
clojure:apache2 jabley$ sudo /usr/sbin/apachectl restart
clojure:apache2 jabley$ curl -v -o /dev/null http://localhost/
* About to connect() to localhost port 80 (#0)
* Trying ::1... connected
* Connected to localhost (::1) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3
> Host: localhost
> Accept: */*
>
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0< HTTP/1.1 200 OK
< Date: Thu, 20 May 2010 13:07:58 GMT
< Server: Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8l DAV/2 mod_python/3.3.1 Python/2.6.1
< Content-Location: index.html.en
< Vary: negotiate
< TCN: choice
< Last-Modified: Sat, 20 Nov 2004 20:16:24 GMT
< ETag: "130d9-2c-3e9564c23b600"
< Accept-Ranges: bytes
< Content-Length: 44
< Content-Type: text/html
< Content-Language: en
view raw gistfile1.sh hosted with ❤ by GitHub