Home > Uncategorized > PHP 5.3 on OSX

PHP 5.3 on OSX

February 22nd, 2010 Leave a comment Go to comments

I wanted to play with Symfony 2 and so needed to install PHP 5.3 on my OSX 10.5. What seemed like a simple task turned into a huge waste of my time.

I use MAMP because it’s a nice out-of-the-box solution. The problem is, it still doesn’t ship with 5.3 because it’s waiting for it to be “stable”.

It’s funny that I got a similar answer a few years ago from a big web hosting company about PHP5 when it was clearly announced that PHP4 is discontinued.

I first searched for a way to upgrade PHP in MAMP and came across this nice post: http://www.davidgolding.net/cakephp/upgrading-php-in-mamp.html

Unfortunately, while following the steps, I kept getting errors because some dependencies were missing. First openssl, then libjpeg, and so on. After some time I grew tired of that catch-up game and decided to go with a product that comes with 5.3 pre-compiled.

XAMPP was my answer. You can download it here: http://www.apachefriends.org/en/xampp.html

So if you’re tired of MAMP, it’s time to switch.

EDIT:

To migrate your vhost config from MAMP, copy  to XAMPP/etc/extra/httpd-vhosts.conf and enable the line that contains this path in XAMPP/etc/httpd.conf

To migrate your MySQL, my favorite method is to enable MySQL via MAMP, dump all the databases to a file (you may use MySQL Administrator for convenience), disabling MySQL via MAMP, enabling it via XAMPP and then restore your databases from the dump file.

EDIT 2:

At the time of this post, XAMPP ships with PHP 5.3.0 while Symfony 2 requires 5.3.1. Oh well, I guess I’ll just wait for them to release a new version before I play with Symfony.

