PHP Find php.ini and edit configuration settings from command line

Manipulating the PHP ini file from the command line is really quite straight forward.

To get yourself started on the command line, just ask PHP for help like this:

pauL ⨊ $ php -help

You’ll see a list of options and arguments.

From the php help output one can see that the -i option will show what amounts to the contents of the phpinfo() function.

By piping this output through grep, we can filter for the php.ini file and figure out where the file is.

pauL ⨊ $ php -i | grep "php.ini"
Configuration File (php.ini) Path => /usr/local/php5/lib
Loaded Configuration File => /usr/local/php5/lib/php.ini

With this information one can use the -d flag to alter php.ini setting from the command line as well.

pauL ⨊ $ php -c /usr/local/php5/lib/php.ini -d memory_limit=256M

 

Posted in

Leave a Reply

Your email address will not be published.