PHP on Mac OS Monterey, M1 Macbook Pro

I migrated from a 2015 Macbook Pro to a Macbook Pro M1/Monterey.

I've not been able to successfully run PHP since. It is installed and the CLI works, but Apache2 continues to throw an architecture error.

Is there a version of PHP that will run on M1?

Thanks, Harry

Answered by mikeyh in 709392022

How are you building PHP? Homebrew, MacPorts or ?

If Homebrew then you'll need to rebuild, codesign then update your apache config LoadModule with the new Homebrew path which changed for Apple Silicon (you might be trying to load an old Intel build from migrated Homebrew or Big Sur install)

LoadModule php_module /opt/homebrew/lib/httpd/modules/libphp.so "Apple Development: Name (ID)

You can check the architecture with lipo:

lipo -archs /opt/homebrew/lib/httpd/modules/libphp.so
arm64

 

Also check:

Go to the PHP developer site and look there.

Accepted Answer

How are you building PHP? Homebrew, MacPorts or ?

If Homebrew then you'll need to rebuild, codesign then update your apache config LoadModule with the new Homebrew path which changed for Apple Silicon (you might be trying to load an old Intel build from migrated Homebrew or Big Sur install)

LoadModule php_module /opt/homebrew/lib/httpd/modules/libphp.so "Apple Development: Name (ID)

You can check the architecture with lipo:

lipo -archs /opt/homebrew/lib/httpd/modules/libphp.so
arm64

 

Also check:

Removing Homebrew then doing a fresh install created the appropriate structure (/opt/Homebrew) did the trick. I'm cleaning up some other loose ends but all pieces of my website (PHP, MySQL [mariadb] and httpd) are functioning.

What an experience.

Thank you for your help, I greatly appreciate it.

Sorry for the duplicate - I need to figure out how to close this out.

Removing Homebrew then doing a fresh install created the appropriate structure on my M1 laptop (/opt/Homebrew) did the trick.Homebrew had been using the /usr/ based structure, and therefore the software for Intel architecture.

PHP on Mac OS Monterey, M1 Macbook Pro
 
 
Q