Tags:
  1. February 22nd, 2010 at 15:48 | #1

    I have at home few Vostro servers with several OS installed to test new software. Few months ago, I wrote a new set of RPMs for PHP 5.3.1, on CentOS 5.4 64bits. All I have to do is install the NX client on any computer I use and I have instant access to my developer server. You should try it, it will save you a lot of time.

  2. February 22nd, 2010 at 15:52 | #2

    I have a simple-to-follow writeup of how to build your own PHP 5.3.x environment on Snow Leopard. http://www.teamonetickets.com/software/howto-setup-php-apache-mysql-dev-environment-on-snow-leopard.html

  3. February 22nd, 2010 at 17:04 | #3

    Why not use MacPorts? There are lots of tutorials around describing how to get a working PHP/MySQL installation going with MacPorts. Sure, it involves installing MacPorts (which is not such a bad thing, IMHO) but you benefit from relatively pain-free upgrades later on, since MacPorts resolves dependency issues for you.

  4. February 22nd, 2010 at 17:41 | #4

    I’d say Symfony 2 will run on 5.3.0 for testing/development purposes, but 5.3.0 has a ton of bugs that have been fixed 5.3.1 so it’s highly recommended to use the latter. Just expect WTF’s to happen, but don’t let that stop you from trying Sf2 :)

  5. February 22nd, 2010 at 17:55 | #5

    What I do for development on my MacBook is having Ubuntu Server installed in a VirtualBox VM. I can easily mount the directories within the VM on the host system using MacFuse, but in some cases a Samba share or a shared folder would do the trick just as well.

    The benefits of having a dedicated development environment separated from your regular desktop OS are so great, I even use VirtualBox running Linux when I’m working on Linux hosts.

  6. February 22nd, 2010 at 18:01 | #6

    fong
    I remember using MacPorts some time ago but did not realize that it can solve my dependency problems. I guess that’s the whole point of MacPorts: not to worry about dependencies. I’ll give it a shot later today and let you know how it worked out.

  7. February 22nd, 2010 at 18:02 | #7

    Boggiano
    I agree. I was able to run Symfony 2 without 5.3.0. I might run into trouble later, but I’m not worried since I’m just playing with it.

  8. Rob Zienert
    February 22nd, 2010 at 18:04 | #8

    Why not use Zend Server CE? Super easy to setup.

  9. February 22nd, 2010 at 18:04 | #9

    Wolff
    I use VMs for bigger projects. I just don’t create one every time I want to try some new gadget. In any case, I never targeted a 5.3 production environment yet, so I don’t have 5.3 on any VM.

  10. February 22nd, 2010 at 18:10 | #10

    @Rob Zienert
    I’m still unsure of what Zend Server does other than provide a GUI for my php.ini and such. The official page is pretty thin.

  11. Artur Ejsmont
    February 23rd, 2010 at 04:29 | #11

    im currently forced to develop on mac and i hate it to be honest : ) it has been a year and im not into it at all! if it werent for macports it would be a 100% useless os made for simpletons ; )

    throwing that to a side i would suggest ports indeed. i also heard new version of macos ships with php5.3 but i dont know details as i have not used it.

    Why would companies insist on developing on totally differnet arch then deploy to? these tiny version numbers or missing extensions or os specyfic errors are serious pain. I used to work on windows for 2 years as well and seriously it was same pain. Develop on ubuntu, delpoy to debian : ) that would be my dream now : )

  12. February 23rd, 2010 at 10:55 | #12

    I used these instructions to get set up with a complete PHP/MySQL dev environment on my MacBook Pro last year – http://2tbsp.com/content/install_apache_2_and_php_5_macports. It looks like a lot to jump through but in reality, it took me less than an hour to get everything working just as I wanted it. And yes, the biggest benefit is that installing new modules or updating PHP is really simple since dependencies are managed by MacPorts. Porticus is a nice GUI wrapper for the ports command line tool if you prefer port management that way. (BTW, FWIW, I don’t use the MySQL server from MacPorts — I use the Community edition from mysql.com, but that’s mainly because I already had a working MySQL DB prior to installing MacPorts.)

    Good luck! =)

  13. Mamsaac
    February 23rd, 2010 at 16:29 | #13

    Considering that XAMPP has PHP 5.3.1 packages for Windows, I would expect such version to be available for Mac OS pretty soon.

  14. Ted
    February 23rd, 2010 at 19:52 | #14

    Is upgrading to Snow Leopard an option? You get PHP 5.3 out of the box, along with newer versions of other stuff like Ruby, Rails, etc.

  15. pj
    February 24th, 2010 at 01:00 | #15

    why not just use MacPorts? It is very easy to install and upgrade to the latest and greatest versions as well as add extensions etc, plus its more more consistent.

  16. Urkman
    February 24th, 2010 at 02:02 | #16

    Here is my Development Enviroment on my MacBook( 10.6 )
    – ZendServer CE( installs almost everything you need like, Apache, php 5.3, mysql )
    – PostgreSQL ( this is my main DB )
    – Netbeans ( best IDE for php )
    – SmartSVN

    And with that everything is setup on my MacBook.

    One thing I did on installation of OSX: I choose a casesensitive filesystem, because I deploy to a linux maschine…

    I’m very happy with all this stuff and development is just fun :-)

    Urkman

  17. February 24th, 2010 at 07:34 | #17

    @Ted
    I got Snow Leopard, but php -v gives me 5.2.11.

    MacPorts was indeed a good solution to upgrade my PHP.

  18. shaun
    March 1st, 2010 at 23:16 | #18

    I am currently running 10.6.2

    blahblah:~ shaunb$ php -v
    PHP 5.3.0 (cli) (built: Jul 19 2009 00:34:29)
    Copyright (c) 1997-2009 The PHP Group
    Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
    blahblah:~ shaunb$

    If I am not mistaken the 10.6.X php install is a 64 bit compilation.

  19. March 3rd, 2010 at 07:41 | #19

    While Snow Leopard does come with PHP 5.3, Apple does not update it regularly and I don’t know of a way to easily install PHP extensions when you need them. Updating to new releases of PHP, maintaining two versions (5.2 + 5.3, if you need them both), and installing new extensions are all made much easier with MacPorts.

  20. March 3rd, 2010 at 15:25 | #20

    MacPorts it is! I actually went ahead and installed multiple versions of PHP on my machine.

  1. No trackbacks yet.