3

Problem

Using OS X Yosemite and Python 2.7, I am trying to follow a simple hello world in Flask with Apache WSGI but am receiving this error when executing apachectl -S:

httpd: Syntax error on line 171 of /private/etc/apache2/httpd.conf: Cannot load libexec/mod_wsgi.so into server: dlopen(/usr/libexec/mod_wsgi.so, 10): image not found

What I've tried

First, I placed the file in /usr/libexec/apache2/ with the other mod_* files. Second, I tried to follow Graham Dumpleton's answer and verify the following steps:

1. That you don't have extensions hidden and have added the extension twice.

gwg$ file /usr/libexec/apache2/mod_wsgi.so
/usr/libexec/apache2/mod_wsgi.so: Mach-O 64-bit bundle x86_64

2. That the mod_wsgi.so file is readable to whatever Apache service user is.

I'm not sure exactly how to do this, but I just checked the file's permissions against other .so files. For example:

gwg$ ls -l mod_vhost_alias.so 
-rwxr-xr-x  1 root  wheel  19472 Sep  9 18:11 mod_vhost_alias.so

and

gwg$ ls -l mod_wsgi.so 
-rwxr-xr-x  1 root  wheel  209564 Dec  4 17:05 mod_wsgi.so

3. That your Apache is 32 [64] bit.

I'm not sure how to do this.

4. That your Python is 32 [64] bit.

Per this SO answer:

>>> import struct
>>> print struct.calcsize("P") * 8
64

5. That your Python is installed for all users and not just user you installed it as.

gwg$ sudo su -
root# python
Python 2.7.6 (default, Sep  9 2014, 15:04:36) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Question

Any help? Thanks in advance.

Community
  • 1
  • 1
jds
  • 7,910
  • 11
  • 63
  • 101

1 Answers1

2

Using brew was the easiest for me to run wsgi on Mac OS X. This is the sequence.

  1. brew tap homebrew/apache
  2. brew install mod_wsgi
  3. If necessary xcode-select --install
  4. You must manually edit /etc/apache2/httpd.conf to include LoadModule wsgi_module /usr/local/Cellar/mod_wsgi/3.X/libexec/mod_wsgi.so
    • X is 5 as of Dec, 2014, but just follow the instruction what is shown on the screen
  5. Check if everything's OK
    • httpd -t => Syntax OK
prosseek
  • 182,215
  • 215
  • 566
  • 871