How to code & run PHP on Mac OS X (10.6)?

Discussion in 'Mac Apps and Mac App Store' started by mnya, Jun 26, 2013.

  1. mnya macrumors member

    Jul 20, 2012
    What do I have to download and configure? I'm getting mixed info on Google search and from app companies... please help :confused:
  2. PaintTheSkyGrey macrumors member

    Sep 9, 2009
    MAMP would be the best bet for running PHP web applications.
  3. firedept macrumors 603


    Jul 8, 2011
    MAMP is going to be your best chose. It is free and easy to configure. Plus down the road you can upgrade to MAMP Pro (for a cost) should you require the additional features.

    But it seems to me you are new to this, so stick with MAMP. MAMP's website has some pretty good instructions for setting it up. It is a nice all in one package. Easiest for beginners.
  4. theluggage macrumors 68040

    Jul 29, 2011
    You need the Apache webserver and the PHP module (actually, you already have these, OS X uses Apache for web sharing but read on...). PHP has a metric shedload of optional libraries and helpers which you may or may not need. If you're writing PHP code that will store data on the server, you'll probably end up wanting a database manager such as MySQL or PostgreSQL and the corresponding PHP library.

    Once you've got that, all you really need is a text editor, but you could look into Eclipse, Netbeans (free) or Coda (paid).

    Option 1:

    As the pervious poster suggested MAMP gives you MySQL, Apache, PHP in a single self-contained package.

    Pro: all-in-one - includes the kitchen sink.
    Con: probably not a biggie but if you also want to use web sharing on your Mac, you'll need to run MAMP on a non-standard port, so you have to access it as something like http://yourdomain:8080/

    Option 2:

    OSX 10.6 already has both of these installed, but PHP isn't enabled. You need to use a text editor to edit /etc/apache2/httpd.conf, look for the line:

    #LoadModule php5_module libexec/apache2/
    ...and uncomment the line to remove the '#'.

    Then go to the "sharing" panel in System Preferences and turn web sharing off (if its already on) and then on again.

    You can then put PHP files in your "Sites" folder and open them by going to http://localhost/~yourshortusername/whatever.php

    ...a bit more footling with the httpd configuration files and you can redirect the root http://localhost/ to wherever you want. Learning to mess with httpd configuration files will put hair on your chest :)

    Pro: no new software to install.

    Con: The version of PHP in OS X 10.6 is ancient and has a limited number of add-ins.

    Option 3:

    You have hair on your chest. You laugh in the face of the the Unix command line. You will want to install MacPorts and use that to compile your preferred versions of Apache, PHP and (if you need it) MySQL.

    Pro: decide exactly what features you want enabled in PHP
    Con: No, I'm not going to write a step-by-step tutorial.
  5. mnya thread starter macrumors member

    Jul 20, 2012

    Thank you, all!
    Good to know MAMP is recommended by so many.
    Actually I tried using MAMP, but I got an error...

    I was using TextWranger to code PHP, and installed MAMP, and then opened the PHP file on Safari to preview, then the new page says I needed GD Library...
    So I got it from a site, unzipped it, but I don't know what I'm supposed to do after that. There is no application in GD Library to start. The PHP page still says I need GD Library.

Share This Page