Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change php.ini location

Is it possible to change the location of php.ini to be used by Apache? When I did php -i | grep 'Configuration File', the result is:

Path => /usr/local/etc

Loaded Configuration File => /usr/local/etc/php.ini

But the result of phpinfo() is

Configuration File (php.ini) Path : /etc

I can copy over php.ini from /usr/local/etc/ to /etc/, but is it possible to change the php.ini folder?

I installed PHP using homebrew and I am using OS X Snow Leopard.

like image 388
Zendy Avatar asked Apr 30 '12 15:04

Zendy


People also ask

Where is the PHP ini file located?

user. 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 is PHP ini in file manager?

ini file is located at /usr/local/lib/php. ini.

Where PHP ini file is located in Ubuntu?

The default location for the php. ini file is: Ubuntu 16.04: /etc/php/7.0/apache2. CentOS 7: /etc/php.


2 Answers

PHP uses different .ini files when running via command line vs running as a web server module. When you grep the results of php -i your getting the command line ini. It's good practice to have separate ini's for the two environments.

If you must change the directory PHP looks for the php.ini file, you can use the PHPIniDir in your web server conf file.

If you wish to just add additional directories to be scanned, you can set the PHP_INI_SCAN_DIR environment variable.

like image 97
webbiedave Avatar answered Sep 22 '22 14:09

webbiedave


To Change php.ini file path we have to declare PHPINIDir in the apache configuration file 'httpd.conf' syntax for that is :

PHPINIDir "path_to_ini_file";
like image 34
Ganesh Patil Avatar answered Sep 21 '22 14:09

Ganesh Patil