30

Running a win64 architecture, attempting to run php with Apache for the first time. After loading the php module in the httpd.conf, apache fails to start and the error log displays

Cannot load c:/php/php5apache2_4.dll into server: %1 is not a valid Win32 application.  

Other sources claim this is a compatbility issue, and that there is either a win32 version of php with win64 apache, or vice versa, I do not think this is the case. I downoaded the win64 vc14 version of apache from http://www.apachelounge.com/download/ and the win64 vc11 version of php from http://windows.php.net/download#php-5.6 - What is causing the error when I attempt to load the php module?

Ethernetz
  • 906
  • 3
  • 16
  • 33
  • 1
    What do Windows log files tell you? Are there any apache or php log files to check? The one error may not be enough to diagnose the problem. – Robbert Dec 21 '15 at 23:31
  • Do you see any errors in the Event Logs for Application or System logs? How are you executing Apache? `%1` should refer to a parameter being sent to the executable. – Twisty Dec 21 '15 at 23:31
  • 1
    Have you installed all the required vc++ runtimes? – Ryan Vincent Dec 21 '15 at 23:36
  • Didnt this help... http://stackoverflow.com/questions/17692255/installing-php-5-on-windows-server-2003-1-is-not-a-valid-win32-application – Sudhir Bastakoti Dec 22 '15 at 00:16
  • Can you provide the HTTPd.conf where you are loading your modules as long with your Apache Version PHP Version, and all the revelant stuff ? – Devian Dec 22 '15 at 00:35
  • @Devian You can check mine if you want, since we encounter the same error. http://pastebin.com/znty0VAb – giannis christofakis Dec 22 '15 at 19:45
  • @Robbert where should I look? At least in my case, I receive this error message when I'm trying to restart the apache, `httpd -k restart`. The error is pointing at the `LoadModule php5_module "c:/php/php5apache2_4.dll"` line that I manually added in order to load the module. – giannis christofakis Dec 22 '15 at 20:01
  • @Devian Server Version : Apache 2.4.17 , Apache Lounge VC14 Server. PHP 5.6.16. – giannis christofakis Dec 22 '15 at 21:01
  • Try checking whether your php is thread safe or thread unsafe version. Try the other version and see if that works. – Alpesh Panchal Dec 23 '15 at 11:43
  • As i thought. Your Apache is VC14 while PHP is VC11. These are incompatible binaries. You should use the same version of binaries. VC11, or VC14. Please do check the answer provided. It is the correct one. – Devian Dec 24 '15 at 16:14

2 Answers2

28

It is actually binary version difference so compatibility issue between apache and php.

Since you've installed apache vc14 windows 64, download this php of vc14

http://windows.php.net/downloads/releases/php-7.0.13-Win32-VC14-x86.zip to config php with apache.

Alpesh Panchal
  • 1,723
  • 12
  • 9
  • What should I do with the old version? Should I remove it somehow? I guess I should change the PATH to point to the newer version you posted. I see it's php 7, is it a stable version ? Are there any apache config changes I should know? – giannis christofakis Dec 28 '15 at 09:53
  • Ok, it seems to work. The only think I changed was to add the new version to the PATH, remove the old one, although when I run `php -v` it shows the old version, don't know why. And I added `LoadModule php7_module "c:/php-7.0.1-Win32-VC14-x64/php7apache2_4.dll"` to httpd.conf. – giannis christofakis Dec 28 '15 at 10:09
  • 1
    I also changed the `PHPIniDir "c:/php-7.0.1-Win32-VC14-x64"` but where is the `php.ini`? – giannis christofakis Dec 28 '15 at 11:02
  • You can find location of php.ini file using phpinfo(); function. Create a new php file and write phpinfo(); into it. Now run it from browser and you will see php.ini location under "Loaded Configuration File" section. – Alpesh Panchal Dec 29 '15 at 17:02
  • I've already done that, the *Loaded Configuration File* field is empty. That's why I had to point the `PHPIniDir` to my old version in order to make it work :( – giannis christofakis Dec 29 '15 at 20:13
  • The download link is invalid. @Andrew, which one should I download? I would think the third and/or fourth links should be used; however, those yield the same problem. – Eric Reed Jan 01 '17 at 20:40
  • In my case, the most recent version worked, it just had to be a x86 version – mr_j Jul 19 '19 at 09:42
0

With this error I also got

 (%1 is not a valid Win32 application.)
 Warning: Module 'pdo_mysql' already loaded in Unknown on line 0

I just commented

;extension=php_pdo.dll
;extension=php_pdo_mysql.dll

Those two lines and both errors disappeared, and everything works fine. I commented those lines because of 'already loaded' errors, but it fixed both somehow...

temo
  • 612
  • 1
  • 9
  • 25