code-8
code-8

Reputation: 58652

How to find which PHP.ini your Apache is using - Mac OS Mojave?

I am on a Mac OS X Mojave. I have no idea where is the correct php.ini that my Apache2 used.

I want to update the memory_limit.

I ran

php -r "phpinfo();" | grep php.ini   

I got

Configuration File (php.ini) Path => /usr/local/php5/lib                                                      
Loaded Configuration File => /usr/local/php5/lib/php.ini 

Then, I opened up /usr/local/php5/lib/php.ini

set memory_limit = 2G and restart apache sudo apachectl -k restart

re-attempt composer install

I kept getting

PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 20480 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleSetGenerator.php on line 126


php --version

PHP 7.1.4 (cli) (built: May  6 2017 10:02:00) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.4, Copyright (c) 1999-2017, by Zend Technologies

Upvotes: 2

Views: 3078

Answers (2)

frank_108
frank_108

Reputation: 719

I was looking for a default php.ini on Mac OS X Mojave.
There was only php.ini.default and no other php.ini.
I copied php.ini.default to php.ini, restart apache with:
sudo apachectl restart

Then was loaded /etc/php.ini and visible within the phpinfo, and php.ini can be edited.

Upvotes: 1

Alana Storm
Alana Storm

Reputation: 166066

Your command line PHP and your web-server based PHP are often configured differently.

Create a temporary webpage, and then run the phpinfo(); from there

#File: test.php
<?php
phpinfo();

Load the file via a web browser and you'll find your php.ini and any additional ini files listed there.

If you're seeing your memory when running PHP from the command line (your question is a little ambiguous there), then try running the following command

$ php --ini  

this will list every ini file used by your command line PHP. By bet would be one of those sets a memory limit that's overriding the one you're setting.

Upvotes: 5

Related Questions