MAMP

How to enable and setup php.ini on a Mac with OSX 10.8 + (MAMP Part 4)

How to enable and setup php.ini on a Mac with OSX 10.8 + (MAMP Part 4)

Welcome to part 4 of the MAMP tutorial. In this post we will go over setting up php.ini on your Mac’s localhost.

What green means: any lines that you need to replace in this tutorial will be in green.


1. Enable the php.ini file:

1. Using Terminal, copy the existing php.ini.default and rename it to php.ini

sudo cp /etc/php.ini.default /etc/php.ini

2. Open php.ini in nano in your terminal for editing

sudo nano /etc/php.ini

2. Enable php short tags:

A php script with short tags will not run on your server unless php short tags are enabled.

1. Hold ctrl + w to do a string search. Type “short_open_tag” to find the line. (You may need to search a couple times)

short_open_tag = Off

2. Replace it with

short_open_tag = On

3. Disable detect_unicode:

detect_unicode is a deprecated feature and will be disabled in the future. But for now we need to disable it so it doesn’t cause us problems.

1. Go to the very end of the php.ini file (still open in nano) and add the following line to the end of the file. It doesn’t exist yet.

detect_unicode = Off

4. Set the timezone:

1. Hold ctrl + w to do a string search. Type “date.timezone” to find it.

replace

;date.timezone =

with

date.timezone = UTC

UTC tells the server to use your local timezone.

Save the file and exit. and congrats. You are done!


Part 1: How to install Apache and PHP on a Mac with OSX 10.8 + (MAMP Part 1)

Part 2: How to setup MySQL on a Mac with OSX 10.8 + (MAMP Part 2)

Part 3. How to setup phpMyAdmin on a Mac with OSX 10.8 + (MAMP Part 3)

Part 5: How to host multiple sites on your Mac (MAMP Part 5)

Published by Jonathan Whiting

I enjoy sharing what I am learning and hopefully it's of interest and help to you. I live in Canada with my wife. Follow me on Twitter.

