This work is licensed under a Attribution Share Alike Creative Commons license
Python Apache ExecCGI MySQLdb on OS X Leopard

sudo apachectl restart
just posting this so
1. you can see the headaches i go through for our work
2. hopefully others in the world can avoid those headaches
-----
Python Apache ExecCGI MySQLdb on OS X Leopard
view log
on Leopard
to see necessary information as you proceed
tail -f /var/log/apache2/error_log
first error
incorrect permissions
set permissions to at least 755 on your .py scripts
sudo chmod 755 blah.py
second error
[Thu Apr 23 01:18:26 2009] [error] [client ::1] Options ExecCGI is off in this directory
to fix ExecCGI on Leopard
/etc/apache2/httpd.conf
has this:
# User home directories Include /private/etc/apache2/extra/httpd-userdir.conf
and
/private/etc/apache2/extra/httpd-userdir.conf
points to
/private/etc/apache2/users
and includes this
Include /private/etc/apache2/users/*.conf
so
cd /private/etc/apache2/users sudo vi [yourusername].conf
and enable ExecCGI by fixing this
<Directory "/Users/paulbhartzog/Sites/">
Options ExecCGI Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>third error
you'll still get a messy error
when you try to use mysqldb to connect
Traceback (most recent call last):
File
import MySQLdb
File "build/bdist.macosx-10.5-i386/egg/MySQLdb/__init__.py"
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 835, in resource_filename
self, resource_name
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 1304, in get_resource_filename
self._extract_resource(manager, self._eager_to_zip(name))
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 1326, in _extract_resource
self.egg_name, self._parts(zip_path)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 915, in get_cache_path
self.extraction_error()
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 881, in extraction_error
raise err
pkg_resources.ExtractionError: Can't extract file(s) to egg cache
The following error occurred while trying to extract file(s) to the Python egg
cache:
[Errno 13] Permission denied: '/Library/WebServer/.python-eggs'
The Python egg cache directory is currently set to:
/Library/WebServer/.python-eggs
Perhaps your account does not have write access to this directory? You can
change the cache directory by setting the PYTHON_EGG_CACHE environment
variable to point to an accessible directory.solution
fix python egg dir and permissions:
See http://www.newtonslore.com/2007/06/09/mysqldb-lays-an-egg/
create the directory and set the privileges
chown -R www:www /Library/WebServer/.python-eggs)
hope that helps
-Paul B. Hartzog
Comments
sheesh! Well, you deserve a
sheesh! Well, you deserve a plaque for both doing it and documenting it! :-)
There may (or may not) be an easier way with python easy_install http://peak.telecommunity.com/DevCenter/EasyInstall (not sure how well it works with macs)
Post new comment