Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ekopras18/476e21a6d03cc837bace988d4e562359 to your computer and use it in GitHub Desktop.
Save ekopras18/476e21a6d03cc837bace988d4e562359 to your computer and use it in GitHub Desktop.
You can run current version of MAMP with PHP 5.4.4 or 5.2.17. How to run 5.3+

Introduction

Lately I needed to test some code against PHP version 5.3 wich is (hopefully not forever) the highest supported version on one of my clients hosting right now. To cut the story short, I develop and test on a local MAMP server, usualy for PHP v5.4+. The free version of MAMP will let you run either v5.4.4 or v5.2.17 of PHP. To run other version you need to purchase MAMP Pro. But I haven't read/heard a single person saing about MAMP Pro worth its price tag.

Setup

My MAMP installation comes with many PHP versions preinstalled. See /Applications/MAMP/conf (Cmd+G), but you can swich only between two: the lowest and the heighest version of PHP. No option between. There are these versions in my MAMP/conf folder:

  • php5.2.17
  • php5.3.5
  • php5.3.13
  • php5.3.14 (I need this one to test against)
  • php5.4.3
  • php5.4.4

The thing is, that what version of PHP is being used is defined in /Applications/MAMP/conf/apache/httpd.conf in this directive:

LoadModule php5_module        /Applications/MAMP/bin/php/php5.4.4/modules/libphp5.so

You go and edit it to something else:

LoadModule php5_module        /Applications/MAMP/bin/php/php5.3.14/modules/libphp5.so

Soon you'll find out, that MAMP is rewriting your previously stored setting on each server start.

Stop MAMP from rewriting /Applications/MAMP/conf/apache/httpd.conf

  1. Head to Finder, hit Cmd+G (Go) and enter /Applications/MAMP/conf/apache
  2. find the http.conf, hit Cmd+I (File Info)
  3. Lock the file
  4. Done

Happy testing with various versions of PHP!

@martin_adamko

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment