Running Apache in 32-bit mode on Leopard
Background
With the evolution of Apple’s hardware from 32-bit to 64-bit compatibility, there are bound to be some difficulties. They have tried to alleviate much of the complexity of running in this environment through their use of universal binaries, but sometimes there are unforeseen difficulties that require “undoing” some of Apple’s handiwork.
As an example, the standard Apache web server is actually made of 4 different executables: 32-bit and 64-bit versions for the PowerPC architecture, and 32-bit and 64-bit versions for the Intel (x86) architecture. Normally, the operating system runs the “most appropriate” version depending on the nature of the hardware. However, this may cause problems when trying to use Apache modules which may not support the “most appropriate” version. A common occurrence of this is when using the PHP module and some of its extensions.
There are two possible methods of alleviating this problem: recompile every module and extension so that it is in the supported architecture or strip the 64-bit binary from the Apache universal binary which forces the operating system to run it in 32-bit mode. As the more expedient solution is simply to force Apache into 32-bit mode, that is the route explained below.
Special Notice
This procedure alters the installed Apache web server. The changed binary may be over-written by a future update which may require this procedure to be repeated. This procedure has been tested only on Leopard running on an Intel-based Mac Pro. Older PowerPC-based systems or systems running Snow Leopard may not require this process.
Setup
- List the supported architectures in the Apache binary.
file /usr/sbin/httpd - Verify that “Mach-O 64-bit executable x86_64″ is listed as part of the universal binary.
- Copy the original executable to a backup location for safety.
sudo cp /usr/sbin/httpd /usr/sbin/httpd.orig - Stop the web server.
sudo apachectl stop - Remove the 64-bit executable from the Apache universal binary.
sudo lipo /usr/sbin/httpd -remove x86_64 -output /usr/sbin/httpd - List the supported architectures now in the Apache binary.
file /usr/sbin/httpd - Verify the “Mach-O 64-bit executable x86_64″ is no longer listed as part of the universal binary.
- Restart the web server.
sudo apachectl start