macports Apache, Python 3.3 + non-macports mod_wsgi3.4

When I tried to install it on a mac, it was a little different, so make a note

First, when I check the dependency of mod_wsgi of macports, ...

$ port info mod_wsgi
Warning: port definitions are more than two weeks old, consider using selfupdate
mod_wsgi @3.3 (www, python)
Variants:             python24, python25, [+]python26, python27, python31, universal

Description:          The mod_wsgi module is written in C code directly against the internal Apache and Python application programming interfaces. As such, for
                      hosting WSGI applications in conjunction with Apache it has a lower memory overhead and performs better than existing WSGI adapters for
                      mod_python or alternative FASTCGI/SCGI/CGI based solutions.
Homepage:             http://www.modwsgi.org/

Library Dependencies: apache2, python26
Platforms:            darwin
License:              Apache
Maintainers:          [email protected]

Python3.3 is not included in the dependencies. In other words, in order to run wsgi using python3.3, mod_wsgi may not work on macports. So, as with Sakura VPS, build and install it yourself.

First time

(python33)
$ wget http://modwsgi.googlecode.com/files/mod_wsgi-3.4.tar.gz
$ tar zxvf mod_wsgi-3.4.tar.gz
$ cd mod_wsgi-3.4
$ ./configure --with-apxs=/opt/local/apache2/bin/apxs --with-python=/opt/local/bin/python3.3
checking Apache version... 2.2.22
configure: creating ./config.status
config.status: creating Makefile
$ make
(Abbreviation)
$ sudo make install
(Abbreviation)
$ 

There seems to be no problem until installation. However……

(LoadModule httpd.Added to conf)


$ sudo /opt/local/apache2/bin/apachectl -S
httpd: Syntax error on line 119 of /opt/local/apache2/conf/httpd.conf: Cannot load /opt/local/apache2/modules/mod_wsgi.so into server: dlopen(/opt/local/apache2/modules/mod_wsgi.so, 10): Symbol not found: __Py_FalseStruct\n  Referenced from: /opt/local/apache2/modules/mod_wsgi.so\n  Expected in: flat namespace\n in /opt/local/apache2/modules/mod_wsgi.so

I can't load mod_wsgi.so. When I googled, I found it here.

Provide the output from running:

otool -L /usr/libexec/apache2/mod_wsgi.so

$ otool -L /opt/local/apache2/modules/mod_wsgi.so
/opt/local/apache2/modules/mod_wsgi.so:
	/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 635.21.0)
	/opt/local/lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.1.0)
	/opt/local/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.1.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)

It looks like mod_wsgi.so is looking at Python 2.7. As I read the page I found, it seems that Framework must be disabled ...

Second time

For the time being, make the python path the full macports path

(python33)$ ./configure --with-apxs=/opt/local/apache2/bin/apxs --with-python=/opt/local/Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3 --disable-framework
checking Apache version... 2.2.22
configure: creating ./config.status
config.status: creating Makefile
$ make
(Abbreviation)
$ sudo make install
(Abbreviation)
$ 
(LoadModule httpd.Added to conf)
$ otool -L /opt/local/apache2/modules/mod_wsgi.so
/opt/local/apache2/modules/mod_wsgi.so:
	/opt/local/Library/Frameworks/Python.framework/Versions/3.3/Python (compatibility version 3.3.0, current version 3.3.0)
	/opt/local/lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.1.0)
	/opt/local/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.1.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 635.21.0)
$ sudo /opt/local/apache2/bin/apachectl -S
(Abbreviation)
Syntax OK

This time he recognized it correctly.

Recommended Posts

macports Apache, Python 3.3 + non-macports mod_wsgi3.4
CentOS 6.4 with Python 2.7.3 with Apache with mod_wsgi and Django
How to embed mod_wsgi into Apache on Python Windows
Apache mod_auth_tkt and Python AuthTkt
Django --Apache mod_wsgi virtualhost deployment
Touch Apache Beam in Python
Apache Beam Cheat Sheet [Python]
Make apache log csv with python
Apache Beam (Dataflow) Practical Introduction [Python]
Set multiple WSGIPythonPath with Apache + mod_wsgi
Run python3 Django1.9 with mod_wsgi (deploy)
Until you run python with apache
Environment construction of Flask / MySql / Apache / mod_wsgi / virtualenv with Redhat7 (Python2.7) November 2020