105

I have recently got a mac an am not used to developing on a mac at all.

I have MAMP Pro 1.9.6.1. I did a locate on php.ini and got this:

$ locate php.ini
/Applications/MAMP/conf/php5.2/php.ini
/Applications/MAMP/conf/php5.3/php.ini
/Library/Application Support/appsolute/MAMP PRO/conf/php.ini
/private/etc/php.ini.default

I changed the name of all of them. Restarted MAMP. It loaded without a hitch (I know odd right?). I am using PHP version 5.2.

All of these files are now different names (done one by one for process of elimination). So I figure restart the mac. Same, MAMP loaded no problems, even though all of the php.ini files had been move. On Lamp this that wouldn't even load. But either there is another php.ini file I'm missing (quite possible I don't know how to updatedb), MAMP is really intelligent and just pulls in all of them (less likely) or it doesn't use one.

Florent
  • 12,310
  • 10
  • 49
  • 58
James Vince
  • 1,269
  • 3
  • 10
  • 12
  • 2
    MAMP Pro uses dynamic generated `php.ini`. You have to edit the template. – Florent Jul 27 '12 at 16:24
  • Ricardo Martins Should be the right answer James... – Jonathan Solorzano Dec 19 '15 at 09:05
  • 2
    I'm using MAMP 4 (free) and my php.ini path is `/Applications/MAMP/bin/php/php7.1.1/conf/php.ini` – Gavin Sep 26 '19 at 05:34
  • I have found php.ini file at /Applications/MAMP/bin/php/php8.0.0/conf/php.ini Note: Do not forget to restart apache is my made any changes in php.ini file, otherwise you will not get made changes updates on server. Thanks :) – Kamlesh Apr 28 '21 at 07:17

15 Answers15

149

Note: If this doesn't help, check below for Ricardo Martins' answer.


Create a PHP script with <?php phpinfo() ?> in it, run that from your browser, and look for the value Loaded Configuration File. This tells you which php.ini file PHP is using in the context of the web server.

Lucas
  • 16,930
  • 31
  • 110
  • 182
drew010
  • 68,777
  • 11
  • 134
  • 162
  • 7
    Its pulling from here /Library/Application Support/appsolute/MAMP PRO/conf/php.ini but it seams to reload it every startup – James Vince Jul 27 '12 at 16:30
  • That should be the file to edit to make changes then. Are you not seeing changes you make there? Then read this good historical article on developing on OSX ;) http://web.archive.org/web/20110331152508/http://teddziuba.com/2011/03/osx-unsuitable-web-development.html – drew010 Jul 27 '12 at 16:34
  • This is not very helpful actually as MAMP overwrites the file before server start. – Petr Peller Apr 13 '15 at 11:56
  • 4
    or you can even run `echo ''|php` from the terminal. – phyatt Aug 01 '15 at 20:19
  • 4
    Or just `php -i` (easier to read and shorter than `echo ''|php`). Note: sometimes the console version of php uses a different `php.ini` file and may have different settings than the CGI or Apache PHP. – drew010 Jan 17 '16 at 08:37
  • 5
    on the mamp panel at localhost you can just click php.info from the menu – Alex Borsody Jul 22 '16 at 11:46
  • 1
    Needs server restart to apply php.ini changes. – Krzysztof Przygoda Oct 31 '16 at 15:14
  • I had to restart MAMP app, not just the servers to apply, anyway phpInfo is in main menu of WebStart page, there is the place I have copied the path to active php.ini.. happy coding :) – Luckylooke Dec 14 '17 at 10:12
  • I've followed all these steps, none of them worked for me In my phpinfo page I can see the updated values, but my laravel application still throws error the file "Intro01.mp4" exceeds your upload_max_filesize ini directive (limit is 2048 KiB). I use php verison 7.2.8 /Applications/MAMP/bin/php/php7.2.8/conf/php.ini -- this is the url as given to me by my phpinfo page Now I'm confused, what is wrong? – Pianistprogrammer Feb 27 '20 at 07:18
  • I did not have a `php.ini` in the location described in `info.php`, but two templates as `php.ini-dev` and `-prod`. I had to create a `php.ini` at the same location using these and I did so. Now it works! – Bedir Yilmaz Sep 28 '21 at 13:55
78

I'm not sure if in MAMP (non-PRO) is the same, but MAMP overrides the modified php.ini everytime it starts.

In my case, I needed to use the MAMP menu to change my php.ini file (File -> Edit Template -> PHP -> PHP 5.xx -> php.ini).

Ricardo Martins
  • 5,702
  • 3
  • 40
  • 59
39

