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
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 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
I have installed fresh copy of lumen 5.6 on my ubuntu machine. I also upgrade my php version from php 5.6.* to 7.2.5. Now php 7.2.5 version is enabled on my system. But when I run the project I receive frollowing exceptoion
Parse error: syntax error, unexpected '?'
/home/example/apis/lumen/vendor/symfony/http-foundation/Response.php
Below is my php version
PHP 7.2.5-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: May 5 2018 04:59:13) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.5-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
Guide to solve this problem or suggest any usefull link
If you create an info.php file inside your lumen public/ folder and open it on your server
<?php // info.php filename
phpinfo();
there is a good chance it is still referencing php 5.6?
You do not mention if you are serving the project via php -S, apache or nginx.
I am going to presume you are using apache as it mostly the default on Ubuntu. Disable the php 5.6 module for apache and enable the php 7.2 module. Something like the following will work.
Disable php 5
sudo a2dismod php5
Enable php 7.2
sudo a2enmod php7.2
Restart apache
sudo service apache2 restart
Just installed a clean copy of ubuntu and php (to start a wordpress blog)
As recommended here, I installed php with
sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql
Which worked great. I can even confirm that PHP v7.0.22 is installed -
> php --version
PHP 7.0.22-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.22-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies
I made some changes to Nginx in order to get it to read PHP files, and I'm trying to restart the php service -
> sudo service php7.0-fpm restart
Failed to restart php7.0-fpm.service: Unit php7.0-fpm.service not found.
- which it's claiming is not found.
In fact, it looks like there is no service at all with a name like "php" installed when I run sudo service --status-all to list everything.
Do I have to do something extra to install the PHP service?
Thanks!
Why I am getting 2 different versions of php ?
When I am checking via a php file:
<?php
echo 'Current PHP version: ' . phpversion();
output:
Current PHP version: 7.0.18-1+deb.sury.org~xenial+1
When I am checking via a terminal command:
root#dev-Inspiron-N5110:~# php -v
PHP 7.1.4-1+deb.sury.org~xenial+1 (cli) (built: Apr 11 2017 22:12:32)
( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.4-1+deb.sury.org~xenial+1, Copyright (c) 1999-
2017, by Zend Technologies
php -v giving me PHP 7.1.4-1+deb.sury.org~xenial+1 and phpversion() giving me 7.0.18-1+deb.sury.org~xenial+1.
That is because you have two different versions installed for PHP. The PHP cli is picking up the latest one whereas Apache has been set up with php 7.0.
What you can do is remove both the PHP version from your system and then do a fresh install again:
sudo apt-get install ppa-purge
sudo ppa-purge ppa:ondrej/php-7.0
sudo apt-get purge php7.*
and then install latest PHP 7 from the official Ubuntu Repository like so:
sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql
as you are using Ubuntu 16 the new PHP version will be >=7