PHPIniDir broken under windows 7?
Asked Answered
E

7

8

I had a server running on a Windows XP machine using Apache2 with PHP and MySQL. I've recently upgraded to Windows 7 and have been having trouble getting it to work. Apache works fine and PHP works, but I can't seem to get it to work with a php.ini file.

When I set PHPIniDir to a directory with a php.ini file, the Apache service does NOT start.

When I set PHPIniDir to a directory with NO php.ini file, the Apache service does start.

When I leave out PHPIniDir, the Apache service does not start.

Has anyone found a fix for this problem? Thanks!

EDIT :

PHPIniDir "C:\Windows" #works (no php.ini file)

PHPIniDir "C:\Program Files (x86)\php\" #does not work (contains php.ini file)

I enable at most one at any given time.

Exhaustion answered 16/12, 2009 at 5:47 Comment(2)
Can you post the configuration directives that work and don't work ? Do you have any error in Apache's logs ?Submariner
D:\Apache24\bin>httpd.exe -d D:/Apache24 AH00526: Syntax error on line 517 of D:/Apache24/conf/httpd.conf: Invalid command 'PHPIniDir', perhaps misspelled or defined by a module not included in the server configurationCladoceran
C
5

I had the same problem. I fixed it. Open php.ini file with a notepad or any text editor. Disable all of the extension in php.ini file. Comment extensions by one by, and find out which extension causes the problem.

Cockfight answered 1/6, 2010 at 7:25 Comment(0)
S
10

delete last slash:

PHPIniDir "C:\Program Files (x86)\php"
Snap answered 9/2, 2012 at 16:19 Comment(1)
Bitten again by a trailing backslash in httpd.conf..., thanksGearing
C
5

I had the same problem. I fixed it. Open php.ini file with a notepad or any text editor. Disable all of the extension in php.ini file. Comment extensions by one by, and find out which extension causes the problem.

Cockfight answered 1/6, 2010 at 7:25 Comment(0)
R
3

There are several reasons:

  • Old version of Apache and/or PHP. Apache 2.2.13/2.2.14 seem to work fine in Windows 7, as well as PHP 5.2.11/5.3.
  • Some of PHP extensions may cause the Apache startup failure. You may either check Apache's log files or enable 'display_startup_errors' in php.ini (when it's enabled you may use ApacheMonitor.exe to start or stop the Apache service, and if an error occurs, it'll display a message). You may also disable all PHP extensions and if it helps start enabling them one by one and see which one is causing the problem.
  • Imho, make sure you've downloaded an archive of PHP and didn't use the automated installer. In my experience, installers never worked well. You can always add two PHP-related directives (PHPIniDir and LoadModule) into Apache's config file and make sure PHP dir is included in Windows' path. Oh, and service error may also be caused by php2apache library.
  • Check if Apache/PHP/MySQL directories are included into Windows' path. Here is a good utility to do that: Redmond Path. You may add the following directories into the path: Apache/bin dir, PHP dir, MySQL/bin dir. It might help.
