I just updated Ubuntu to version 18.04 and I have version 7.2 of PHP, if I execute the command "php -v" I get this result
root#laptop1:/etc/apache2/sites-enabled# php -v
PHP 7.2.3-1ubuntu1 (cli) (built: Mar 14 2018 22:03:58) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.3-1ubuntu1, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
root#laptop1:/etc/apache2/sites-enabled#
However, if I run the phpinfo() command inside a php file through a web browser I get the following: it tells me that I have version 7.1 of PHP and that I do not have the Xdebug activated.
For this reason Xdebug does not work with my PhpStorm IDE; I do not know if the best option is to delete all the PHP versions installed and leave one that is not as recent as 7.0 or 7.1.
There is a difference between what version of PHP you use in your terminal and what version your web-server (in example apache2) is using. If you have apache2, you can change the version of PHP to 7.2 with the following commands:
Dissable PHP 7.1:
sudo a2dismod php7.1
Enable PHP 7.2:
sudo a2enmod php7.2
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php7.2-fpm
After that restart apache2:
sudo service apache2 restart
Related
I want to install gRPC for PHP 7.3. I followed Google Cloud documentation.
I use ubuntu 16.04, Nginx
I install:
sudo apt-get install autoconf zlib1g-dev php-dev php-pear
sudo pecl install grpc
But I am getting this error:
No releases available for package "pecl.php.net/grpc"
install failed
I don't know what is wrong.
It is php -v
PHP 7.3.22-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Sep 9 2020 06:46:12) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.22, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.22-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
Please, help me.
I'm trying to update php. When I check my php version, it returns:
php -v
PHP 5.5.12 (cli) (built: Mar 10 2017 16:27:17)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
So I added ondrej's repository
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.0
But STILL:
php -v
PHP 5.5.12 (cli) (built: Mar 10 2017 16:27:17)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
I don't know what to do anymore... Already tried purge, everything... this php doesn't upgrade, it remains this version. Any ideas?
If you have this problem while upgrading from PHP5 to PHP7 on Ubuntu 16.04
with Apache, here's what helped me (credit goes here):
Disable PHP5 module on Apache:
sudo a2dismod php5
Now enable PHP7:
sudo a2enmod php7.1
To reflect changes Apache restart is required:
sudo systemctl restart apache2
By the way run phpinfo() in your script take a look which version is this running. Command line php is a complete separate system
Try to run First :
sudo apt-get upgrade
And then : For PHP 5.5, PHP 5.6 and PHP 7.0:
sudo apt-add-repository ppa:ondrej/php
You have flipped "apt" and "add". Please take a look at your command.
Then the other steps that you made.
I had an outdated version of PHP on my system, so attempted to upgrade from 5.5.9 to 5.6.
I followed the following steps on my Digital Ocean Ubuntu droplet:
I installed Ondřej Surý's PPA and selected 5.6 as well as other packages related to the main one, like the XML package.
When I do php -v on my server, it says
PHP 5.6.29-1+deb.sury.org~trusty+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
This indicated to me that the update went through.
But when I restart my apache server and check the error logs, it says
Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.20 configured -- resuming normal operations
I believe the latest version of Magento on my server is giving me this error (HTTP 500) because it is using the wrong version of PHP...
How do I fix this? Thank you.
The digital ocean community site here offered a couple of extra commands:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5.6 php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml
sudo a2dismod php5
sudo a2enmod php5.6
sudo service apache2 restart
Note the a2dismod and a2enmod steps. The post says:
Without the a2dismod/a2ensmod steps, Apache will continue to see your older version of PHP, even if command line is seeing the new version.
I have a Vaprobash VagrantFile building a Ubuntu Nginx stack.
In it I specify PHP v5.6:
php_version = "5.6" //Options: 5.5 | 5.6
However, I run
$ vagrant up
when I ssh into the box and do
$ php -v
it shows PHP 5.5.9-1ubuntu4.20 (cli) (built: Oct 3 2016 13:00:37).
Why wasn't 5.6 installed?
I am not sure this repo has been updated for php after the ppa has been migrated (see https://github.com/oerdnj/deb.sury.org/wiki/PPA-migration-to-ppa:ondrej-php)
basically in scripts/php.sh you need to replace ppa by
sudo add-apt-repository ppa:ondrej/php
(make sure to run sudo apt-get update if you're running this command directly from the VM after the initial provisioning) -
and to install php5.6 you need to run
sudo apt-get install -qq libapache2-mod-php5.6
with this change, you now get
vagrant#vaprobash:~$ php -v
PHP 5.6.28-1+deb.sury.org~trusty+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
If you need additional php modules, make sure to replace the installation by specifying 5.6 in your php version such as
sudo apt-get install -qq php5.6-fpm
Whenever I try to run this code
example#testserver:~$ sudo apt-get install php5-xdebug
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php5-xdebug
I get this error "E: Unable to locate package php5-xdebug"
Please help
Thanks
If you're running the default apt installation of PHP on Ubuntu 16.04, then it should be PHP7. If I had to guess from php5-xdebug, then I'd say you were using a command intended for Ubuntu 14.04 or older where the default PHP installation was PHP5. You can verify your PHP version with:
php --version
This is what I see:
PHP 7.0.8-0ubuntu0.16.04.2 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.8-0ubuntu0.16.04.2, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
At any rate, you should be able to search available packages for your configuration with:
apt search xdebug
From my relatively fresh Ubuntu 16.04 install without any added PPA's, I get one result:
php-xdebug - Xdebug Module for PHP
So you can install this package by name (note the missing "5" from your command):
sudo apt install php-xdebug
You might also have to restart your webserver. If you're running the stock build of Apache for Ubuntu 16.04:
sudo service apache2 restart