Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multi php.ini files in my system

Tags:

php

user-agent

I have Linux Ubuntu 10.10 and when i run the below in a terminal:

php -i | grep php.ini

I got the loaded Configuration File => /etc/php5/cli/php.ini

While if I use phpinfo() in the browser it will be:

Loaded Configuration File /etc/php5/apache2/php.ini

Which means that there are different ini files according to php_sapi_name!!

now the question is how can i set the same php.ini for all user agents (browser, cli, etc) without copying the same file to different locations!?

like image 538
Lina Avatar asked Feb 04 '11 21:02

Lina


People also ask

What is multi PHP ini Editor?

Bluehost cPanel's MultiPHP INI Editor allows you to make configuration changes to your PHP settings. This is along with MultiPHP Manager, which gives you a way to change the PHP version of your sites. This article will provide you information on how to edit php.

Where is the PHP ini file stored?

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. This file is located on your server in the /public_html folder.

Where are INI files located?

The INI file which contains the Program Options is stored in the user's Windows\application_data folder (something like C:\Users\pguth\AppData\Roaming\microdem\microdem. ini) .


2 Answers

I don't think setting all the different php contexts to use the same config is a good idea in the first place but if you really want to, you could just have one php.ini and all the others be symbolic links.

I don't think there is a way to change php's behavior as to which file it will include without at the very least recompiling it.

like image 89
Damp Avatar answered Sep 24 '22 11:09

Damp


sometimes you can have more than one php.ini to manage different interfaces or websites for example you can have different php.ini for each website you host on your server by setting PHPINIDir in your virtualhost as below

<VirtualHost 10.24.11.2:80>
ServerName foo.com
ServerAlias www.foo.com
PHPINIDir /var/www/html/foo
</VirtualHost>

however, if you like to make only one php.ini for all interfaces, the only way is to use symlinks as below:
ln -s /etc/php5/cli/php.ini /etc/php5/apache2/php.ini

like image 29
Alaa Avatar answered Sep 23 '22 11:09

Alaa