Mac OS X MAMP, solr & PHP

Fix MAMP components

First you need to config your MAMP apache configuration correct, follow these steps:

  • Download MAMP components and configure
  • URL: (i.e.
  • Unpack your
  • Identify your php-5.x.x.tar.gz file (where 5.x.x is your version of PHP)
  • Create directory for your PHP sources: ”mkdir -vp /Applications/MAMP/bin/php/php5.X.X/include”
  • Unzip the tar file to you new folder
  • Rename your php-5.x.x directory to php (without the version numbering) e.g. mv /Applications/MAMP/bin/php/php5.2.17/include/php-5.?.?? /Applications/ MAMP/bin/php/php5.2.17/include/php
  • Configure PHP sources by running the following command in the terminal:cd /Applications/MAMP/bin/php/php5.?.??/include/php ./configure


Then you need to change you $PATH for PHP, use the terminal and type in:

vim ~/.profile

Add first to line: /Applications/MAMP/bin/php/php5.4.4/bin:

Ex of output should be.) export PATH=/Applications/MAMP/bin/php/php5.4.4/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

Save and exit (press ”esc” type in wq och press return).

Rest .profile by running this:

source ~/.profile

Make sure that if you type in ”which php” in the terminal, it should show you the path to you bin directory within MAMPs folderstruture

Install solr with brew

Now, use brew to install solr engine.

brew install pecl/solr

To test it, go to: /usr/local/Cellar/solr/4.3.1/libexec/example/

and run the following command in the terminal: java -jar start.jar

Install PECL and solr php extension

And last, install PECL and use PECL to install solr-php extension. Follow this guide:

From guide (if deleted):

sudo php -d detect_unicode=0 go-pear.phar
  1. Type 1 and press return.
  2. Enter:
  3. Type 4 and press return.
  4. Enter:
  5. Press return

MAMP add virtualhosts

If you want to run your own VirtualHosts when you are using MAMP on Mac, just do the following step:

1.) Open your terminal

2.) Run: pico /Applications/MAMP/conf/apache/httpd.conf

3.) Add the following to the bottom of the file (change for your values):

NameVirtualHost *

DocumentRoot ”/Applications/MAMP/htdocs/”
ServerName localhost

DocumentRoot ”/Applications/MAMP/htdocs/YOUR-PATH”
ServerAlias *
4.) Save

5.) Open your hosts file, ”sudo pico /etc/hosts”

6.) Add your domain and point it to your localhost (add at the bottom of the file):

7.) Save and your done

If you want to check your configuration, just run: apachectl configtest

MAMP run mysql as command on a mac

As you might have noticed when running MAMP as your local Apache/MySQL/PHP enviroment you cannot run ”mysql” as a command from the terminal. This is beacuse the execute file is in the folder /Applications/MAMP/bin/apache2/bin/mysql

To fix this, simply create a symlink from the execute file to your /bin/ folder. Just copy and paste the command below to your terminal and run it:

sudo ln -s /Applications/MAMP/bin/apache2/bin/mysql /bin/mysql