Categories
MAMP PHP Tutorials

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)

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 replies on “How to enable and setup php.ini on a Mac with OSX 10.8 + (MAMP Part 4)”

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.

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

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

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?

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 🙂

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

Hi Jiminsrq,

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

Let me know if that helped?

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

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.

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

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.

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.

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

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…

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

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

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

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.

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

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.