Brett
Brett

Reputation: 20079

PHP not using custom php.ini file

I have done this before so I'm not sure why it's not working, but I am trying to create a custom php.ini file and I have placed this within a specific directory.

For example, the default php.ini is located at:

C:\xampp\php\php.ini 

My custom one is located at:

D:\Codebase\Somedir\123\php.ini

I placed a PHP file inside the above directory and did output with phpinfo() and it still reports it as using C:\xampp\php\php.ini.

I have restarted Apache as well.

What am I doing wrong here!?

Upvotes: 0

Views: 1708

Answers (2)

João Josézinho
João Josézinho

Reputation: 2728

If you're using XAMPP you can change the configuration file it loads PHP with by opening the properties.ini file in the

C:\xamp 

directory and editing the php_configuration_directory field to

D:\Codebase\Somedir\123\

Then restart apache for the changes to take effect.

If PHP is running as an apache module you could also edit httpd.conf on your apache setup and add this variable:

PHPIniDir "D:\Codebase\Somedir\123\" 

Upvotes: 0

Anthony Garcia-Labiad
Anthony Garcia-Labiad

Reputation: 3721

You can see which php.ini file is loaded running php.exe --ini. On my computer it output:

Configuration File (php.ini) Path: C:\WINDOWS
Loaded Configuration File:         C:\tools\php\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

If it is the wrong php.ini there, have a look to http://php.net/configuration.file

Upvotes: 1

Related Questions