Posts Tagged ‘mod_wsgi’

[Tutorial] install Apache + MySQL + Python on Mac OS

Friday, June 27th, 2014

OS version: Mac OS X 10.8.5
last revision: 2014-06-27
here are the instructions:

# download & install XAMPP (you only can get 64-bit version for mac)

# install python 2.7.x (choose 64-bit, Because the Apache in XAMPP is 64-bit version)
(why not python 3.x? don’t ask me, google the question by yourself.)

# check python bit-version (run the following script in Python)
import struct; print( 8 * struct.calcsize("P"))
(should print out ‘64′)

# check python version (run the following script in Python)
import sys; print (sys.version)
(print out ‘2.7.7′ in this moment)

# download mod_wsgi (a bride for Apache and Python)

# install mod_wsgi
make distclean
./configure –with-apxs=/Applications/XAMPP/xamppfiles/bin/apxs –with-python=/Library/Frameworks/Python.framework/Versions/2.7/bin/python
(this is import! if you don’t add those parameters, mod_wsgi might reference wrong python location – the default python installed by Mac)
sudo make install

# add load wsgi module script in Apache configuration (httpd.conf)
LoadModule wsgi_module modules/

that’s all
then you can launch Apache & MySQL in XAMPP now.

good luck! ;-)

[IMPORT!!] the Apache bit-version must be matched with the Python bit-version, or you will get error while Apache trying to launch. They must be both 64-bit version or both 32-bit version.