Apache doesn't load module from PHP
Asked Answered
G

12

10

I am following this portuguese article to configure Apache and PHP:

How Install And Configure The Development Environment in PHP - Part 2.

I already set up the php.ini and httpd.conf files. Besides to php5apache2_4.dll is in the right directory, but when I restart the server show me the following error:

httpd.exe: Syntax error on line 531 of D:/Apache24/conf/httpd.conf: Invalid LoadModule path \xe2\x80\xaa"D:/php-5.6.13/php5apache2_4.dll"

Httpd.conf:

LoadModule php5_module ‪"D:/php-5.6.13/php5apache2_4.dll"
AddType application/x-httpd-php .php 
PHPIniDir "D:/php-5.6.13/"

EDIT

I changed the Httpd.conf file.

LoadModule php5_module ‪"../php-5.6.13/php5apache2_4.dll"
AddType application/x-httpd-php .php 
PHPIniDir "../php-5.6.13/"

And now is returning me a new error:

httpd.exe: Syntax error on line 531 of D:/Apache24/conf/httpd.conf: Cannot load ../php-5.6.13/php5apache2_4.dll into server: %1 n\xe3o \xe9 um aplicativo Win32 v\xe1lido.

In English language: Not a valid Win32 application.

In console:

php -version
PHP 5.6.13 (cli) (built: Sep  3 2015 15:14:40)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

httpd -version
Server version: Apache/2.4.16 (Win64)
Apache Lounge VC14 Server built:   Jul 22 2015 13:24:19
Glaucescent answered 24/9, 2015 at 17:56 Comment(2)
Your syntax looks correct ... but appearances can be deceiving. Make sure you're using "simple double quotes" (" == ascii 34) for all your module entries in httpd.conf and php.ini. More details here: webmasterworld.com/forum92/3140.htm. ALTERNATIVE SUGGESTION: since you don't have any spaces in any of your paths - just take out the double-quotes entirely.Gocart
I solved, thank you (; I changed the architecture of Apache, I install the Apache Win32 for last.Glaucescent
G
8

I just had the same problem trying to configure php7, so for anyone else having trouble:

There may be a few issues. Check that your versions of php and Apache are bit-compatible (both 64-bit x64 or both 32-bit x86; note that when downloading 64-bit PHP from windows.php.net/download/, the zip file will be called php...Win32...x64).

Also check that they are both compiled with the same version of Visual Studio (e.g. VC14). This happened to be the problem here: www.apachelounge.com/viewtopic.php?t=6596

In my case, I had the problem paulsm4 referred to about quotes. I copied and pasted the code from a website and noticed that when I ran httpd -k start, my error was httpd: Syntax error on line 62 of C:/Apache24/conf/httpd.conf: Invalid LoadModule path \x93c:/php7/php7apache2_4.dll\x94. The \x93 and \x94 are the CP1252 encodings for fancy open and end quotes. Eliminating these or replacing them with regular quotes fixed the problem and Apache ran smoothly with PHP after that.

Another problem someone else ran into was trying to configure Apache with NTS (non-thread-safe) PHP.

php.net/manual/en/install.windows.apache2.php The PHP download website also makes this point.

Gavel answered 17/12, 2015 at 23:53 Comment(1)
"Also check that they are both compiled with the same version of Visual Studio (e.g. VC14)" YES!Eveliaevelin
S
4

Removing the double-quotes form the httpd_uwamp.conf file worked for me on both UnWamp and PHP distributions. (No spaces are in any of my path names)

For Example Change

LoadModule "{PHPMODULENAME} {PHPPATH}/{PHPAPACHE2FILE}" to LoadModule {PHPMODULENAME} {PHPPATH}/{PHPAPACHE2FILE}

Thanks to Giancarlo Abel Giulian for his post ;-)

Spineless answered 1/4, 2016 at 15:16 Comment(0)
T
2

You have to make sure that you are using compatible version PHP with apache. Such that if you are running apache 32 bit make sure you are using PHP 32 bit and the same applies for 64 BIT. For preliminary analysis do the following.

  1. Open command prompt and navigate to your apache installation bin folder such as cd "C:/Apache24/bin"

  2. Then run the following command to see if syntax is OK: httpd.exe -t

The response will tell you if the mentioned dll php5apache2_4.dll is missing in your PHP location. if this is the case then you have to download the specific compatible PHP version with apache. otherwise it will tell you that syntax is ok.

for more information please visit this link

