You are here: Home / Debian GNU/Linux / Servers / PHP / Manage PHP ini options from command line on Debian

Manage PHP ini options from command line on Debian

by Pierre-Yves Landuré last modified Nov 15, 2017 06:43

Memory limit, upload limit, quote management, ... are PHP configuration options which change is asked by various Web applications. This howto setup a command line script to ease the management of PHP configuration changes.

This howto is tested on:

  • Debian 6.0 Squeeze
  • Debian 7.0 Wheezy

Prerequisite

This howto recommends:

Installation

Install the needed software :

command apt-get install php5-cli

Install the php-tools script :

command wget 'https://raw.github.com/biapy/howto.biapy.com/master/php5/php-tools' \
    --quiet --no-check-certificate --output-document='/usr/local/bin/php-tools'
command chmod +x '/usr/local/bin/php-tools'

Usage

Get PHP option current value :

# command php-tools --get 'post_max_size'

Analyse PHP option settings across ini files :

# command php-tools --analyze 'post_max_size'

Force the value of a PHP option (here, post_max_size is forced to 5 Mb) :

# command php-tools --fix 'post_max_size' '5M'

Raise the value of a PHP option, if needed (here, raise post_max_size to 10Mb if existing value is lower) :

# command php-tools --set 'post_max_size' '10M'

The settings done with php-tools script are stored in "/etc/php5/conf.d/zzz-php-tools.ini".