Question

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.

Était-ce utile?

La solution

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.

Autres conseils

delete last slash:

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

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.

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"

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.

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.

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top