views:

707

answers:

2

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.

+2  A: 

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.
Oleksandr Bernatskyi
I've tried enabling errors, but continue to get the same error - "The requested operation has failed!"
bobbyb
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.dllWhen they are all commented out, apache starts fine. Any idea why this is?
bobbyb
After some more testing, it seems i can enable extensions but there is some sort of limit, i think by total extension size?
bobbyb
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?
Oleksandr Bernatskyi
Oh, and would you specify the versions of Apache and PHP you've installed?
Oleksandr Bernatskyi
apache 2.2.14 and php 5.2.11
bobbyb
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).
Oleksandr Bernatskyi
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?
bobbyb
Uh oh, maybe this will help: http://www.brooks-bilson.com/blogs/rob/index.cfm/2008/1/4/Intermittent-Apache-Problems-and-winntaccept-Asynchronous-AcceptEx-failed
Oleksandr Bernatskyi
that did not help. The id warning seems to be the more prevalent one.
bobbyb
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.
Oleksandr Bernatskyi
If it's not caused by firewall/Skype you may try these things: #1 Replace PHP installation with this one: http://www.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.
Oleksandr Bernatskyi
#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!
bobbyb
Cool, I was happy to help. You're welcome.
Oleksandr Bernatskyi
A: 

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.

Murat