brew path an M1 Apple - php

I'm a little bit confused with the installation path on my mac.
When i run brew info php#7.4 i get the result above
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php7_module /opt/homebrew/opt/php#7.4/lib/httpd/modules/libphp7.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html
The directory is /opt/homebrew/opt/php#7.4
When i run php --ini it shows a different path
/opt/homebrew/etc/php/7.4
Inside /opt/homebrew/etc/php/7.4/bin i have installed 7.4, 8.0 and 8.1
Inside /opt/homebrew/opt i see a list of symlinks, also find symlink for 7.4, 8.0 and 8.1. All symlinks a linked to Cellar.. for example: ./Cellar/php#7.4/7.4.32
In my /opt/homebrew/Cellar path i also find 7.4, 8.0 and 8.1 folder
I'm not sure but why i have to different sources?
/opt/homebrew/etc and /opt/homebrew/opt
Should i delete one of them? Is there a best practise to update the installation pathes?

Related

Can't find symbol sqlite3_enable_load_extension after install PHP on macOS Monterey via brew

install php via brew, follow the instructions like this
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php_module /usr/local/opt/php/lib/httpd/modules/libphp.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html
The php.ini and php-fpm.ini file can be found in:
/usr/local/etc/php/8.1/
To restart php after an upgrade:
brew services restart php
Or, if you don't want/need a background service you can just run:
/usr/local/opt/php/sbin/php-fpm --nodaemonize
==> Summary
🍺 /usr/local/Cellar/php/8.1.0: 512 files, 79.9MB
==> Running `brew cleanup php`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
to enable php and this to sign the php.so.
After this, when i run apachectl configtest, I got error like this
httpd: Syntax error on line 190 of /private/etc/apache2/httpd.conf: Cannot load /usr/local/Cellar/php/8.1.0/lib/httpd/modules/libphp.so into server: dlopen(/usr/local/Cellar/php/8.1.0/lib/httpd/modules/libphp.so, 0x000A): Symbol not found: _sqlite3_enable_load_extension\n Referenced from: /usr/local/Cellar/php/8.1.0/lib/httpd/modules/libphp.so\n Expected in: /usr/lib/libsqlite3.dylib
what should i do?
I struggled with this for 2 days until I finally gave up.
This might not be the answer you're looking for but I installed Apache via Brew and used that httpd instead of the one that came with the OS.
Had everything up and running in 10 minutes after that.

Upgrade to PHP 7.2 version in MacOS

I have installed php7.2 using homebrew. But when i run php -v i still get php7.1. Of which i think it wasn't installed with Homebrew. How can i enable disable 7.1 and enable 7.2.
I have tried this as suggested by the install.
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php7_module /usr/local/opt/php#7.2/lib/httpd/modules/libphp7.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html
Also tried, uncommenting this line in /etc/apache2/httpd.conf
LoadModule php7_module libexec/apache2/libphp7.so
I have solved this by linking the new installed version.
After installing the new php version(7.2) with homebrew, you have to run
brew link php#72 --force
if your previous version was a installed with homebrew, you have to unlink it also. E.g for php 7.1
brew unlink php71
This is for the php CLI(command line), for the Apache PHP you need to edit /etc/apache2/httpd.conf
When you run php -v, you get the version of PHP that is executed from the command line, not the version of PHP executed from Apache.
If you run:
/usr/local/bin/php -version
You will have the version of the PHP installed by Homebrew. To set it as the default PHP interpreter from the command line, your PATH environment variable should contain /usr/local/bin/ before /usr/bin.
To check the version of PHP executed within Apache run phpinfo by browsing the following PHP file:
<?php
phpinfo();

PHP is not working after upgrading macOS from High Sierra to Mojave [duplicate]

