Apache doesn`t handle .php files on Windows7

2019-09-02 19:06发布

After having searched and tryed during the whole day and before going to install something like XAMP i wonder why the following hasn`t worked out for me, in case somebody knows:

Conditions: Windows 7 (64), Microsoft VC (2005/2008/2010/2012).

Purpose: to install a web-server on the local machine to execute PHP-scripts.

Process:

1) Well, firstly i downloaded binary apache 2.4 for win64 which require Microsoft VC11. Then i edited conf-file and installed apache, everything was fine, i could see the page http:/localhost returning "It works". Ok.

2) Then i went to install PHP. There is no any stable official release for win64. Well, i downloaded VC11 x86 Thread Safe and installed it from cmd with "php -i". It seemed to be fine too because it worked in console by typing "php.exe -f path-to-file". php.ini was with default settings.

3) Thats here where my trouble begins. I have to integrate apache and php. According to php.net, there are 3 common ways to do that: cgi, fastcgi and handler. I chose the last - as handler, adding at the end of httpd.conf that content:

LoadModule php5_module "c:/myAdr/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
PHPIniDir "c:/myAdr"

Then i cannot restart web-server. The following message appears:

httpd: Syntax error on line 530 of c:/myAdr/apache/conf/httpd.conf: Cannot load c:/myAdr/php/php5apache2_4.dll into server: 1% \xed \xe5 ... win32

And as you have already supposed it didnt work. The localhost still shows "it works" (i.e. apache without having been restarted works), but it still doesnt execute php :( And here i am done. Are there special/additional lines in the config file i should have uncommented or added?

Short review: Before installing apache&php, i have had proper Microsoft VC installed, disabled IIS-components of windows (otherwise surfaces common error as to port 80 that cannot be used by apache because it is used by IIS and stuff). VC versions (in my case VC11) coincide for both apache and php (another common issue here is the use of apache based on VC6 and php based on VC9, for example). I was always under Administrator on my PC. File php5apache2_4.dll was in the php-folder according to path given to apache. Also i saw a couple of similar topics here, but those advices didnt work for me or, probably, i just dont understand how to do it :(

So far i have got two questions:

  • What did i do wrong generally?
  • Is there anybody who in the end arranged the problem? And if yes, i guess, many people would like to know how in detail.

UPDATE! FINALLY I MADE IT WORK! the issue (that error when the file php5apache2_4.dll is neither loaded nor found) consists of version`s incompatibility, i.e. my OS is win7 (64) and my apache is designed for win64 (httpd-2.4.6-win64-VC11), but i used PHP DESIGNED FOR win32 (php-5.5.1-Win32-VC11-x86) because of lack of official stable php-version for win64. The solution for me was to find php for win64! first link in this topic http //www.apachelounge.com/viewtopic.php?p=23384 provides us with PHP 5.4.9 for Windows x64! Attention, there are no php.ini files there! You should take them from other distributives. And after installing that version as i described above at the beginning, everything is working now!

1条回答
够拽才男人
2楼-- · 2019-09-02 19:32

I would remove the current installs of Apache and PHP and go directly to WAMP or XAMPP. If you have not used Apache and PHP before, there are too many things to get right before it works.

查看更多
登录 后发表回答