Post Archive

› January 17, 2006

Start PHP on your new Mac

  • Reported by Nate

This is largely just a note to self:

  • Be sure bbedit or textmate or some other tool that has command line support is installed first
  • Open terminal
  • Open the php config file: bbedit /etc/httpd/httpd.conf (change bbedit if you're using something else)
  • Search for the term php
  • Un-comment the lines you find to contain php (remove the # at the start of the lines)
  • Save the file, open the system preferences and restart the web server by turning off/on again Personal Web Sharing under Sharing

Warning: At the time of this writing, this starts up the default version of PHP, which even on brand new Intel iMacs is version 4.3.1. Also, this info might be outdated by the time you read this. Doing this might not work on your computer, your computer might melt, it might train your cat to DESTROY, it might ruin your life's work - use at your own risk. Thanks Dan, for the reminder on how to go about this.

Comments

1. January 17, 2006 11:01 AM

Quote this comment

Justin Goodlett Posted…

I've tried for almost 2 days now and this little tip did the trick. Couldn't have done it without ya Nate!

2. January 17, 2006 11:24 AM

Quote this comment

Rob Posted…

While we're on the topic, does anyone know a good tutorial on upgrading PHP on the Mac, say to 4.x or 5.x? Thanks.

3. January 17, 2006 11:43 AM

Quote this comment

Nate Posted…

Yeah - I'd like that too.

4. January 17, 2006 12:51 PM

Quote this comment

tony Posted…

maybe this will help. i used this package to install php 5.

http://www.entropy.ch/software/macosx/php/

5. January 23, 2006 09:20 PM

Quote this comment

Jonathan Posted…

Actually pico will work just fine and it's included in the terminal. Also, for a quick fix you might want to look at MAMP or Complete PHP at http://www.serverlogistics.com/php4.php. Server logistics also has a MySQL installer as well.

6. January 24, 2006 09:42 AM

Quote this comment

Dave Posted…

Thanks! Been looking for an easy tutorial to get php working since I purchased my new intel iMac. I reckoon this info should be made more widespread as people who know php but don't really know the inner delvings of Mac OS X (such as myself) would really benefit from it.

7. February 1, 2006 03:12 AM

Quote this comment

Chad Posted…

A little help please, I have a new Intel iMac, my first mac, though I have used them here and there and know my way around. I installed textmate, opened the terminal and typed textmate /etc/httpd/httpd.conf

it just said command not found. ???

8. February 2, 2006 12:28 AM

Quote this comment

Chad Posted…

OK got it, worked great on my Intel 20" iMac. v4.3.11 here

9. February 17, 2006 07:48 AM

Quote this comment

CarbonCopy Posted…

Instructons work just fine on an Intel CoreDuo iMac 17in.

10. February 21, 2006 11:50 PM

Quote this comment

andrew Posted…

Anyone had luck getting this PHP install to work with the x86 MySQL 5 download from their website?

11. March 1, 2006 07:41 PM

Quote this comment

John Posted…

Doesn't seem to want to connect to Intel-based MySQL 4.1 either.

12. March 3, 2006 12:52 AM

Quote this comment

Joe Posted…

I have an Intel iMac and I think I figured out part of the problem with MySql connections. There is no socket link in /var/mysql. If you are in terminal you should create a directory called "mysql" in the "var" directory. then go to that directory and run the command "ln /tmp/mysql.sock ." That did the trick for me.

13. March 4, 2006 07:42 PM

Quote this comment

Andrew Montague Posted…

Hi Joe

I followed your directions, but when I ran "ln /tmp/mysql.sock" I got this message: "No such file or directory". Any ideas where I'm going wrong?

Thanks

14. March 5, 2006 07:31 AM

Quote this comment

CarbonCopy Posted…

The instructions posted by Joe, above, had a slight error. It should be "ln /tmp/mysql/mysql.sock"

THAT worked for me. Hope that helps.

15. March 6, 2006 07:48 PM

Quote this comment

Ryan Martell Posted…

Hey Andrew- A couple of things:

  • I had Joe's location for my mysql.sock file, not CarbonCopy's. It was in /tmp/mysql.sock. This was the default location for the i686 MySql version 5 installer.
  • I think this socket is only created on startup of the Mysql daemon. Make sure you have that started before typing in the command.
  • Finally, be sure you are typing LN in lowercase.
  • Good Luck!

    PS- Thanks Joe! That solved my problem

    16. April 8, 2006 05:58 AM

    Quote this comment

    glen Finch Posted…

    Same problem with socket link in connecting MySQL, creating a link to /tmp/mysql.sock works, but only until the server is restarted. Any ideas anyone?

    I also really need to get WDDX and GDLib libraries which don't come with the default PHP installation so I might end up having to compile from scratch afterall. Shell commands are not be speciality so be gentle! Any advice welcome

    17. April 19, 2006 11:44 AM

    Quote this comment

    bryan Posted…

    I was able to get the socket link between PHP and MySQL working just fine but it broke as soon as I rebooted. To get it working again I had to 'sudo rm /var/mysql/mysql.sock' and then redo the link 'ln /tmp/mysql.sock'

    I am going to do some hunting but does anyone know of a way to automate this process on startup?

    18. April 20, 2006 11:54 AM

    Quote this comment

    Ravi Posted…

    To get mySQL working with php on iMac Intel:
    1 - Locate the file /etc/php.ini.default
    2 - Make a copy of this file called php.ini
    Look for the bit that says:

    ; Default socket name for local MySQL connects. If empty, uses the built-in
    ; MySQL defaults.
    mysql.default_socket =

    3 - type /tmp/mysql.sock after mysql.default_socket =
    4 - Save and restart Apache

    That should do it

    19. April 27, 2006 09:19 AM

    Quote this comment

    Paula Posted…

    Help please? I want to run php on my iMac core duo, but can't get it to fly. I can turn on web sharing so that's okay, but when I un-comment the php lines in terminal I still can't run php. I want to run php5 but right now I'd be happy with 4.

    20. April 27, 2006 09:22 AM

    Quote this comment

    Paula Posted…

    Shoulda posted here sooner! By some miracle it just started working. I just turned sharing on and off a few times.

    21. June 6, 2006 06:38 PM

    Quote this comment

    Ed Posted…

    Did the trick for me - was driving me mad! Thanks ...