geckob
geckob

Reputation: 8130

memory_limit return different values in php5-cli and browser

I am writing a script that requires me to get all php configuration. But I stumble an issue and inconsistencies when I run the ini_get_all() in the browser and using php5-cli. Here is my code snippet:

$confiq = ini_get_all();
echo $config['memory_limit']['local_value'];

It return 128M when I run using browsers, but it return -1 when I run using php5-cli from the command line

EDIT: It turned out they are using two different php.ini files. I checked the cli .ini with php --ini command. Now I need to figure out how to change the location for .ini file for cli

EDIT: For the easy hack, I created symbolic links to the apache2 php.ini to make sure both using the same php.ini.

Upvotes: 3

Views: 205

Answers (1)

Harikrishnan
Harikrishnan

Reputation: 9979

There are two different php.ini files.

/etc/php5/apache2/php.ini for web and /etc/php5/cli/php.ini for command line.

You need to edit corresponding ini file according to the context. If you need the same ini value in both cli and web, obviously you need to edit both. Also don't forget to restart apache (service apache2 restart) after editing ini files to see the changes.

Upvotes: 2

Related Questions