crmpicco
crmpicco

Reputation: 17181

Apache module error on M1 chip - file, but is an incompatible architecture have 'arm64', need > 'x86_64'

I am on the Apple M1 arm64 chip arm64.

uname -m
arm64

I am trying to install the PHP 8.2 module for Apache, e.g.

LoadModule php8_module /opt/homebrew/Cellar/php/8.2.1/lib/httpd/modules/libphp.so

...however when I do so I encounter the following error:

apachectl -S
httpd: Syntax error on line 183 of /usr/local/etc/httpd/httpd.conf: Cannot load /opt/homebrew/Cellar/php/8.2.1/lib/httpd/modules/libphp.so into server: dlopen(/opt/homebrew/Cellar/php/8.2.1/lib/httpd/modules/libphp.so, 0x000A): tried: '/opt/homebrew/Cellar/php/8.2.1/lib/httpd/modules/libphp.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/php/8.2.1/lib/httpd/modules/libphp.so' (no such file), '/opt/homebrew/Cellar/php/8.2.1/lib/httpd/modules/libphp.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))

file `which php`
/usr/local/bin/php: Mach-O 64-bit executable arm64
file `which httpd`
/usr/local/bin/httpd: Mach-O 64-bit executable x86_64

From memory, Apache was installed with the old version of Homebrew on an Intel chip Mac and was imported into the new MBP on the M1 chip.

PHP (8.2) was installed recently using the fresh Homebrew install for arm64.

What are my options? Uninstall Apache and re-install then reconfigure?

Upvotes: 0

Views: 904

Answers (1)

Kimh
Kimh

Reputation: 21

I've had the same issue and did try to reinstall apache (upgraded osx), but did not work.

I finally found out that if I ran Apache under the old architecture using Rosetta, it worked. Not the result I had hoped for, but I've wasted HOURS on this already so, it's good enough for me.

To do so, simply prefix you terminal command with "arch -x86_64", ie:

arch -x86_64 sudo apachectl -k restart

HTH

Upvotes: 2

Related Questions