On Windows 10 Pro, after downloading PHP 8, switching to it in Laragon (PHP > Version) and restarting Apache, I get the following error:
httpd: Syntax error on line 546 of
C:/laragon/bin/apache/httpd-2.4.35-win64-VC15/con...:
Syntax error on line 2 of
C:/laragon/etc/apache2/mod_php.conf: Can't locate
API module structure 'php8_module' in file
C:/laragon/bin/php/php-8.0.2-Win32-vs16-x64/php8a...:
No error
After a fair bit of head scratching, the fix was fairly simple - in file
C:/laragon/etc/apache2/mod_php.conf
I changed
LoadModule php8_module to LoadModule php_module
It seems Laragon fouls up the auto-configuration of PHP 8
GOTO
C:/laragon/etc/apache2/mod_php.conf
AND REPLACE THIS
#This file is auto-generated, so please keep it intact.
LoadModule php8_module "C:/laragon/bin/php/php-8.0.6-Win32-vs16-x64/php8apache2_4.dll"
PHPIniDir "C:/laragon/bin/php/php-8.0.6-Win32-vs16-x64"
<IfModule mime_module>
AddType application/x-httpd-php .php
</IfModule>
WITH THIS
#This file is auto-generated, so please keep it intact.
LoadModule php_module "C:/laragon/bin/php/php-8.0.6-Win32-vs16-x64/php8apache2_4.dll"
PHPIniDir "C:/laragon/bin/php/php-8.0.6-Win32-vs16-x64"
<IfModule mime_module>
AddType application/x-httpd-php .php
</IfModule>
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?
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 plain php_module
So the loader line should look like this:
LoadModule php_module "c:/Program Files/PHP/php-8.0.0RC2/php8apache2_4.dll"
You would expect that the Apache2 directive for PHP8 would intuitively be:
LoadModule php8_module "path/to/PHP/php8apache2_4.dll"
But rather you have to use:
LoadModule php_module "path/to/PHP/php8apache2_4.dll"
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:
httpd -t
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:
LoadModule php7_module "C:/Apache/modules/php7apache2_4.dll"
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:
httpd.exe: Syntax error on line 244 of C:/Apache/conf/httpd.conf: Can't locate API module structure `php_module' in file C:/Apache/modules/php7apache2_4.dll: No error
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:
LoadModule php_module "C:/Apache/modules/php7apache2_4.dll"
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:
LoadModule php7_module "C:/Apache/modules/php7apache2_4.dll"
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.
LoadModule php[PHP_MAIN_VERSION]_module "path/to/PHP/php[PHP_MAIN_VERSION]apache2_4.dll"
Example:
LoadModule php7_module "C:/php7.4.27/php7apache2_4.dll"
To resolve the error in my case I have to add as
LoadModule php_module "c:/php/php8apache2_4.dll"
instead of
LoadModule php8_module "c:/php/php8apache2_4.dll"
My working environment details..
Windows 10 64 Bit
PHP Version: PHP 8.0.19 64 bit Thread safe version
Apache version: httpd-2.4.53-win64-VS16
In httpd.conf file: I have added below line of code on top.
AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .php .html
LoadModule php_module "c:/php/php8apache2_4.dll"
PHPIniDir "c:/php"
It should look like below:
# PHP8 module
AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .php .html
LoadModule php_module "c:/php/php8apache2_4.dll"
PHPIniDir "c:/php"
I had the same problem but in my case it worked changing this line in the httpd.conf file from
#ServerName www.example.com:80
to
ServerName localhost
And it worked
Not forgetting #vmxes answer
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
I am trying to get my info.php file to work, it has the code:
<?php phpinfo(); ?>
When I hit localhost on my apache web server, i get the default "It works!" When I hit localhost/info.php I get the error message, oops chrome could not connect to localhost.
I do not understand why, I already added these two lines to my httpd.conf file in my apache conf folder:
LoadModule php5_module "C:/Program Files (x86)/PHP/php5apache2_2.dll"
AddType application/x-httpd-php .php
Are there any other obscure things that I need to setup in order to get php to work? I am really baffled.
Are you sure that it isn't
LoadModule php5_module "C:/Program Files (x86)/PHP/php5apache2_2.dll"
AddType application/x-httpd-php .php
Note the _ instead of . in the dll filename.
I have successfully installed both Apache and php on my computer, Now I want to know how
to tell Apache what translator it needs to use when it is asked for a
.php file by users.
I tried adding the following code to the end of the httpd.conf file but afterward I was unable to start Apache service.
AddType application/x-httpd-php .php
PHPIniDir "C:/php5/"
LoadModule php5_module "C:/php5/php5apache2_4.dll"
I get "the requested operation has failed!" error when I try to start apache service from apache service monitoring tool.
Thanks in advance.
Delete your changes and then do almost the same thing but put the rows in the right place.
Search for the LoadModule statements in the httpd.conf-file. After the last LoadModule statement paste this:
LoadModule php5_module "c:/php/php5apache2_2.dll"
Search for AddType statements. After the last one paste this:
AddType application/x-httpd-php .php
Paste this at the very end of your httpd.conf-file:
PHPIniDir "c:/php"
Change all instances of c:/php to c:/php5 if that is where you installed php.
I had a friend configure my server for sqlite3 yesterday.
He went in through putty and used a command line to determine if it was already installed:
locate sqlite3
it came back that it was indeed located as this shows:
/usr/bin/sqlite3
/usr/lib64/libsqlite3.so.0
/usr/lib64/libsqlite3.so.0.8.6
/usr/lib64/apr-util-1/apr_dbd_sqlite3-1.so
/usr/lib64/apr-util-1/apr_dbd_sqlite3.so
/usr/share/man/man1/sqlite3.1.gz
/usr/share/rails/configs/databases/sqlite3.yml
So then he proceeded to explain how we had to configure the apache to recognize and load that module. So we went into the httpd/conf.d/ directory and vi edited the php_conf file by adding this line <<---THIS LINE & now the complete file looks like this:
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#
<IfModule prefork.c>
LoadModule php5_module modules/libphp5.so
</IfModule>
<IfModule worker.c>
LoadModule php5_module modules/libphp5-zts.so
</IfModule>
LoadModule php5_module modules/pdo_sqlite.so<<---THIS LINE
#
# Cause the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
AddType text/html .php
#
# Add index.php to the list of files that will be served as directory
# indexes.
We then saved that file (i just double checked). We then called /etc/init.d/httpd reload and then restart. We got Green OKs all around.
But I still get:
PHP Fatal error: Class 'SQLite3' not found
when calling this line in my php file:
$db = new SQLite3($sqlite_database);
Any ideas how else I could test to see what is wrong?