I recently formatted my MacBook and I chose to use PHP that comes with the operating system. This version comes with a few libraries installed, then you need to make some customizations.
First you must enable the PHP module in Apache, there are several tutorials talking about it on the web. A quick Google search brings some good results over this. So I will not talk about it here.
Once installed the PHP module in Apache and properly configured, you must compile some libraries from source.
First of all, you should make sure that you have Developer Tools installed. These software usually comes at an additional installation disc, along with your computer.
MySQL should be installed too. You can grab its installer from the official site.
All steps bellow consider that you are the root of the system, then run the following command:
sudo su
Then edit the extensions’ path on the PHP settings file.
vim /etc/php.ini
Search for extensions_dir and change its value for:
extensions_dir = /usr/lib/php/extensions
I’m using Mac OS X 10.5.8 that comes with PHP 5.2.12. You have to download the source code for your PHP version. You can check your PHP version with the following command on Terminal:
php -v
We consider [php-source-dir] as the directory where you have download the PHP source code.
Step 1 – PDO MySQL
To install the PDO MySQL module on PHP, run the following sequence of commands.
cd [php-source-dir]/ext/pdo_mysql phpize MACOSX_DEPLOYMENT_TARGET=10.5 \ CFLAGS='-arch x86_64 -g -Os -pipe -no-cpp-precomp' \ CCFLAGS='-arch x86_64 -g -Os -pipe' \ CXXFLAGS='-arch x86_64 -g -Os -pipe' \ LDFLAGS='-arch x86_64 -bind_at_load' \ ./configure --prefix=/usr --with-pdo-mysql=/usr/local/mysql \ --with-zlib-dir=/usr make make install cd /usr/lib/php/extensions ln -s no-debug-non-zts-20060613/pdo_mysql.so pdo_mysql.so
Then update the PHP configuration.
vim /etc/php.ini
Add the following line to the end of file:
extension=pdo_mysql.so
Finally, restart the web server.
apachectl restart
If you create a PHP file with the phpinfo() function, you’ll see the PDO MySQL function enabled.
Step 2 – Mcrypt
This step is very similar to the previous one, the I’ll skip the explanation and just show the necessary code.
cd [php-source-dir]/ext/mcrypt phpize MACOSX_DEPLOYMENT_TARGET=10.5 \ CFLAGS='-arch x86_64 -g -Os -pipe -no-cpp-precomp' \ CCFLAGS='-arch x86_64 -g -Os -pipe' \ CXXFLAGS='-arch x86_64 -g -Os -pipe' \ LDFLAGS='-arch x86_64 -bind_at_load' \ ./configure make make install cd /usr/lib/php/extensions ln -s no-debug-non-zts-20060613/mcrypt.so mcrypt.so
Add the following line to php.ini.
extension=mcrypt.so
Restart Apache web server with apachectl command line tool.
Step 3 – GD
The last PHP lib required by Magento is GD. Before install GD you must have libjpeg installed. Download libjpeg-6b source code and go to its directory, then run the following commands:
cp /usr/share/libtool/config.sub . cp /usr/share/libtool/config.guess . MACOSX_DEPLOYMENT_TARGET=10.5 \ CFLAGS='-arch x86_64 -g -Os -pipe -no-cpp-precomp' \ CCFLAGS='-arch x86_64 -g -Os -pipe' \ CXXFLAGS='-arch x86_64 -g -Os -pipe' \ LDFLAGS='-arch x86_64 -bind_at_load' \ ./configure --enable-shared make mkdir -p /usr/local/include \ /usr/local/bin /usr/local/lib \ /usr/local/man/man1 make install
After install libjpeg you can install GD library. Like PDO MySQL and Mcrypt libs, run the commands bellow to get GD installed.
cd [php-source-dir]/ext/gd phpize MACOSX_DEPLOYMENT_TARGET=10.5 \ CFLAGS='-arch x86_64 -g -Os -pipe -no-cpp-precomp' \ CCFLAGS='-arch x86_64 -g -Os -pipe' \ CXXFLAGS='-arch x86_64 -g -Os -pipe' \ LDFLAGS='-arch x86_64 -bind_at_load' \ ./configure --with-zlib-dir=/usr --with-jpeg-dir=/usr/local/lib \ --with-png-dir=/usr/X11R6 --with-freetype-dir=/usr/X11R6 \ --with-xpm-dir=/usr/X11R6 cd /usr/lib/php/extensions ln -s no-debug-non-zts-20060613/gd.so gd.so
Add the following line to php.ini.
extension=gd.so
And, finally, restart the web server with apachectl restart.