Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is possible to split PHP configuration file php.ini?

Anyone working with php knows that php.ini is a big file that may cause headaches when you need to change over ssh.

For example I can change nginx.conf using include directive to load all of the files under sites-enabled dir into the main nginx.conf.

So my question is straightforward: It's possible to do the same thing with php.ini ?

like image 521
adrian7 Avatar asked May 02 '12 13:05

adrian7


People also ask

What is PHP ini configuration file?

The php. ini file is the default configuration file for running applications that require PHP. It is used to control variables such as upload sizes, file timeouts, and resource limits. php. ini file is the configuration file.

How does PHP ini work?

ini file is a special file for PHP. It is where you declare changes to your PHP settings. The server is already configured with standard settings for PHP, which your site will use by default. Unless you need to change one or more settings, there is no need to create or modify a php.


1 Answers

If your PHP installation is setup to scan for .ini files you can drop several of them in a folder. If you installed PHP through the Ubuntu repos, it should already be configured this way.

My phpinfo() (note: The additional ini files are the result of installing php extensions from the repos and won't be included with PHP):

phpinfo with ini sections highlighted

The setting for this directory is a compile-time option:

--with-config-file-scan-dir=/etc/php5/apache2/conf.d

You can also set an environment variable through Apache:

SetEnv PHP_INI_SCAN_DIR /php/custom/scan/directory

More info @ ServerFault

like image 163
Mike B Avatar answered Sep 24 '22 05:09

Mike B