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

35,458

Solution 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.

Solution 2

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

PHPIniDir "C:\srv\php5_4_8\"
Share:
35,458
user1513171
Author by

user1513171

Updated on April 16, 2020

Comments

  • user1513171
    user1513171 about 4 years

    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

  • Edward Ruchevits
    Edward Ruchevits over 11 years
    It's strange. Have you restarted httpd after that? Try to reboot your system as well.
  • user1513171
    user1513171 over 11 years
    Restart httpd? I restart Apache. I can try a system reboot too though.
  • Edward Ruchevits
    Edward Ruchevits over 11 years
    Yes, httpd that's your Apache HTTP Server. How you installed Apache and how you start it? As a Windows service or by running binary?
  • user1513171
    user1513171 over 11 years
    I start it as a Windows Service. Installed it using the .msi installer or whatever you call it. I am on my old comp right now my compi I'm having these problems on is going through some stupid Windows updates right now upon restarting, but I checked my php.ini here with phpinfo() and it IS suppose to actually be C:\Windows for Configuration File path, but the other one, the one that is showing (none) for me SHOULD say C:/php/php.ini. So that's the problem I'm at now. And the system restart didn't help the problem, still (none) for Loaded Configuration file.
  • Edward Ruchevits
    Edward Ruchevits over 11 years
    Could you please tell your Windows version and service pack as well? Include all that information in your question.
  • user1513171
    user1513171 over 11 years
    Wait, AddHandler, I had AddType with that but not AddHandler, are they the same thing? Well I added it and didn't make a difference anyway.
  • Rommel Castro
    Rommel Castro about 10 years
    you saved my life, removing the "/" from the PHPIniDir fixed the problem on my server, thank you for this, i really really appreciate
  • readikus
    readikus almost 10 years
    Umm - they're both the same
  • sthiago
    sthiago over 8 years
    you saved my life [2], I needed to add the php.exe directory to the environment PATH
  • VimLeSai
    VimLeSai about 4 years
    what if i'm using php's 7.4 version should php5_modules be php7_modules in LoadModule php5_module "c:/php/php5apache2_2.dll".
  • nxasdf
    nxasdf about 2 years
    I've been hunting high and low for my PHP extensions not getting loaded with Apache, but CLI worked fine. It was all because PHPIniDir was missing from my httpd.conf, argh what a headache and many hours lost just because of this one line that should have a default value within PHP. Thank you.