I’m trying to install PHP, Apache and MySQL on Windows, following these guidelines. At some point, I am prompted to edit httpd.conf
to point to my PHP installation. Both the apache directory and the php directory are under C:
: C:Apache24
and C:php-8.0.0beta1-Win32-vs16-x64.
The relevant lines for my installation are:
PHPIniDir "C:/php-8.0.0beta1-Win32-vs16-x64"
AddHandler application/x-httpd-php .php .phar
LoadModule php8_module "C:/php-8.0.0beta1-Win32-vs16-x64/php8apache2_4.dll"
Unfortunately, these seem to break Apache, since even running httpd
afterwards yields:
httpd.exe: Syntax error on line 542 of C:/Apache24/conf/httpd.conf: Can't locate API module structure `php8_module' in file C:/php-8.0.0beta1-Win32-vs16-x64/php8apache2_4.dll: No error
It seems that php8_module
is not recognized by PowerShell. Any ideas?
8
Answers
I had exactly the same problem. I found a solution here.
As it turned out in PHP 8 we should not use
php8_module
as we would expect, but only plainphp_module
So the loader line should look like this:
It should look like below:
You would expect that the Apache2 directive for PHP8 would intuitively be:
But rather you have to use:
I find that strange but that’s how it is.
If you now navigate to your Apache2bin directory (something like C:/Apache24/bin)
and check your httpd.conf file for any syntax errors using:
You should get the output "Syntax OK". Now you can start your apache server without any errors.
If you are just looking for the answer it is:
If you’d like to read on, I am trying to help people with other issues that come with trying to install php, mysql and apache together.
So normally for the PHP 8 version if you try to install it and try to connect it with MySQL and Apache it will not work which we already know. IF you didn’t know this, please go and uninstall PHP 8 and install Php 7.4 in your C directory.
Now the line:
If you notice what the error actually is that of a syntax which is pretty confusing if you go letter by letter trying to fix the issue.
It turns out it is more of a logical error than a syntax error.
Now if you typed this in your config code:
You are not wrong or far from the actual solution actually you are 99% correct with this above line.
So if you notice the error line again it states it is unable to locate an API called
php_module
.So by default for PHP 8 you don’t need to change this line as it understands it, but for Php 7.4 you must add a 7 in front of php so it can locate the module.
So the correct line of code to be placed in the config file is:
thank you for patiently reading through this, I hope it helps anyone searching for a more whole answer in relation to trying to download php 7.4, mysql and apache together.
I had the same problem but in my case it worked changing this line in the httpd.conf file from
to
And it worked
Not forgetting @vmxes answer
Example:
from https://windows.php.net/download#php-8.0
you have to download the "Thread Safe" version. otherwise you have no "php8apache2_4.dll" and you need that so that php8 works with apache in XAMPP.
just download this version and you have
To resolve the error in my case I have to add as
instead of
My working environment details..
In httpd.conf file: I have added below line of code on top.