Enabling PHP at Leopard’s Apache Code Swarm
Jan 26

I’ve been trying to run python scripts using Apache for a long time but finally I could install mod_python into our Mac Mini.

You can download mod_python from Apache web page:

http://httpd.apache.org/modules/python-download.cgi

Uncompress the source code and execute the configure script.

./configure --with-apxs=/usr/sbin/apxs

 Then you have to patch the src/Makefile as follows:

  1. Add  -arch x86_64 -arch ppc -arch i386 at the end of LDFLAGS variable
  2. Add -arch x86_64 -arch ppc -arch i386 at the end of  CFLAGS variable
  3. Modify mod_python.so objective as follows:
    Add -Wc,”-arch x86_64″ -Wc,”-arch ppc” -Wc,”-arch i386″ after the -c
    In my situation: $(APXS) $(INCLUDES) -c -Wc,”-arch x86_64″ -Wc,”-arch ppc” -Wc,”-arch i386″ $(SRCS) $(LDFLAGS) $(LIBS)

Then you can compile and install this module:

make
sudo make install

In order to test that mod_python works you can add the following lines at httpd.conf

<Location /mpinfo>
  SetHandler mod_python
  PythonInterpreter main_interpreter
  PythonHandler mod_python.testhandler
</Location>

Access to http://localhost/mpinfo and get this report:

Python Info

Related Posts

5 Responses to “Compiling mod_python and installing into Leopard’s Apache”

  1. Graham Dumpleton Says:

    This is not everything that needs to be fixed for it work all to work properly. For example, PSP pages will break. Rather than patch it yourself, just use latest source code from subversion repository.

    svn co https://svn.apache.org/repos/asf/quetzalcoatl/mod_python/trunk mod_python-trunk

    It has all the required fixes, including some which are needed for newer Apache versions.

    Better still, if you are only wanting to run a WSGI capable application such as Django or Trac, then use mod_wsgi instead. Using mod_python is not a good long term option at this point in time.

  2. pigui Says:

    @Graham, thanks for your comment.

    I’m running a Trac, so probably I will install mod_wsgi

  3. wolffan Says:

    Path of httpd.conf is : /private/etc/apache2/httpd.conf

  4. wolffan Says:

    Before accessing localhost you need to add another line in httpd.conf:
    “LoadModule python_module libexec/apache2/mod_python.so”

    with the other loadmodule line’s.

    Then you need to activate “web sharing” from system preferences in Mac OS

  5. Barend Kobben Says:

    Great, finally found an instruction to get mod_python working on MAc OSX that Actually works. Thanks very much! WHy is this information not on the apcahe mod_python pages…? Anyone knwo who to contact for that…?

    Barend

Leave a Reply