Install Magento on Unix with mcrypt
Posted by Stephan Kristyn on July 13th, 2010 / 2 Comments
Hopefully this guide will shrink the 3 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.
Let’s begin!
- Create hostfile entry for your online shop in /etc/hosts, for e.g.
127.0.0.1 beta.shop.com
- Create 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 with
sudo vi /private/etc/apache2/extra/httpd-vhosts.conf
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:
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’ve 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.
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.
http://beta.shop.com
or if you did not set up apache properly
http://beta.shop.com/username/magentodirectory
- Installation should run through just fine. Finally copy the sample data from the Magento Sample Zip Package over into the media folder. Congratulations!
This is what I get:

http://blog.markhopwood.com/2010/02/22/installing-magento-enterprise-stand-alone-on-os-x/
http://michaelgracie.com/2009/09/23/plugging-mcrypt-into-php-on-mac-os-x-snow-leopard-10.6.1/
Twitter
Facebook
Reddit
StumbleIt!
Digg it
Google
Delicious
Comments
-
Comment by Arnold Chan on Sep 1st, 2010 at 5 am
You are awesome, and it works !!!
I spent all the morning searching for “working” articles on installing mcrypt on MAMP environment, but none of them works.
I am going to buy myself a Starbucks coffee, i deserved it !!
-
Comment by Stephan Kristyn on Sep 1st, 2010 at 6 am
Thank you – I’m glad I could help; it’s always good to get some feedback. See you at Starbucks.