To be clearer (as i read this thread but didn't SEE the solution, also if it was here!), I have the same problem and found the cause: I were modifying the wrong php.ini!

Yes, there are 2 php.ini files in MAMP:

  1. Applications/MAMP/conf/php5.5.10/php.ini
  2. Applications/MAMP/bin/php/php5.5.10/conf/php.ini

The right php.ini file is the second: Applications/MAMP/bin/php/php5.5.10/conf/php.ini

To prove this, create a .php file (call it as you like, for example "info.php") and put into it a simple phpinfo()

<?php
echo phpinfo();

Open it in your browser and search for "Loaded Configuration File": mine is "/Applications/MAMP/bin/php/php5.5.10/conf/php.ini"

The error was here; i edited Applications/MAMP/conf/php5.5.10/php.ini but this is the wrong file to modify! Infact, the right php.ini file is the one in the bin directory.

Take care of this so small difference that caused me literally 1 and a half hours of headaches!

Aerendir
  • 6,152
  • 9
  • 55
  • 108
  • The exact directory depends on which PHP version you are using, but yeah, that path (../MAMP/bin/php/phpX/conf/php.ini) is correct. I also edited the php.ini.temp file just in case. Set display_errors = On in both cases. – Jason Engage Nov 22 '16 at 13:19
  • This is the answer I needed since I do not have the Pro version. – Dreadnought Mar 11 '19 at 22:20
  • MAMP 5 doesn't have conf folders in the bin/php folders anymore. – sk904861 May 06 '22 at 11:03
22

The file you have to edit is in MAMP Pro and uses the php.ini file everytime it starts up.

  • Start MAMP PRO
  • Edit File > Edit Templates > PHP 5.3.2 php.ini
  • Restart MAMP Pro

Your changes should stick.

DᴀʀᴛʜVᴀᴅᴇʀ
  • 7,681
  • 17
  • 73
  • 127
tim
  • 221
  • 2
  • 2
9

I don't know if you ever found an answer to this but I DIDN'T need MAMP PRO to do this. Simply goto the correct path by following what others have said. It's something like...

MAMP-> bin-> php-> php(your php version)-> conf-> php.ini

The key here is where you're editing the file. I was making the mistake of editing the commented part of the ini file. You actually have to scroll down to LINE #472 where it says "display_errors = Off and change it to On. Hope this helps any

Jonathan Disla
  • 127
  • 1
  • 6
6

Just run the following command from your terminal, it will show you your Loaded Configuration File easiest way I have ever found.

php --ini
zarpio
  • 10,380
  • 8
  • 58
  • 71
2

Change /Applications/MAMP/conf/php5.2/php.ini if you are using 5.2 version of php. If you are using the 5.3 php version, edit the /Applications/MAMP/conf/php5.3/php.ini.

If you are using OSX Lion or OSX Mountain Lion, I recommend you using the default installation of apache and php.

Greets!

nicowernli
  • 3,250
  • 22
  • 37
  • I think MAMP is a better option than the default because it includes multiple versions of PHP as well as a few precompiled [PHP Accelerators](http://en.wikipedia.org/wiki/PHP_accelerator). Apple has kindly [removed the Web Sharing preference](http://support.apple.com/kb/HT5230?viewlocale=en_US) in Mountain Lion :(. Also note that the MAMP 2.x paths for PHP include the minor version (eg `MAMP/conf/php5.4.3`). – Stennie Jul 29 '12 at 01:31
2

After running the MAMP server, you have php info link in toolbar Once click, You will get all information about php enter image description here

Manikandan
  • 844
  • 15
  • 31
1

It depends on which version of PHP your MAMP is using. You can find it out on: /Applications/MAMP/conf/apache/httpd.conf looking for the configured php5_module.

After that, as someone said before, you have to go to the bin folder. There you'll find a conf folder with a php.ini inside.

example: /Applications/MAMP/bin/php/php5.4.10/conf

Leo

leopinzon
  • 707
  • 6
  • 13
1

Probably the fastest way to access the PHP.ini for the currently loaded version of PHP in MAMP PRO (v.4.2.1):

  1. Open MAMP Pro
  2. Click on "PHP" under the "Languages" section on the sidebar
  3. Tap on the arrow button right next to the drop-down that lets you select the "Default Version" of PHP.
Panos Spiliotis
  • 801
  • 1
  • 9
  • 18
1

After going through all the solutions here, the easiest way to find the loaded php.ini file is to go into phpinfo on the loaded MAMP webpage, which will show you the loaded php.ini file.

This will also confirm if the parameters you change, like max_file_size, have updated correctly.

s89_
  • 1,533
  • 3
  • 25
  • 40
1

On my Mac, running MAMP I have a few locations that would be the likely php.ini, so I edited the memory_limit to different values in the 2 suspected files, to test which one effected the actual MAMP PHP INFO page details.
By doing that I was able to determine that this was the correct php.ini:

/Applications/MAMP/bin/php/php7.2.10/conf/php.ini
Alessio Cantarella
  • 5,077
  • 3
  • 27
  • 34
Auxiliary Joel
  • 173
  • 1
  • 13
0

I only have the non-pro version of MAMP but just because it loads it doesn't mean the PHP file is being found/without errors.

I renamed my php.ini files and MAMP still started but Apache returned several errors.

What are you trying to change in your php.ini file?

Eugene
  • 4,829
  • 1
  • 24
  • 49
soulston
  • 147
  • 1
  • 4
0

I have checked all answers and of course I have used phpinfo() to check the exact location of php.ini. I don't see a File option in the menu bar on my mac. I changed both php.ini and php.ini.temp files in that folder. No vail.

Until I realized that I forgot to uncomment the modified always_populate_raw_post_data line.

Michael Shang
  • 686
  • 8
  • 9
0

I was struggling with this too. My changes weren't being reflected in phpInfo. It wasn't until I stopped my servers and then restarted them again that my changes actually took effect.

Trethewey
  • 36
  • 1