'How to change the default xampp php.ini directory

The php.ini file in xampp is located here: C:\Windows for php.ini

The phpinfo contains this information:

Configuration File (php.ini) Path C:\WINDOWS

Loaded Configuration File (none)

Scan this dir for additional .ini files (none)

How can i change the directory?



Solution 1:[1]

open this file "\xampp\apache\conf\extra\httpd-xampp.conf"

find this block

PHPINIDir "C:/xampp/php"

change the directory

Solution 2:[2]

From my experience using XAMPP, it's better to put the php.ini file where XAMPP expects it to be by default. Typically XAMPP is going to look under its own dir. For Windows, it would look like, or similar to, this: [yourdrive_letter]:\xampp\php\php.ini . That's what should be showing up in your Loaded Configuration File setting. I always ignore whatever it says in Configuration File (php.ini) Path, because that's not really the ini that xampp is using. Go look under your xampp directory and find the "php" folder. If it's not there, then it needs to be (unless you've somehow configured xampp to look elsewhere). So find the PHP folder you want to use and put it under the xampp folder. The version of xampp I have does not allow for switching php versions/folders "on the fly", so the folder MUST BE named "php". (Yeah, I've tried having two php folders with different names and just swapping them out -- that doesn't work well in xampp).

Solution 3:[3]

I don't see where I was telling you to edit anything under the Windows directory. If you can't copy the php.ini for some reason, then you can use the template for it provided by XAMPP and change it to your needs. You asked how to change the directory for your php.ini and your subject was about XAMPP so I assumed you have an XAMPP directory somewhere and knew how to configure it -- my bad. Most installation directions I've seen for XAMPP tell you to put it in C:\xampp. If you have it under a Windows directory, then you have my sympathy. If you DO have a C:\XAMPP, I'm simply saying to find a directory called PHP under THAT folder, and then configure your XAMPP to use the php.ini under C:\xampp\php. Under your 'config' option for Apache, you should see a file option called 'httpd-xampp.conf'. Select that to edit it; there should be a module called <IfModule php5_module> in there. Under that is your PHPINIDir directive. Change whatever path it's pointing at to "C:/xampp/php". Add the closing tag (</IfModule>). Restart Apache. (You may have to stop Apache before editing this file). If your XAMPP is in your Documents directory for some reason, then it's just a matter of changing the paths in this answer. I wouldn't put it there personally, but it seems your network people have you kind of locked down. Sorry if my previous answer was unhelpful.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Neeraj Agrawal
Solution 2 McAuley
Solution 3