So I was happy with my native PHP setup.
Until I updated Snow Leopard to 10.6.3.
The problem with the update is that it also updates PHP from 5.3.0 to 5.3.1. This in itself would be fine, but it also enables zend-multibyte. And this causes problems with FLOW3, because FLOW3 uses declare(ENCODING = 'utf-8'); at the beginning of every file, which throws an error on 5.3.1 with enabled zend-multibyte because of a bug (see the FLOW3 mailing list for details). This bug is fixed in PHP 5.3.2, but Snow Leopard 10.6.3 includes only 5.3.1.
Still with me? Okay, let’s fix this mess. How? If we were to fix this in the default setup, we’re going to run into these kind of problems again and again. To me, the only reasonable solution is to have your own operating-system independent solution.
So here’s what I did (and you should do, too):
Start by installing MacPorts if you don’t have it already. Then, install the newest Apache and PHP with the following commands:
sudo port install apache2 sudo port install php5 +apache2 +pear
You’ll also need the PDO drivers and the mbstring extension, get them with:
sudo port install php5-sqlite sudo port install php5-mysql sudo port install php5-mbstring
And then you probably have to adjust the settings. Now, MacPorts installs everything under /opt/local, so that’s were you should be looking for the files:
hosts is still at /etc/hosts (of course)
httpd.conf is at /opt/local/apache2/conf/httpd.conf
httpd-vhosts.conf is at
/opt/local/apache2/conf/extra/httpd-vhosts.conf
[username].conf is at
/opt/local/apache2/conf/extra/[username].conf
Some important things to check:
- Are
[username].confandhttpd-vhosts.confincluded in yourhttpd.conf? (Just do a quick search on both) - Does
httpd.confhandle php files? If not, enable it at the end of the file with<IfModule php5_module> AddType application/x-httpd-php .php </IfModule>
- Is overriding allowed? Search for
<Directory />and ensure
AllowOverrideis set toAll
That’s it, restart Apache
sudo /opt/local/etc/LaunchDaemons/ » org.macports.apache2/apache2.wrapper stop sudo /opt/local/etc/LaunchDaemons/ » org.macports.apache2/apache2.wrapper start
And of course you don’t want to do this everytime, so have it start on launch with:
sudo launchctl load -w » /Library/LaunchDaemons/org.macports.apache2.plist
Hope this helps … if you have any questions or corrections, please let me know.