Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

memory_limit return different values in php5-cli and browser

Tags:

php

php-ini

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.

like image 595
geckob Avatar asked Dec 06 '25 05:12

geckob


1 Answers

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.

like image 132
Harikrishnan Avatar answered Dec 08 '25 19:12

Harikrishnan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!