mod_wsgi icon indicating copy to clipboard operation
mod_wsgi copied to clipboard

MacOS M2 Pro New Installation Trouble

Open kheff16 opened this issue 2 years ago • 1 comments

This issue is potentially system or OS dependent.

I ran into a few errors when trying to install mod_wsgi over a couple days.

Chip: Apple M2 Pro OS: Ventura 13.3.1

When running a system install for mod_wsgi following the Installation On MacOS X guide.

I followed the steps by downloading the tarball from here[https://github.com/GrahamDumpleton/mod_wsgi/releases]. I used 4.9.4.

In preparing for this installation I used home-brew install httpd to avoid any System Integrity Protection (SIP) issues. I also installed python-2.7 to python in my path.

After downloading the source code, httpd and python2.7 I ran the steps:

  1. ./configure in the source code's downloaded directory using the zip version.
  2. make
  3. sudo make install

The only issue was ld: warning: ignoring file /Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64 after running make.

I located the issue that the seemed to be the python 2.7 version I was using was deprecated and may not be able to support the chip architecture. Note that the python2.7 version I had installed was not included with the system, however the ./configure --with-python=/usr/bin/python3 showed no error in the make step, but where it came to running httpd, there was a syntax error, httpd: Syntax error on line 66 of /opt/homebrew/etc/httpd/httpd.conf: Cannot load /opt/homebrew/lib/httpd/modules/mod_wsgi.so into server: dlopen(/opt/homebrew/lib/httpd/modules/mod_wsgi.so, 0x000A): symbol not found in flat namespace '_PyBool_Type'

I resolved this issue by using homebrew install python and reviewing the MakeFile after running configure. With this new version of python it looks like there is a new naming for one of the variables that configure populates in the load step. specifically the variable was LDFLAGS. The original value of LDFLAGS was -L/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.11/lib -L/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.11/lib/python3.11/config -arch arm64.

However, on inspection the later of these files is incorrect. The directories all existed except for config. Instead, the directory was renamed config-3.11-darwin. Making that change in the LDFLAGS allowed for the httpd to work as intended. The value of LDFLAGS is presented below for clarity.

-L/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.11/lib -L/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.11/lib/python3.11/config-3.11-darwin -arch arm64

This issue is resolved for me personally, but hopefully the SEO on these errors might help someone who runs into these potential hiccups when installing for Mac on new system architecture.

I am excited to begin using mod_wsgi and I want to thank all the contributors who have worked hard to make this project the success that it is. Thank you.

kheff16 avatar Apr 23 '23 05:04 kheff16

You are better off not using configure/make/make install method on macOS, use the pip install mod_wsgi method instead. See:

  • https://pypi.org/project/mod-wsgi/
  • https://www.youtube.com/watch?v=H6Q3l11fjU0

Same restrictions about using Homebrew Apache, and possibly Homebrew Python as well.

GrahamDumpleton avatar Apr 23 '23 06:04 GrahamDumpleton