I following this link to upgrade my php from 5.6 to 7.2
and its successfully installed
PHP 7.2.14 (cli) (built: Jan 8 2019 12:06:12) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.14, Copyright (c) 1999-2018, by Zend Technologies
here my httpd
Server version: Apache/2.4.6 (CentOS)
Server built: Nov 5 2018 01:47:09
after trying to phpinfo() I got apache doesn't works. Its produce php code rather than compiling.
I check my httpd.conf, there are no LoadModule for php7Module. So I add LoadModule as bellow
LoadModule php7_module modules/libphp7.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
and checking libphp7.so and guess what, there are no libphp7.so at modules directory.
However, I still figuring out what I miss. I install bellow dependencies
php72 php72-php-fpm php72-php-mysqlnd php72-php-opcache php72-php-xml
php72-php-xmlrpc php72-php-gd php72-php-mbstring php72-php-json
Ps. I running CentOS Linux release 7.6.1810 (Core)
Update 1
getsebool -a | egrep 'cgi|builtin_scriptin'
httpd_builtin_scripting --> on
httpd_enable_cgi --> on
I think that PHP isn't enabled in Apache. How to make it works?
Try to restart/start apache2
sudo systemctl restart httpd.service
If still issue persists, then
sudo systemctl status httpd.service
Related
I have installed php 8.0.15 on my Debian 10 (GCP vm)
php -v
PHP 8.0.15 (cli) (built: Jan 29 2022 07:37:39) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.15, Copyright (c) Zend Technologies
with Zend OPcache v8.0.15, Copyright (c), by Zend Technologies
But my wordpress site still on php 7.4
I used a2dismod, a2enmod, apache2 restart - its doesnt help.
What could be the problem? Thanks
If you are having multiple php versions and want to use different version and output the same in phpinfo() type the following:
To disable the current version for example php8.1:
sudo a2disconf php8.1-fpm
To enable php7.4-fpm:
sudo a2enconf php7.4-fpm
Then restart apache using this command:
sudo systemctl restart apache2
After doing this check using phpinfo() function.
Please check if you have installed php8.1-fpm or php7.4-fpm
I was using the built in macos big sur apache and php, but an update deleted all the preferences that i had in apache...as it allways does.
This time i wanted to install the homebrew version of apache and php, and followed all the indications:
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.0/
after i configure everything, check the config file with: sudo apachectl configtest and returned ok. i test my new php with: php -v and it returns the same php that i had before install the hombrew version:
WARNING: PHP is not recommended
PHP is included in macOS for compatibility with legacy software.
Future versions of macOS will not include PHP.
PHP 7.3.24-(to be removed in future macOS) (cli) (built: Dec 21 2020 21:33:25) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.24, Copyright (c) 1998-2018 Zend Technologies
if i run /usr/local/bin/php -v directly from the brew php folder:
PHP 8.0.3 (cli) (built: Mar 4 2021 20:45:17) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.3, Copyright (c) Zend Technologies
with Zend OPcache v8.0.3, Copyright (c), by Zend Technologies
how can i use the brew php?
It's usually not a good idea to remove system binaries. Instead, you can add an alias in the ~/.zshrc file. At the end of the file, add:
alias php="/usr/local/bin/php"
the solution was to put this in ~/.bash-profile
export PATH=/usr/local/bin:$PATH
the restart the pc, and it was ready, now when i php -v
PHP 8.0.3 (cli) (built: Mar 4 2021 20:45:17) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.3, Copyright (c) Zend Technologies
with Zend OPcache v8.0.3, Copyright (c), by Zend Technologies
On Centos 7 I have installed HTTPD and PHP5.4 (I know it's old, but a package I am using needs PHP 5.4)
[root#devserver sites-enabled]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root#devserver sites-enabled]# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built: Jun 27 2018 13:48:59
[root#devserver sites-enabled]# php -v
PHP 5.4.16 (cli) (built: Apr 12 2018 19:02:01)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
Apache runs fine and shows that php5 is loaded:
[root#devserver sites-enabled]# httpd -M | grep php
php5_module (shared)
I have httpd.conf set up to load the module via the 10-php.conf
# 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>
[root#devserver modules]# ls /etc/httpd/modules/ |grep php
libphp5.so
However, when I try to load a basic phpinfo page, I only see
<?php
phpinfo();
?>
Instead of http processing the php. /var/www/html/error.log and /etc/httpd/logs/error.log are both clean. Actually, they're totally empty.
Anybody have any ideas what could be going on?
I am trying for days to enable php on my server. The web server is up, but php is not parsed.
First things first: the server is a CentOS 7 running apache2 and php 7.
Everythign seems to be correctly installed:
OS: uname -a
Linux rafiki 3.10.0-327.10.1.el7.x86_64 #1 SMP Tue Feb 16 17:03:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
and :cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
apache: httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built: Jul 18 2016 15:30:14
PHP: php -v
PHP 7.0.10 (cli) (built: Aug 20 2016 07:47:25) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.10, Copyright (c) 1999-2016, by Zend Technologies
Then, in /etc/httpd/conf/httpd.conf there is this line:
Include conf.modules.d/*.conf
And in /etc/httpd/conf.modules.d/:
10-php.conf 00-base.conf 00-dav.conf 00-lua.conf 00-mpm.conf 00-proxy.conf 00-systemd.conf 01-cgi.conf
10-php.conf content:
<IfModule prefork.c>
LoadModule php7_module modules/libphp7.so
</IfModule>
<IfModule !prefork.c>
LoadModule php7_module modules/libphp7-zts.so
</IfModule>
Here is output for ls /etc/httpd/modules/ | grep php
libphp7.so
libphp7-zts.so
In /var/www/, there is a test.php file, which content is:
<?php phpinfo(); ?>
When I try http://[myserver.domain]/test.php, apache serves the raw file, without parsing php code.
I went through a lot of researches including StackOverflow, but none of the results had a solution working for me.
Can someone please help me to get php run properly? Is there something I am doing wrong ?
Solution:
As pointed out by #kyshel, a simple reboot worked.
Try rebooting the server (as others have already suggested). It worked for me.
I built custom php-7 for pthread
$ php -v
PHP 7.0.6 (cli) (built: May 20 2016 14:04:16) ( ZTS DEBUG )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
But running localhost/info.php with code
<?php phpinfo(); ?>
outputs PHP Version 5.6.11-1ubuntu3.3
How do I enable PHP7 to Apache
You can check and run following commands to enable php 7 on your browser.
If you have php7 enabled in apache it should look something like
ls /etc/apache2/mods-enabled/ | grep php
php7.0.conf
php7.0.load
If php7.0 is an availible mod you should be able to
sudo a2dismod php5
sudo a2enmod php7.0
sudo service apache2 restart