Restrict answered 16/12, 2009 at 8:1 Comment(12)
I've tried enabling errors, but continue to get the same error - "The requested operation has failed!"Exhaustion
There is a section at the end of php.ini with what appear to be extensions. They look like this: [PHP_BZ2] extension=php_bz2.dll [PHP_CURL] extension=php_curl.dll When they are all commented out, apache starts fine. Any idea why this is?Exhaustion
After some more testing, it seems i can enable extensions but there is some sort of limit, i think by total extension size?Exhaustion
Ok, so it's caused by some PHP extension. Have you figured out which one exactly? There is no need to enable all extensions at once. Just try to enable the ones you need, one by one, so you know which one is failing. Could you also check the value of "extension_dir" in php.ini?Restrict
Oh, and would you specify the versions of Apache and PHP you've installed?Restrict
Ok. This is exactly what I have. Two more things. Have you tested the Apache's configuration file? (Start -> All Programs -> Apache HTTP Server -> Configure Apache Server -> Test Configuration). It should say "Syntax OK". Could you also check if there is anything in error.log file? (ApacheDir/logs/error.log, in case you didn't change the error.log path).Restrict
The test says "Syntax ok" like you said. The log has no errors, however, I do get the following warnings when it fails.[warn] (OS 995)The I/O operation has been aborted because of either a thread exit or an application request. : winnt_accept: Asynchronous AcceptEx failed. [warn] pid file C:/Program Files (x86)/Apache Software Foundation/Apache2.2/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?Exhaustion
Uh oh, maybe this will help: brooks-bilson.com/blogs/rob/index.cfm/2008/1/4/…Restrict
that did not help. The id warning seems to be the more prevalent one.Exhaustion
Maybe it's caused by firewall or another application that's using the same port as Apache? I've just managed to crash Apache by Skype (Tools -> Options -> Advanced -> Connection -> Use port 80 and 443...), I've actually turned it off before right after installation, but when it's turned back the same error occurs("The requested operation has failed!"), though Apache doesn't write anything into the log file.Restrict
If it's not caused by firewall/Skype you may try these things: #1 Replace PHP installation with this one: php.net/get/php-5.2.11-Win32.zip/from/a/mirror. #2 Make sure that both Apache and PHP are included into Windows' path. If both of these things doesn't work out then try to move both Apache and PHP out from Program Files directory into the root (say C:\Apache and C:\PHP), just try to use some path without whitespaces, it helps sometimes.Restrict
#1 seems to have fixed it. the only difference i see is that the new version has far fewer extensions so my guess is one or more of the extensions were breaking something. Thank You!Exhaustion
B
2

I had the same problem, you have to specify the full URL for the PHP module in the httpd.conf.

All of the guides that I have found said to put the following:

PHPIniDir "C:/Program Files/PHP"
LoadModule php5_module "php5apache2_2.dll"

When in actual fact you need:

PHPIniDir "C:/Program Files/PHP"
LoadModule php5_module "C:/Program Files/PHP/php5apache2_2.dll"
Bojorquez answered 1/3, 2011 at 10:41 Comment(0)
P
1

I was never able to get beyond this line:

LoadModule php5_module "C:/Program Files (x86)/PHP/php5apache2_2.dll"

So finally in desperation I created a new folder C:/PHP, copied that dll into C:/PHP and changed the line to

LoadModule php5_module "C:/PHP/php5apache2_2.dll"

And for the first time it all worked! Maybe it just doesn't like spaces in the path. Or maybe it doesn't like long path names. I dunno. It's likely that this fix is specific to a particular version of Apache and PHP, but after spending about 20 hours on this problem, I'm so bleary that I don't know what that dependency might be.

Picker answered 24/8, 2012 at 4:4 Comment(0)
N
1

I had this problem too, but I could get Apache to work again by disabling all the extensions in the php.ini file (I had all the DLL in the ext folder, but they were disabled in the php.ini) Since I wanted to use all the php extensions, I tried disabling one by one to see which ones were crashing Apache. I also did install PHP in the C:, to avoid "blank space/long path" problems. In the end, here is how my Apache's httpd.conf file is, in the part of PHP:

#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
PHPIniDir "C:\PHP"
LoadModule php5_module "C:\PHP\php5apache2_2.dll"
#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL

Also, the extensions that was crashing apache was:

  • php_oci8.dll
  • php_pdo_oci.dll
  • php_pdo_oci8.dll
  • php_pdo_sqlite_external.dll
  • php_pspell.dll
  • php_sybase_ct.dll

I really don't know what's wrong with them, though.

Please, note that I installed PHP by using the msi installer (php-5.2.17-Win32-VC6-x86.msi) and I installed ALL the extensions. I'm also using Windows 7.

Neumark answered 25/1, 2013 at 18:39 Comment(0)
G
0

As an alternative to the @ar2r answer of deleting the last backslash, you can write the path using (forward) slashes and it would work even with an slash at the end. For some reason using a backslash at the end of a path doesn't works in recent versions of Windows:

# works, no slash or forward slash at the end
PHPIniDir "C:\Program Files\PHP7"
PHPIniDir "C:/Program Files/PHP7/"
PHPIniDir "C:\Program Files\PHP7/" # mixing slashes and backslashes

# doesn't works, backslash at the end
PHPIniDir "C:\Program Files\PHP7\"

Note that mixing forward and backslashes works as long as the trailing slash is not a backslash.

This applies also to other directives, I noticed this behavior when configuring the Alias for the icons of the directory index.

Gearing answered 6/12, 2017 at 17:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.