44 comments on “How to enable and setup php.ini on a Mac with OSX 10.8 + (MAMP Part 4)”

  1. Thanks for the tutorial Jonathan 🙂

    1. Jonathan Whiting says:

      You’re welcome Zain!

  2. Matt says:

    Thank Jonathan, all your work is amazing.

    I want to upload large files using my phpMyAdmin… but it wont accept large files. Is there a way to edit the php.ini file that the phpMyAdmin is using to accept large files?

    post_max_size=20M
    upload_max_filesize=20M
    max_execution_time = 300

    I tried to change these in the /etc/php.ini but they were denied.

    1. Jonathan Whiting says:

      Hi Matt, Just to confirm did you restart apache after the update?

      1. Matthew says:

        Yes thank you,
        That was my issue. It needed a restart!

        1. Jonathan Whiting says:

          Awesome, I’ve done that before. Updated my settings, scratched my head and then remembered it needed to be restarted.

  3. Thank you Jonathan. You saved my day. Much love from Jakarta! xoxo

    1. Jonathan Whiting says:

      Hi Tia, happy it worked out for you!

  4. Haendel says:

    Very nice tutorial!!!

    1. Jonathan Whiting says:

      Thanks Haendel

  5. itp26 says:

    thank you from Japan for your running posts! very helpful.

    1. Jonathan Whiting says:

      Hi from Canada, I’m happy it helped you

  6. javkhaa says:

    Nice, It’s very helpful

  7. Jeff Kahn says:

    Very nicely done. Very informative.

    1. Jonathan Whiting says:

      Thanks Jeff

  8. AJ says:

    Wow. That was pretty straightforward. Very nicely done. Whew!

    Thank you so much for making this available.

  9. Steven says:

    It would be nice if you could of explained better. Many users are new to commands and you don’t even tell us how to save this file. Now I’m left with a mess Thanks

    1. Jonathan Whiting says:

      Hi Steven, thanks for your feedback. I will try to make future tutorials easier to follow. Let me know if there was any specific commands that you would like explained?

  10. Vasko says:

    Also I forgot to write that I followed these tuts on my 10.9 OSX worked great to easy!

  11. Vasko says:

    Thank you Jonathan your tuts are faultless! you saved me time & a head ache as I’m a student in web development and very new to this world of programming. Cheers 🙂

    1. Jonathan Whiting says:

      Just glad it helped out 🙂

  12. Jiminsrq says:

    I’ve followed your instructions and when I try to log into I get ” #1045 Cannot log in to the MySQL server”
    the config.inc.php file is located here: “/Users/jim/Sites/phpMyAdmin”
    the contents of the config.inc.php are:

    ANY help or guidance you can provide is appreciated

    1. Jonathan Whiting says:

      Hi Jiminsrq,

      You may need to change your host credentials from “localhost” to “127.0.0.1”

      Let me know if that helped?

  13. Hi,

    Thank you for this great series of articles. It has been very helpful. I think MAMP is a nice solution for beginners but after a while, they’ll look for this kind of native solutions.

    Kind regards,
    Kubilay

    1. Jonathan Whiting says:

      Hi Kubilay, glad you found it useful and I couldn’t agree more. Mamp.info is a great solution to get started, but there are PHP packages that are required for some projects that don’t integrate nicely with it. Having a clean localhost setup is the way to go.

  14. Sua says:

    Ah this is THE tutorial that I didn’t have any trouble following it.
    Many Thanks!

    1. Jonathan Whiting says:

      Glad you found it helpful

  15. Harlan says:

    Jonathan

    Great tutorial – much appreciated!

    1. Jonathan Whiting says:

      Thanks

  16. Moissane says:

    Very helpful, thanks a lot…I could finish my task.

    1. Jonathan Whiting says:

      No problem 🙂

  17. Fernando says:

    Hello, I am going crazy with my mac because I am newbie with this system and I have discovered to differentes php.ini. One in my localhost with MAMP and other with my “internal” server. I am programming with Symfony and I need to write console command that they don’t work and my web application yes. How can i configure to set the same php.ini? Thanks in advance

    1. Jonathan Whiting says:

      I am sorry, but I don’t not understand your question? The php.ini setup will handle your mac’s server. There should only be one file running your mac’s Apache server.

  18. Manan Shah says:

    Thanks for this tutorial. After hours searching internet and doing all weird I was able to setup the configuration. Can you please put up permissions tutorial on Sites folder. for eg joomla installation creates the configuration file through web and ask for deletion of the installation folder also. I wanted to know what would be ideal permission set in Sites folder.

    Thanks in advance.

    1. Jonathan Whiting says:

      I will do

  19. Edward C says:

    Jonathan, I am running PHP version 5.3.15 and when I run phpinfo() on MAC OS X 10.8.4, it shows that my display_errors is OFF for both local and Master values. How do I change these values to ON? Any assistance would be greatly appreciated. I am new to the MAC world…I know how to change the php.ini file in windows but I am running MAC.

    Thanks

  20. Nicolas Mertens says:

    Ok, I just did all this, many thanks…! However I don’t know why I did all these little things. Perhaps you could update the tutorials some time with comments (color orange or so) to each step on why we are doing things and learn from this…

    1. Jonathan Whiting says:

      Thanks, glad it helped. I try to make these tutorials easy to follow, those explanations make sense to add.

  21. Edward says:

    Jonathan, Followed your instruction and thanks for your assistance. One quick question, since I converted from Windows to Mac. In Windows, we are told to change the “SMTP = localhost” to our outgoing mail server and to change “sendmail_from = [email protected]” to your email address. I noticed that in your instructions, you don’t mention this. Do I need to change those two lines to test mail applications on my local computer? Any assistance would be greatly appreciated. Thanks, Edward

    1. Jonathan Whiting says:

      It’s pretty straightforward to enable it. Just need to update a few config files. I will write a post with some instructions.

    2. Jonathan Whiting says:

      It’s not as straightforward as I first thought. As of 10.8 there are a bunch of changes that Apple made. I am documenting my progress and will post how I got it working, hopefully by tomorrow.

      1. Prabhu Konchada says:

        I am unable to loacte the default php.ini for php 5.3.15 that comes with mac to enable display errors and as I configured MAMP I could not configure php 5.4.10 or greater that comes with MAMP please help me

        1. Jonathan Whiting says:

          Hi Prabhu, the default php.ini file should be located at the following path. /etc/php.ini.default

Leave a Reply

Your email address will not be published. Required fields are marked *