I'm trying to execute some PHP code on a project (using Dreamweaver) but the code isn't being run.
When I check the source code, the PHP code appears as HTML tags (I can see it in the source code). Apache is running properly (I'm working with XAMPP), the PHP pages are being opened properly but the PHP code isn't being executed.
Does someone have a suggestion about what is happening?
Note: The file is already named as filename.php
Edit:
The Code..:
<?
include_once("/code/configs.php");
?>
Sounds like there is something wrong with your configuration, here are a few things you can check:
Make sure that PHP is installed and running correctly. This may sound silly, but you never know. An easy way to check is to run php -v from a command line and see if returns version information or any errors.
Make sure that the PHP module is listed and uncommented inside of your Apache's httpd.conf This should be something like LoadModule php5_module "c:/php/php5apache2_2.dll" in the file. Search for LoadModule php, and make sure that there is no comment (;) in front of it.
Make sure that Apache's httpd.conf file has the PHP MIME type in it. This should be something like AddType application/x-httpd-php .php. This tells Apache to run .php files as PHP. Search for AddType, and then make sure there is an entry for PHP, and that it is uncommented.
Make sure your file has the .php extension on it, or whichever extension specified in the MIME definition in point #3, otherwise it will not be executed as PHP.
Make sure you are not using short tags in the PHP file (<?), these are not enabled on all servers by default and their use is discouraged. Use <?php instead (or enable short tags in your php.ini with short_open_tag=On if you have code that relies on them).
Make sure you are accessing your file over your webserver using an URL like http://localhost/file.php not via local file access file://localhost/www/file.php
And lastly check the PHP manual for further setup tips.
php7 :
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php7.0-fpm
sudo service apache2 restart
I'm running Apache on Ubuntu and my issue was that the /etc/apache2/mods-available/php5.conf file was missing this:
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
I added it back in and php was parsing php files correctly.
note for php 7 users, add this to your httpd.conf file:
# PHP 7 specific configuration
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
I found another problem causing this issue and already solved it. I accidentally saved my script in UTF-16 encoding. It seems that PHP5 can't recognize <?php tag in 16 bit encoding by default.
You're just opening your php file into browser. You have to open it using localhost url. if you open a file directly from your directory it will not execute the php code in any case.
use: http://locahost/index.php or http:127.0.0.1/index.php
Enable php short code. In your case, you are using <? which is php short code for <?php. By default php short codes are disabled.
Also use: sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt if you are a ubuntu user.
I'm posting this answer because my Virtualmin/Webmin admin interface decided it was a good idea to disable my PHP engine.. took me a while to find the solution, so I thought I'd share it with you guys:
Also, be sure to check that none of your website config files related to this specific host or virtualhost have any php_admin_value's in them that turn off PHP, like this:
php_admin_value engine Off
When in doubt, comment it...
# php_admin_value engine Off
And restart your webserver.
This just happened to me again, along with the server downloading html files, rather than processing. I had not use the webserver apache for some time on the computer and meanwhile Ubuntu updated like two more versions from originally installed LTS. Now it is
$ cat /etc/issue
Ubuntu 16.04 LTS
So the php worked after like so:
$ sudo apt-get install lamp-server^
$ sudo a2enmod php7.0
$ sudo service apache2 restart
The webserver was now parsing the php. Maybe now got to update some webs since php7.0 now running where as it was before running php5. Oh well.
I know it should sound silly... but seldom it happens.
Check if you are trying to execute php from
**http://localhost/info.php**
and not from
file:///var/www/info.php
ps> you can notice that if you write from shell
php info.php
it answer with the code (it means php functions)..
I've solved this by uninstalling XAMPP, and installing WAMP.
Thanks for the help.
In case we are in the same page do following
sudo apt-get install php -y
sudo apt-get install php-{bcmath,bz2,intl,gd,mbstring,mysql,zip,fpm} -y
To enable PHP 7.2 FPM in Apache2 do:
a2enmod proxy_fcgi setenvif
a2enconf php7.2-fpm
update 2: Apache downloads .php file instead of rendering
After that, I faced above issue. There are similar questions like this.
I don't know why but it only happened for my .php files in /var/www/html/ root folder. everything was ok for sub-directories. (for example wordpress and phpmyadmin worked fine)
So here is my solution. I decided to enable php module. so I ran this command:
a2enmod php7.2
but I got this errors:
Considering dependency mpm_prefork for php7.2:
Considering conflict mpm_event for mpm_prefork:
ERROR: Module mpm_event is enabled - cannot proceed due to conflicts. It needs to be disabled first!
Considering conflict mpm_worker for mpm_prefork:
ERROR: Could not enable dependency mpm_prefork for php7.2, aborting
so I decided to disable mpm by running following commands:
sudo a2dismod mpm_prefork
sudo a2dismod mpm_worker
sudo a2dismod mpm_event
then restart apache:
systemctl restart apache2
then enable php7.2 (my installed version):
sudo a2enmod php7.2
and right now everything works fine.
I faced this issue on php 7.1 that comes with High Sierra (OS X 10.13.5), editing /etc/apache2/httpd.conf with following changes helped:
Uncomment this line
LoadModule php7_module libexec/apache2/libphp7.so
Paste following at the end
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
on my ubuntu 14.04, apache 2.4, php 5.5.9 install, I tried with a sample.php on /var/www/html (default document root) and it worked ok.
So the problem was on my Virtual Servers config.
The solution was to include, on the Directory def containing the .php, this line:
php_admin_flag engine on
Make sure the script contains
<?php
before the code that should be executed. There should be no space between <? and php in this.
Another possible cause of this problem could be that you are trying to run the script in a "user directory" from the UserDir module. Running PHP scripts in user directories is disabled by default. You will run into this problem if the script is in the public_html directory in your home folder and you are trying to access it from http://localhost/~your_username.
To fix this, open up /etc/apache2/mods-enabled/php7.2.conf. You must comment or delete the tag block at the bottom that reads
<IfModule mod_userdir.c>
<Directory /home/*/public_html>
php_admin_flag engine Off
</Directory>
</IfModule>
i had similar problem but in my case solution was different.
my file that held php code was called "somename.html"
changed it to "somename.php" worked fine
For fresh setup of LAMP running php 7
edit the file /etc/httpd/conf/httpd.conf
Note: make sure to make backup for it before changing anything.
Paste this at the very bottom of the file:
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
Then, search for LoadModule and paste the following line:
LoadModule php7_module modules/libphp7.so
This line will simply ask httpd to load the php 7 module
Then restart httpd
Check all the packages you have installed for php using:
yum list installed | grep remi
Install all relevant php packages, especially php-devel on your machine.
Add AddType application/x-httpd-php .php to your httpd.conf file if you are using Apache 2.4
In my case the php module was not loaded. Try this:
Check which modules are loaded: apache2ctl -M. Look for module like php7_module (shared)
If no php module is listed, then try to load the module that corresponds to your php version. In my case the php packet is libapache2-mod-php7.3. So I did: a2enmod php7.3 and the problem was solved.
Easiest way to install Apache + php7 tested using Debian 10:
apt-get update -y
apt-get install apache2 php7.0 libapache2-mod-php -y
sudo service apache2 restart
This was in my .htaccess
DirectoryIndex index.html index.htm
index.html contained PHP code. By default, PHP won't process files with extentions like htm* as PHP code.
You can override this, by adding the following to .htaccess:
<FilesMatch ".+\.html$">
SetHandler application/x-httpd-php
</FilesMatch>
If you have configuration like this:
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/var/www/example.com"
<FilesMatch "\.php$">
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
</VirtualHost>
Uncomment next lines in your httpd.conf
LoadModule proxy_module lib/httpd/modules/mod_proxy.so
LoadModule proxy_fcgi_module lib/httpd/modules/mod_proxy_fcgi.so
It works for me
Try restarting the apache server. This was the mistake I had made - forgetting to restart the server after installing php!
service httpd restart
For php7.3.* you could try to install these modules. It worked for me.
sudo apt-get install libapache2-mod-php7.3
sudo service apache2 restart
I think the problem that it is showing code instead of the result is that it is not going to local host . recheck what address u r going in. are u going to a local file directory or to the local host.
from the screenshot u sent it is going to ur computer not to the localhost.
"file:/// " it should be "localhost/"
Reinstalling the mcrypt module worked for me.
$sudo apt-get install php5-mcrypt
$sudo php5enmod mcrypt
I had a case that I accidentally started untaring my files directory in root. It added the .htaccess file from my files folder that would block all php
# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php5.c>
php_flag engine off
</IfModule>
Bottom line check the .htaccess file on root.
Just spent hours of trying to get PHP 5 to run with Apache 2.4 on Windows 10. Finally for me it was a typo in httpd.conf LoadModule. Drew attention to writing and exact module path through the last answer in this apachelounge thread of denny2018. Thank you!
After two nights I discovered... My directory was written c: (lower case)
I had LoadModule php5_module "c:/php/php5apache2.dll" but correct for apache 2.4 is:
LoadModule php5_module "C:/php/php5apache2_4.dll"
So I also missed the _4 before (for apache 2.4). The full snippet that worked for me:
# PHP
LoadModule php5_module "C:/php/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Just tried PHP 7. There the LoadModule line in httpd.conf for Apache 2.4 reads
LoadModule php7_module "C:/php/php7apache2_4.dll"
Currently php manual shows up c:/php/php5apache2.dll which of course needs to be adjusted.
in my case (Apache/2.4.34),
after uncommenting the specific module
"LoadModule php7_module libexec/apache2/libphp7.so"
from
"/etc/apache2/httpd.conf"
my problem was gone.

The change of php 5.2 to 5.6 modifies the characteristics of the opening and closing script [duplicate]

I'm trying to execute some PHP code on a project (using Dreamweaver) but the code isn't being run.
When I check the source code, the PHP code appears as HTML tags (I can see it in the source code). Apache is running properly (I'm working with XAMPP), the PHP pages are being opened properly but the PHP code isn't being executed.
Does someone have a suggestion about what is happening?
Note: The file is already named as filename.php
Edit:
The Code..:
<?
include_once("/code/configs.php");
?>
Sounds like there is something wrong with your configuration, here are a few things you can check:
Make sure that PHP is installed and running correctly. This may sound silly, but you never know. An easy way to check is to run php -v from a command line and see if returns version information or any errors.
Make sure that the PHP module is listed and uncommented inside of your Apache's httpd.conf This should be something like LoadModule php5_module "c:/php/php5apache2_2.dll" in the file. Search for LoadModule php, and make sure that there is no comment (;) in front of it.
Make sure that Apache's httpd.conf file has the PHP MIME type in it. This should be something like AddType application/x-httpd-php .php. This tells Apache to run .php files as PHP. Search for AddType, and then make sure there is an entry for PHP, and that it is uncommented.
Make sure your file has the .php extension on it, or whichever extension specified in the MIME definition in point #3, otherwise it will not be executed as PHP.
Make sure you are not using short tags in the PHP file (<?), these are not enabled on all servers by default and their use is discouraged. Use <?php instead (or enable short tags in your php.ini with short_open_tag=On if you have code that relies on them).
Make sure you are accessing your file over your webserver using an URL like http://localhost/file.php not via local file access file://localhost/www/file.php
And lastly check the PHP manual for further setup tips.
php7 :
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php7.0-fpm
sudo service apache2 restart
I'm running Apache on Ubuntu and my issue was that the /etc/apache2/mods-available/php5.conf file was missing this:
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
I added it back in and php was parsing php files correctly.
note for php 7 users, add this to your httpd.conf file:
# PHP 7 specific configuration
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
I found another problem causing this issue and already solved it. I accidentally saved my script in UTF-16 encoding. It seems that PHP5 can't recognize <?php tag in 16 bit encoding by default.
You're just opening your php file into browser. You have to open it using localhost url. if you open a file directly from your directory it will not execute the php code in any case.
use: http://locahost/index.php or http:127.0.0.1/index.php
Enable php short code. In your case, you are using <? which is php short code for <?php. By default php short codes are disabled.
Also use: sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt if you are a ubuntu user.
I'm posting this answer because my Virtualmin/Webmin admin interface decided it was a good idea to disable my PHP engine.. took me a while to find the solution, so I thought I'd share it with you guys:
Also, be sure to check that none of your website config files related to this specific host or virtualhost have any php_admin_value's in them that turn off PHP, like this:
php_admin_value engine Off
When in doubt, comment it...
# php_admin_value engine Off
And restart your webserver.
This just happened to me again, along with the server downloading html files, rather than processing. I had not use the webserver apache for some time on the computer and meanwhile Ubuntu updated like two more versions from originally installed LTS. Now it is
$ cat /etc/issue
Ubuntu 16.04 LTS
So the php worked after like so:
$ sudo apt-get install lamp-server^
$ sudo a2enmod php7.0
$ sudo service apache2 restart
The webserver was now parsing the php. Maybe now got to update some webs since php7.0 now running where as it was before running php5. Oh well.
I know it should sound silly... but seldom it happens.
Check if you are trying to execute php from
**http://localhost/info.php**
and not from
file:///var/www/info.php
ps> you can notice that if you write from shell
php info.php
it answer with the code (it means php functions)..
I've solved this by uninstalling XAMPP, and installing WAMP.
Thanks for the help.
In case we are in the same page do following
sudo apt-get install php -y
sudo apt-get install php-{bcmath,bz2,intl,gd,mbstring,mysql,zip,fpm} -y
To enable PHP 7.2 FPM in Apache2 do:
a2enmod proxy_fcgi setenvif
a2enconf php7.2-fpm
update 2: Apache downloads .php file instead of rendering
After that, I faced above issue. There are similar questions like this.
I don't know why but it only happened for my .php files in /var/www/html/ root folder. everything was ok for sub-directories. (for example wordpress and phpmyadmin worked fine)
So here is my solution. I decided to enable php module. so I ran this command:
a2enmod php7.2
but I got this errors:
Considering dependency mpm_prefork for php7.2:
Considering conflict mpm_event for mpm_prefork:
ERROR: Module mpm_event is enabled - cannot proceed due to conflicts. It needs to be disabled first!
Considering conflict mpm_worker for mpm_prefork:
ERROR: Could not enable dependency mpm_prefork for php7.2, aborting
so I decided to disable mpm by running following commands:
sudo a2dismod mpm_prefork
sudo a2dismod mpm_worker
sudo a2dismod mpm_event
then restart apache:
systemctl restart apache2
then enable php7.2 (my installed version):
sudo a2enmod php7.2
and right now everything works fine.
I faced this issue on php 7.1 that comes with High Sierra (OS X 10.13.5), editing /etc/apache2/httpd.conf with following changes helped:
Uncomment this line
LoadModule php7_module libexec/apache2/libphp7.so
Paste following at the end
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
on my ubuntu 14.04, apache 2.4, php 5.5.9 install, I tried with a sample.php on /var/www/html (default document root) and it worked ok.
So the problem was on my Virtual Servers config.
The solution was to include, on the Directory def containing the .php, this line:
php_admin_flag engine on
Make sure the script contains
<?php
before the code that should be executed. There should be no space between <? and php in this.
Another possible cause of this problem could be that you are trying to run the script in a "user directory" from the UserDir module. Running PHP scripts in user directories is disabled by default. You will run into this problem if the script is in the public_html directory in your home folder and you are trying to access it from http://localhost/~your_username.
To fix this, open up /etc/apache2/mods-enabled/php7.2.conf. You must comment or delete the tag block at the bottom that reads
<IfModule mod_userdir.c>
<Directory /home/*/public_html>
php_admin_flag engine Off
</Directory>
</IfModule>
i had similar problem but in my case solution was different.
my file that held php code was called "somename.html"
changed it to "somename.php" worked fine
For fresh setup of LAMP running php 7
edit the file /etc/httpd/conf/httpd.conf
Note: make sure to make backup for it before changing anything.
Paste this at the very bottom of the file:
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
Then, search for LoadModule and paste the following line:
LoadModule php7_module modules/libphp7.so
This line will simply ask httpd to load the php 7 module
Then restart httpd
Check all the packages you have installed for php using:
yum list installed | grep remi
Install all relevant php packages, especially php-devel on your machine.
Add AddType application/x-httpd-php .php to your httpd.conf file if you are using Apache 2.4
In my case the php module was not loaded. Try this:
Check which modules are loaded: apache2ctl -M. Look for module like php7_module (shared)
If no php module is listed, then try to load the module that corresponds to your php version. In my case the php packet is libapache2-mod-php7.3. So I did: a2enmod php7.3 and the problem was solved.
Easiest way to install Apache + php7 tested using Debian 10:
apt-get update -y
apt-get install apache2 php7.0 libapache2-mod-php -y
sudo service apache2 restart
This was in my .htaccess
DirectoryIndex index.html index.htm
index.html contained PHP code. By default, PHP won't process files with extentions like htm* as PHP code.
You can override this, by adding the following to .htaccess:
<FilesMatch ".+\.html$">
SetHandler application/x-httpd-php
</FilesMatch>
If you have configuration like this:
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/var/www/example.com"
<FilesMatch "\.php$">
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
</VirtualHost>
Uncomment next lines in your httpd.conf
LoadModule proxy_module lib/httpd/modules/mod_proxy.so
LoadModule proxy_fcgi_module lib/httpd/modules/mod_proxy_fcgi.so
It works for me
Try restarting the apache server. This was the mistake I had made - forgetting to restart the server after installing php!
service httpd restart
For php7.3.* you could try to install these modules. It worked for me.
sudo apt-get install libapache2-mod-php7.3
sudo service apache2 restart
I think the problem that it is showing code instead of the result is that it is not going to local host . recheck what address u r going in. are u going to a local file directory or to the local host.
from the screenshot u sent it is going to ur computer not to the localhost.
"file:/// " it should be "localhost/"
Reinstalling the mcrypt module worked for me.
$sudo apt-get install php5-mcrypt
$sudo php5enmod mcrypt
I had a case that I accidentally started untaring my files directory in root. It added the .htaccess file from my files folder that would block all php
# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php5.c>
php_flag engine off
</IfModule>
Bottom line check the .htaccess file on root.
Just spent hours of trying to get PHP 5 to run with Apache 2.4 on Windows 10. Finally for me it was a typo in httpd.conf LoadModule. Drew attention to writing and exact module path through the last answer in this apachelounge thread of denny2018. Thank you!
After two nights I discovered... My directory was written c: (lower case)
I had LoadModule php5_module "c:/php/php5apache2.dll" but correct for apache 2.4 is:
LoadModule php5_module "C:/php/php5apache2_4.dll"
So I also missed the _4 before (for apache 2.4). The full snippet that worked for me:
# PHP
LoadModule php5_module "C:/php/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Just tried PHP 7. There the LoadModule line in httpd.conf for Apache 2.4 reads
LoadModule php7_module "C:/php/php7apache2_4.dll"
Currently php manual shows up c:/php/php5apache2.dll which of course needs to be adjusted.
in my case (Apache/2.4.34),
after uncommenting the specific module
"LoadModule php7_module libexec/apache2/libphp7.so"
from
"/etc/apache2/httpd.conf"
my problem was gone.

apache2.4 build not finding php5.3

I am setting up a test server before upgrading an elderly version of mediawiki on a production server. I am trying to duplicate what will be on the production server - apache2.4 and php5.3.
When I try to access any php file, the server displays it as text rather than running it.
This is all running on Ubuntu 12.04 LTS. The apache package available is version 2.2, so I can't simply apt-get.
I have built apache 2.4 from source, and it correctly serves an index.html from my designated DocumentRoot.
In httpd.conf, I have added:
DocumentRoot = /var/www
AddType application/x-httpd-php .php
<filesMatch>"\.php$:"
SetHandler application/x-httpd-php .php
</filesMatch>
I have installed php5.3, and it is working - I can run phpinfo.php from a command line.
In /etc/php5/apache2/php.ini I have (error displays are for testing only):
engine = On
display_errors = On
display_startup_errors = On
doc_root = /var/www
I am not able to find a reference to a mod_php of any sort either in the httpd.conf or in the directory in which httpd is installed (/usr/local/apache2).
Some of the references on the web mention "modules-available" and "modules-enabled" but these appear to be a convenience added by Debian, and are not part of the apache source build.
What am I missing? I'm sure it's something simple.
After searching and using packages from several repositories for both apache and php, and trying to build either or both from source, I determined that there did not seem to be a libphp5.so that was compatible with apache 2.4. In any case, I didn't find it.
I reconfigured everything to use php as cgi rather than as a module, and got things working that way, which was enough for my intended purpose.
You need to load php module in httpd.conf:
On my Linux Slackware I have this in /etc/httpd/mod_php.conf
LoadModule php5_module lib/httpd/modules/libphp5.so
# Tell Apache to feed all *.php files through PHP. If you'd like to
# parse PHP embedded in files with different extensions, comment out
# these lines and see the example below.
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
And in /etc/httpd/httpd.conf:
# php
Include /etc/httpd/mod_php.conf

Categories