PHPINIDIR ignored in W7 Apache (WampServer)

SAbboushi
SAbboushi used Ask the Experts™
on
I want Apache to load my php.ini file from a folder on my d: drive.

C:\wamp\bin\apache\Apache2.2.21\conf\httpd.conf
...
ServerRoot "c:/wamp/bin/apache/apache2.2.21"

PHPIniDir "d:\documents\Application Data\PHP\"
...

Open in new window


Restarting all services with the WampServer system tray icon displays a Green "W" with the above PHPIniDir statement.  But http://localhost/?phpinfo=1 shows:

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

Loaded Configuration File: C:\wamp\bin\apache\Apache2.2.21\bin\php.ini


Tried other options, but didn't work either:

PHPIniDir "d:\documents\Application Data\PHP"

Open in new window

(no final "\") results in an orange "W" and http://localhost/?phpinfo=1 shows "Internet Explorer cannot display the webpage"

Same with:
PHPIniDir "d:/documents/Application Data/PHP/"

Open in new window

and
PHPIniDir "d:/documents/Application Data/PHP"

Open in new window


How can I get Apache to use d:\documents\Application Data\PHP\php.ini?

Thanks-
Sam

W7 64, IE9
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
Make sure that your permissions in that directory allow Apache to access it.  "Everyone" might work but you can look at the permissions in the original location to see how they are set.  "d:\documents\Application Data\" sounds like it would be for a specific user and you might not be able to set permissions to allow it.  Another issue is that the path has a space in it in "Application Data" and quite a number of programs that have come from Unix or Linux do not like that.

I am wondering why you want to do this when it works fine where it is originally located.

Author

Commented:
Thanks for your response--

>>you might not be able to set permissions to allow it.  
Permissions are the same for both folders

>>Another issue is that the path has a space in it
Good idea - but eliminating the space had no effect

>>I am wondering why you want to do this when it works fine where it is originally located.
Backup/restore and system partition imaging
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
Try creating a new folder like D:\wampdata and put it there.  See if Apache will find it there.
11/26 Forrester Webinar: Savings for Enterprise

How can your organization benefit from savings just by replacing your legacy backup solutions with Acronis' #CyberProtection? Join Forrester's Joe Branca and Ryan Davis from Acronis live as they explain how you can too.

Author

Commented:
Copied the bin folder containing the php.ini from the original location and changed php.ini to:

 PHPIniDir "d:\bin\"

Restarted services.  No effect...

I went through this same problem with IIS and it took over a year before I figured out I also had to make a change to an internal environment variable for php-cgi.exe...

Hoping to figure this out a little sooner this time!
Fixer of Problems
Most Valuable Expert 2014
Commented:
I hadn't looked at my WAMP setup in while.  But I just did and I realized why you won't be able to do this.  One of the purposes of WAMP is to enable you to switch versions of PHP, MySQL, and Apache.  To enable that, wampmanager or some part of it will force the 'php.ini' in the current Apache directory to be used.  And if you added versions of Apache, you would find another copy of 'php.ini' in the new Apache directories.

If you had a standard install of Apache and PHP, you would be able to change the location of 'php.ini' because nothing would be resetting it.  As it is, WAMP is probably not going to allow you to do what you want.

Author

Commented:
k thanks for your help.
with regards-
Sam

Author

Commented:
Success!!

Create a System Environment variable "PHPRC" with the value "D:\Documents\Application Data\PHP", restart all services, and phpinfo() shows:

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

Loaded Configuration File: D:\Documents\Application Data\PHP\php.ini

This didn't work with IIS so I didn't bother to try it until now on Apache...
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
Good for you.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial