简体   繁体   中英

Apache 2.2 phpinfo() Configuration File (php.ini) Path doesn't match httpd.conf

I am trying to set up Apache to work with PHP. It seems to be working because I can run a file index.php from my "example" directory which is within htdocs in Apache. However, when I look at the Configuration File (php.ini) Path on the phpinfo() screen it does not match what I have in httpd.conf. Also, my modules that are turned on within my php.ini file are not set to enabled.

So I think it is not getting my php.ini. On the phpinfo() screen it says the Path is C:\\Windows.

In my httpd file in the conf directory of Apache I have this:

.
.
.
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule php5_module C:/php/php5apache2_2.dll
PHPIniDir "C:/php/"

All of these files exist. However this is not even a php.ini at C:\\Windows.

You may say that maybe my httpd.conf file isn't being read. However, if I change the php5_module line to something like

LoadModule php5_module C:/php/incorect.dll

Apache fails to start up. So this is being read. Just my php.ini isn't being read. Why? Thanks for the help!

EDIT: Also want to mention, on the phpinfo() screen, Loaded Configuration File is displaying as (none). Not sure what this is even talking about, but just some more insight to those of you who do.

Oh, and PHP version is 5.4.6.

EDIT 2: Windows Version: Windows 7 Professional Service Pack: Service Pack 1

Change:

PHPIniDir "C:/php/"

To:

PHPIniDir "C:/php"

Load module:

LoadModule php5_module "c:/php/php5apache2_2.dll"

Add PHP handler:

AddHandler application/x-httpd-php .php

Update directory index (optionally):

DirectoryIndex index.php index.html

Include "c:\\php" to the end of your Path variable.

SOLVED - Can't be forward slashes, have to be back. took

PHPIniDir "C:\srv\php5_4_8\"

I found a way to install it properly, on IIS 7:

Set IIS to allow 32-bits if you are on 64-bits

cscript %SYSTEMDRIVE%\\inetpub\\adminscripts\\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1

Set enviroment variables

PATH to, say, C:\\php\\

PHPRC to, that same dir

Go to Web Service Extensions: Add a new extension...

Name it for example php, and point it to the php5isapi.dll.

Set status to Allowed.

Right click Web Sites:

On the tab, ISAPI Filters, name it for example php, and point it to the php5isapi.dll

Then go to Home directory tab:

Click Configuration

On Mappings, click add:

Executable would be: php5isapi.dll Extension to: .php

Click OK, then OK.

Then on the tab Documents click Add:

and add there what you want to load as default, say index.php

Then stop, and start IIS.

This worked for me on a Windows 2003 Server, and WinXP 64.

I hope this works for you too.

My System: Windows with apache 2.2, php 5.3

Symptoms: PDO drivers not found.

What I found: phpinfo() showed that the php.ini file was "C:\\Windows" even though I expected it to be "C:\\Program Files (x86)\\PHP\\" as specified in my httpd.conf file in apache\\conf

Problem was with the PHPIniDir string in httpd.conf so the php.ini file I intended to use was not found.

FAILED:

PHPIniDir "C:\Program Files (x86)\PHP\"

WORKED:

PHPIniDir "C:\Program Files (x86)\PHP"
PHPIniDir "C:/Program Files (x86)/PHP"
PHPIniDir "C:/Program Files (x86)/PHP/"

NOTICE: the extra "\\" in the FAILED case. Remove it, save the conf file, and restart apache. Now phpinfo should show the php.ini file as coming from "C:\\Program Files (x86)\\PHP" and the PDO drivers had been loaded.

I was facing exactly the same issue.

In my case, the problem was that I had saved the php.ini file as a text file. As soon as I converted the text file to "All Files" in notepad and gave it the ".ini" extension, it became a "Configuration Settings File" and it worked.

(Working on Windows)

Since I am running Windows 7 (Apache 2.2 & PHP 5.2.17 & MySQL 5.0.51a), the syntax in the file "httpd.conf" (C:\\Program Files (x86)\\Apache Software Foundation\\Apache2.2\\conf\\httpd.conf) was very sensitive to slashes. I needed to change from

PHPIniDir 'c:\\PHP'

to

PHPIniDir 'c:\\PHP'

Pay the attention that the last slash disturbed everything!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM