Apache doesn't load module from PHP - php

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

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.

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 ;-)

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.
Open command prompt and navigate to your apache installation bin folder such as
cd "C:/Apache24/bin"
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/

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.

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.

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.

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

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!!!

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.

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)
open cmd (no need to open as administrator but you can)
navigate to the bin folder into c:/apache/bin (or whatever your folder is)
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.

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

Related

Cannot start service apache on laragon

Everything was ok before. Today I tried to start laragon apache and I got the following error :
httpd: Syntax error on line 546 of
C:/laragon/bin/apache/httpd-2.4.35-win64-VC15/conf/httpd.conf:
Syntax error on line 1 of
C:/laragon/etc/apache2/fcgid.conf: Cannot load
C:/laragon/etc/apache2/modules/mod_fcgid-2.3.9-Win32-VC14.so
into server: %1 is not a valid Win32 application.
I have tried to change PHP versions, but it didn't help.
What should I do to start apache withour this error?
The answer was given by one of Laragon's administrators
You need to use a PHP Thread Safe version. The PHP NTS (non thread safe) versions are NOT compatible with Laragon.
https://forum.laragon.org/topic/166/tutorial-how-to-add-another-php-version-php-7-4-php-8-0-updated/1
You must also make sure that the VC of both PHP & Apache are the same.
If you are finding when trying to switch from php7 to php8 on Laragon here is a quick fix goto C:\laragon\etc\apache2
open mod_php.conf on line 2 change php8_module to php_module
# 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>
change this above to
# 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>

httpd.conf on Windows: can't locate API model structure `php8_module`

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

PHP test page is showing blank

I am trying to set up PHP to work with Apache using Apache Module DLL. The following code is added to c:\Apache24\conf\httpd.conf file:
LoadModule php5_module C:/PHP/php5apache2_4.dll
<IfModule php5_module>
DirectoryIndex index.html index.php
AddHandler application/x-httpd-php .php
PHPIniDir "C:/PHP"
</IfModule>
Then I browse http://localhost in a browser and it shows a page saying "It Works!"
Then again I test browse a PHP page info.php which just calls phpinfo() and it shows quite a bit of info about PHP installation.
Now, the case is that I found two default files such as php.ini-production and php.ini-development and I copy any one of them and save it as php.ini in
"C:/PHP",restarts the Apache server and again test browse info.php,then this time the page is blank even without any error message.
What might be the issue and how should I try to solve it?
My software specification is outlined below:
OS: Windows 7
PHP: 5.6.29
Apache: 2.4.23-win32-VC14
Thanks in advance!

PHP stopped working on Apache after upgrade to OS x 10.10.1 Yosemite - Owncloud broken

Context: I'm trying to run Apache on my local Mac27" (2009) so that I can use OwnCloud as an alternative to Apple's iCloud (I just want to do local sync of my calendar like in the good-old "OS X big cat" days. For paranoid privacy reasons I don't want Cupertino to know who I know or what I'm doing - probably misplaced, but there you go). My foray into this were based on a blog post by Michael Gracie at http://michaelgracie.com/2013/11/13/getting-ios-7-calendar-and-contacts-syncing-directly-with-os-x-10-9-mavericks/ (for which many thanks are due).
When I upgraded to Yosemite a few weeks ago (remind me why I did this?) I spent an age mending my very simple setup and I was back . Yesterday I upgraded (again, remind me why I did this?) to 10.10.1 and it broke again. Everything seems like it should work, but PHP is not running.
The symptom is that, when I run OwnCloud (localhost/owncloud/index.htm), I get the OwnCloud logo and styling and then an error:
PHP module GD is not installed.
Please ask your server administrator to install the module.
This, however, is a diversion, because it's not the GD module which is the problem - I think that Apache can't see PHP at all. The reason is as follows:
1) Does PHP run on Apache?
When I go to:
http://localhost
I see the Apache "It Works!" message.
Adapting the index.html.en file in /Library/Webserver/documents/ allows me to modify that message, however, when I call PHP from within that file e.g.
<h1>It works!</h1>
<h2>This file is in /Library/Webserver/Documents</h2>
<h3>Trying to printout phpinfo()</h3>
<?php
echo phpinfo();
?>
Then I see three lines of text but no PHP info.
So PHP is not available when rendering that webpage.
2) Is PHP available at all?
Investigating this, I run the following command from the terminal:
sudo echo <?php phpinfo() ?> | php
and I get four-thousand lines of PHP info, which includes
'--with-gd'
in the configure command.
3) Has Apache loaded the PHP module?
I then run:
httpd -t -D DUMP_MODULES
Apache tells me that, among many other modules it is using:
php5_module (shared)
4) Is the httpd.conf file compatible with this:
I've been through httpd.conf in my /etc/apache2 directory and have uncommented the following lines:
LoadModule php5_module libexec/apache2/libphp5.so
LoadModule authn_core_module libexec/apache2/mod_authn_core.so
LoadModule authz_host_module libexec/apache2/mod_authz_host.so
5) What else?
Just to complete the picture, in my /etc/apache2/users file I have configured my own user settings to:
<Directory "/Users/DJBrown/Sites/">
Options Indexes MultiViews FollowSymLinks
Require all granted
AllowOverride All
Order allow,deny
Allow from all
</Directory>
(I confess, at this point - as well as others - I'm really not quite sure what I'm doing since I've following much of this from some other answers in StackOverflow).
6) Conclusion
Apache is running with PHP is loaded and both httpd and PHP can be interrogated from the command line ... but Apache won't run PHP.
Is that possible?
What have I missed?
Any help gratefully received.
DJ
Here's a partial answer.
Changing the line in httpd.conf
AddType application/x-httpd-php .php
to
AddType application/x-httpd-php .php .htm .html
Permits apache to render in-line PHP code in HTML files.
(I got this from http://php.about.com/od/advancedphp/p/html_php.htm)
I still have an OwnCloud problem now, which I will take to their forum
Thanks for your help birdspider
DJ

Getting blank PHP page over Apache

In a newly setup digitalOcean cloud server (CentOS), I have installed php and Apache. The webserver is running fine:
[root#a2m5cent01 httpd]# service httpd status
httpd (pid 11232) is running...
[root#a2m5cent01 httpd]# php --version | head -1
PHP 5.3.3 (cli) (built: Dec 11 2013 03:29:57)
But browser is showing blank pages (white page) if I try to visit any php page.
Here is what I have done so far to troubleshoot:
Created a page with following content: <?php phpinfo(); ?>. It displays a blank page when viewed from browser.
Just to ensure, apache is pointing to the correct directory, placed a static .html page there, and saw it comes out fine in browser, so apache is working and directory is correct.
In /etc/php.ini, changed display_errors directive to On. Still blank page
In Apache config file (/etc/httpd/conf/httpd.conf) found this line Include conf.d/*.conf. Inside conf.d directory, there is a php.conf file containing the line:
LoadModule php5_module modules/libphp5.so. Ensured that this .so file actually exists in this place.
In the same file I have these two lines as well: AddHandler php5-script .php and AddType text/html .php
Executed the php page from CLI, it works fine - so php is working locally.
Then why is it always shows a blank/white page over the browser? What else am I missing?
EDIT
Based on suggestions from #Nathan,
I checked Apache error log file, could not see any error being
reported there.
My /etc/php.ini says, php error_log is located as syslog. So I checked /var/log/messages but could not find any PHP error message
Next I put some normal HTML in the php file containing phpinfo() call. Interestingly I found that even the normal HTML texts are also not coming. It still produces blank page.
Then I checked Apache access log. Surprise! There is no GET request for any of the PHP files I tried to load in the browser. But GET request for all the non-php files are there with 200 return code.
Apache is not even logging any access request for PHP files. Any idea why would that happen?
check out your phpinfo() script.
<?php
phpinfo();
?>
missing the "php" behind the first "?" will give a blank page
I think your php installation with apache is faulty. Thats why you can not see any php page in your webserver. Clean remove all the existing apps, like httpd,php,php-fpm,php-cli etc. and try to clean isntall in this order
yum install httpd -y
yum install php php-common php-cli php-gd php-curl php-fpm -y
then make sure you restart yout httpd server.
service httpd restart
Install mod_fastcgi:
yum install mod_fastcgi
Start the service:
service php-fpm start
Restart Apache:
service httpd restart
5. Configuration of Apache with PHP-FPM
Open the fastcgi.conf file:
nano /etc/httpd/conf.d/fastcgi.conf
Add this to the end of the file:
<IfModule mod_fastcgi.c>
DirectoryIndex index.html index.shtml index.cgi index.php
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization
</IfModule>
After that search after "FastCgiWrapper" and make sure it's set to "off" then save the file.
The /usr/lib/cgi-bin/ directory must exist, so we create it:
mkdir /usr/lib/cgi-bin/
If mod_php is installed and enabled, we need to disable it so open the configuration at /etc/httpd/conf.d/php.conf:
nano /etc/httpd/conf.d/php.conf
Comment out the AddHandler and AddType lines so it looks like here:
#
# 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>
#
# 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.
#
DirectoryIndex index.php
#
# Uncomment the following line to allow PHP to pretty-print .phps
# files as PHP source code:
#
#AddType application/x-httpd-php-source .phps
Save the file and restart Apache:
service httpd restart
Are you navigating to the php file directly? Or are you just going to the directory root?
If the later, Apache might not be recognizing .php as the directory index.
To test, try create a .htaccess file in your web root containing the following line:
DirectoryIndex index.php
I have the same issue...
The problem is in the iptables. (It seems like it)
Try with:
service iptables stop
## check if it stop...
service iptables status
Then try to reload the page again.
If you had other solution please share.
[edit]
Restarting the iptables service is working for me.
Try:
service iptables restart
First of all you should check the permissions of your file.
If you don't grant read-permission to public, Apache produces a blank page without showing any errors.
It's been sometime, but I wanted to come back to this question to update that the issue was with the directory permission setup.
The FPM user I was using didn't have necessary permission to execute the index.php file in the web root.
To avoid these issues in the future, I have created an automated bash script that will automatically create and configure webservers in DigitalOcean boxes. Please take a look here https://github.com/akash-mitra/fairy
This script will automatically,
Installs Nginx
Create virtual server block for nginx
Installs PHP, PHP APC, PHP Curl etc.
Supports PHP Fast Process Manager (php-fpm)
Installs Memcached
Installs Database (MariaDB / MySQL)
Optionally Installs PHP Composer and Laravel
Configures and Strengthens SSH
Activates Firewall
Optionally enables SWAP space in DO server and fixes a locale issue
Since everything looks at its default state, have you checked this part just for confirmation
cat /etc/php.ini | grep log_errors
If log_errors is disabled then enable it and check this below log after restarting httpd.
/var/log/httpd/error_log
--
Also check this part from php configuration.
cat /etc/php.ini | grep error_reporting
This value should be enabled by default so that display_errors will work.
error_reporting = E_ALL
Sorry to repost an old thread...this is important.
I also was having these problems where no html response was outputting
After double-checking php.ini or my apache conf files and was still receiving no output, I later found out that I was suppressing the error of an include / require of a class, with #, which was nested within a constructor function. There was a syntax error in the included file, which stopped all output altogether when errors were thrown.
So, check your handlers first.
If you are storing all your output into vars first and you are including various scripts first that fail you'll have to see those errors. If you suppress file handler errors, you'll get a blank screen if you have a syntax error in the file.
Search your files for all instances of # in your php code. Then turn #include "/path_to/script.php"; to include "/path_to/script.php"; or anything #$foo into $foo as such var might reference a dependency that is causing your script to end with nothing showing in the httpd error log or in the http response.

Categories