Hopefully this guide will shrink the two hours I needed for the install down to half an hour for you. One of the problems I faced was that I had to inject mcrypt into an already installed php installation. But more on that later.
In the following tutorial you need quite a bit bash experience and know your way around in a shell editor like vi or nano. I also assume that you have a working apache, php and some SQL Server installed.
Create a hostfile entry for your online shop in the hosts file of your private etc directory, for e.g.
Create an empty Magento Database in your SQL server.
Grant your user rights to that database. This would be the syntax in MySQL:
mysql> grant all privileges on data-base-name.* to username @ localhost;
After receiving a Query OK import the Magento Sample Database
mysql -u username -p -h localhost data-base-name < data.sql
Unzip Magento into your chosen local Directory. You can define that directory in apache2 in your httpd-vhosts.conf file. This file resides in the apache2/extra/ directory of your private etc directory.
Then add a VirtualHost section like in the file's example with these important directives:
DocumentRoot "/Users/username/Sites/magentoDir/" ServerAlias beta.shop.com
Now, the tricky part that I mentioned earlier. In order to install the mcrypt.so module into an already running php installation, we have to do some steps. The following guide will work on MacOSX 10.5 and 10.6 with any newer versions of PHP5. Make sure to have XCode installed by Apple, because we need its developer SDK when compiling mcrypt. Most of the credits of the following tutorial go to Michael.
Get libmcrypt-2.5.8, which you can pick up here; Note: make sure to get libmcrypt and not mcrypt.
Get the PHP 5.3.0 source, which you grab here. Next, create a directory in your root directory called SourceCache and dump the packages in there and unzip.
Move to the libmcrypt-2.5.8 directory, and punch in this line:
MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS='-O3 -fno-common -arch i386 -arch x86_64' LDFLAGS='-O3 -arch i386 -arch x86_64' CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64' ./configure --disable-dependency-tracking
and then make -j6 and finally sudo make install
libmcrypt is ready. Now for the PHP extension move back to /SourceCache, then down to php-5.3.0/ext/mcrypt and type /usr/bin/phpize . Then configure as follows:
MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS='-O3 -fno-common -arch i386 -arch x86_64' LDFLAGS='-O3 -arch i386 -arch x86_64' CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64' ./configure --with-php-config=/Developer/SDKs/MacOSX10.6.sdk/usr/bin/php-config
Again make -j6 then sudo make install
Make sure you have php.ini in the /etc directory. It will probably be php.ini.default to start, particularly if you have just done the Snow Leopard upgrade, so rename it with cp or mv. Ensure that you have enable_dl = On but do not remove the ; in front of ;extension_dir = "./". Add one line to the .ini file in the Dynamic Extensions section. extension=mcrypt.so. Also comment out the line that contains /var/mysql/mysql.sock or change the path to /tmp/mysql.sock. The default mysql.sock location in the php.ini.default file is a bug. In case you are running in problems with your other databases it is always a good idea on MacOSX to use the /tmp/mysql.sock path because this reportedly solved problems in the past as desrcibed here.
Restart Apache and get yourself a Coffee, you deserved it if you came this far :)
For the Install script in the next step to run without problems, we have to grant the script some rights. I would not recommend this on a production server without precaution, but in your demo environment it should be fine to recursively set your magento directory's file permissions to rwx for everyone with sudo chmod -R 777 magentoDir
If the following magento install runs through without any problems, you successfully compiled mcrypt into php.
Open the URL to run the magento install script, for e.g.
or if you did not set up apache properly