https://danielarancibia.wordpress.com/2015/09/27/installing-apache-2-4-and-php-7-for-development-on-windows/

Tafoya answered 17/7, 2019 at 13:8 Comment(0)
S
1

I was having the same problem:

Invalid LoadModule path \xe2\x80\x9cC:/WAMP/php/php5apache2_4.dll\xe2\x80\x9d.

Based on paulsm4 suggestion above, I deleted the quotes in the directive LoadModule php5_module and replaced with simple quotes:

LoadModule php5_module "C:/WAMP/php/php5apache2_4.dll"

This solved it for me.

Sigfrid answered 29/9, 2016 at 6:0 Comment(0)
R
1

I had a similar error du to a simple cut and paste error from an older httpd.conf file where I had

LoadModule php5_module ...

instead of

LoadModule php7_module ...

Hope this may help someone else Googling this error message.

Ramburt answered 1/5, 2018 at 2:48 Comment(0)
H
0

Change

LoadModule php7_module "c:/php/php7apache2_4.dll"

to  

LoadModule php7_module /php/php7apache2_4.dll

and   

PHPIniDir "c:/php"

to  

PHPIniDir /php

Well done.

Harvison answered 26/7, 2017 at 3:54 Comment(0)
W
0

Cannot load modules/php7apache2_4.dll into server: The specified module could not be found. This is a common problem while setting up apache and php environment into a local computer

I also faced the same issue: The best way to approach the problem would be to install the same VC level for the apache server and the php and also make sure that the same VC++ is also installed in the computer.

For me I tried with VC14 for apache24 and php and also installed VC++ 2015 edition which happens to be VC14

Wagonlit answered 22/10, 2017 at 13:54 Comment(0)
S
0

In my case, it was due to the type of PHP7 downloaded: Non Thread Safe Just download the Thread Safe version and extract to C:\php7 (Default directory), then try starting Apache Service again.

Hope this help!!!

Souther answered 17/2, 2018 at 21:55 Comment(0)
F
0

I had tough time to get rid of this error, eventually resolved after both ( Apache and PHP ) installed x86 version ( not 64 ).

Also avoided simple folder name i.e. Apache2.4 or php, instead using detailed name like php_7.1.21_vc14_x86_ts and Apache_2.4.34_vc14_x86 to catch mismatch by looking at folder name itself instead of keep getting weird error.

Fathom answered 25/8, 2018 at 15:31 Comment(0)
V
0

I can understand how does it feels to get that error. Well after hours of research what i found was just remove the double-quotes and you are good to go. There is no need to remove double quotes from all the three lines. Remove them from the line which is giving you error.

Before

PHPIniDir “C:/PHP”
AddHandler application/x-httpd-php .php
LoadModule php7_module "C:/PHP/php7apache2_4.dll"

After

PHPIniDir “C:/PHP”
AddHandler application/x-httpd-php .php
LoadModule php7_module C:/PHP/php7apache2_4.dll

It worked for me. I don't think the upper two lines will give you error until and unless you have installed the PHP in insanely wrong way.

to test it (if you dont know)

  1. open cmd (no need to open as administrator but you can)

  2. navigate to the bin folder into c:/apache/bin (or whatever your folder is)

  3. type httpd -t and it should show syntax OK if it is not so you need to work on the line which it says have got an error. All he best.

Pretty bad reply? i know as it is my first reply to any doubt.

Velate answered 6/6, 2019 at 16:11 Comment(0)
V
0

I had the same error. The only thing I changed was php_module to php7_module

Before

PHPIniDir "c:/php"
LoadModule **php_module** "c:/php/php7apache2_4.dll"
AddType application/x-httpd-php .php

After

PHPIniDir "c:/php"
LoadModule **php7_module** "c:/php/php7apache2_4.dll"
AddType application/x-httpd-php .php
Vaginitis answered 9/5, 2021 at 12:14 Comment(1)
The php_module is used for PHP8.0, before it used to be phpX_module where X was equal to the version number of php, (like php7_module for PHP7). (# before PHP 8.0.0 the name of the module was php7_module)Adventist
K
0

Let me answer with what solved mine, Apache 2.4 was not loading PHP extensions. Then by following quite correct examples above I made to resolve my case.

Before you proceed ensure both Apache2.4 and PHP make match like 64bit etc.

PHPIniDir "c:/php"
LoadModule php7_module "c:/php/php7apache2_4.dll"
AddType application/x-httpd-php .php

Ensure to restart apache server

httpd -k restart
Kristy answered 18/11, 2023 at 20:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.