Brill - thanks for that!
When I enter php -v I get PHP 7.0.6 (cli) (built: May 1 2016 08:12:21) ( NTS )
But phpinfo() still displays PHP Version 5.5.9-1ubuntu4.14
Is there something I need to do for the two to sync?
I have the same problem that paulkd, after trying switching to php7 both using phpbrew and ppa repository (sudo add-apt-repository ppa:ondrej/php) - php -v points to new 7.0.7 from homebrew, but not apache.
service apache2 restart does not affect apache version.
I looked at apache2.conf, but couldn’t find any settings related to php interpreter version, not in conf.d
I had the same problem. You have to disable the php5 module in apache2 and then enable the php7 module:
$ sudo a2dismod php5 $ sudo a2enmod php7.0
When I did this I got an error ‘could not parse envvars’ but I solved this by temporarily renaming this file in the /etc/apache2 directory. The restart apache and now it worked for me.
If you do not see php7.0 module then do the following:
$ sudo add-apt-repository ppa:ondrej/php -y $ sudo apt-get update -y $ sudo apt-get install php7.0-curl php7.0-dev php7.0-gd php7.0-intl php7.0-mcrypt php7.0-json php7.0-mysql php7.0-opcache php7.0-bcmath php7.0-mbstring php7.0-soap php7.0-xml $ sudo apt-get install libapache2-mod-php7.0 -y
Now you should be able to enable the module.
Thanks I updated the PHP version. Is there any way to update the syntax highlighting?
// importing a function (PHP 5.6+)
use function My\Full\functionName;
The current highlighting is 5.5
Anyone still struggling I have included a list of commands to upgrade to php7 as part of my post here Laravel 5.3 Installation on Cloud9
It works for me. Thank you very much!
If anyone is trying the solution OP posted, you may encounter a problem when you run
$ phpbrew switch php-7.0.1
You may get an error along the lines of:
bash: Invalid: command not found
This is because the version of PHP installed has changed, so you need to change the version you switch to as well. To find which is the current version, run
$ phpbrew list
$ phpbrew list * (system) php-7.0.16 php-5.6.30
Adapt the remaining commands as appropriate i.e.
$ phpbrew switch php-7.0.16 $ phpbrew use php-7.0.16 $ php -v PHP 7.0.16 (cli) (built: Jun 5 2017 06:03:59) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
Thank you, I upgraded PHP5 to PHP7 with the help of your comment.
This article is not ok, because apache still keeps using the older version of PHP
This is what i get :
$ phpbrew install 7.0 +default ===> phpbrew will now build 7.0.24 ===> Loading and resolving variants... Downloading http://www.php.net/get/php-7.0.24.tar.bz2/from/this/mirror via curl extension [==================================================================] 184.00/184.00B 100% Redirecting to http://php.net/get/php-7.0.24.tar.bz2/from/this/mirror Redirecting to http://php.net/distributions/php-7.0.24.tar.bz2 [==================================================================] 13.95/13.95MB 100% ===> Extracting /home/ubuntu/.phpbrew/distfiles/php-7.0.24.tar.bz2 to /home/ubuntu/.phpbrew/build/tmp.1508371882/php-7.0.24 ===> Moving /home/ubuntu/.phpbrew/build/tmp.1508371882/php-7.0.24 to /home/ubuntu/.phpbrew/build/php-7.0.24 ===> Checking patches... Checking patch for replace apache php module name with custom version name ===> Configuring 7.0.24... Use tail command to see what's going on: $ tail -F /home/ubuntu/.phpbrew/build/php-7.0.24/build.log Error: Configure failed: The last 5 lines in the log file: checking for cURL in multiarch path... not found ./configure: line 410: test: please: integer expression expected configure: error: reinstall ./configure: line 299: return: please: numeric argument required ./configure: line 309: exit: please: numeric argument required Please checkout the build log file for more details: tail /home/ubuntu/.phpbrew/build/php-7.0.24/build.log
For anyone still needing to upgrade to PHP7. I wrote a bash script to make the process painless. Below is a link to the scripts GitHub page. All you need to do is run 3 commands in the terminal and you’re upgraded.
It would be great if you could make it update to PHP 7.2 But this was awesome. Thank you.
It would be great if you guys updated this for the latest version of PHP as this did not work for me.
No promises, if I get some time I’ll give it a whirl. If you do it, please fork though github and do a pull request with the new code. So others can use it. Glad it helped none the less.
To anyone who visits this nowadays, there is a script that will automatically do this for you. It is located Here.
It allows a faster way to update, and it requires 1 command.
Thanks! I did find one very minor error that I opened an issue for, but it was easy to work around – after that, it worked like a charm and
phpinfo(); confirms I’m on 7.0.28 now.
$ phpbrew list
Adapt the remaining commands as appropriate i.e.
phpbrew switch php-7.0.16
phpbrew use php-7.0.16
$ php -v
PHP 7.0.16 (cli) (built: Jun 5 2017 06:03:59) ( NTS )
Copyright © 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright © 1998-2017
I can’t figure out why when I try to upgrade from php 5.6 to php 7 with a Wordpress install – Wordpress won’t recognize the upgrade.
I have done it before on C9 and it worked fine. But now it’s not working. WHen i do php -v it says 7 but when i do php info it says different.
Please assist. This is what worked before:
sudo add-apt-repository ppa:ondrej/php -y
sudo apt-get update -y
sudo apt-get install php7.0-curl php7.0-cli php7.0-dev php7.0-gd php7.0-intl php7.0-mcrypt php7.0-json php7.0-mysql php7.0-opcache php7.0-bcmath php7.0-mbstring php7.0-soap php7.0-xml php7.0-zip -y
sudo mv /etc/apache2/envvars /etc/apache2/envvars.bak
sudo apt-get remove libapache2-mod-php5 -y
sudo apt-get install libapache2-mod-php7.0 -y
sudo cp /etc/apache2/envvars.bak /etc/apache2/envvars
find out what version of php
I’m stuck at the
$ phpbrew install 7.0 +default command. Returning the following error:
Error: Configure failed: The last 5 lines in the log file: checking for cURL in default path... not found checking for cURL in multiarch path... not found ./configure: line 23550: curl-dir: No such file or directory checking for cURL 7.10.5 or greater... ./configure: line 23565: curl-config: command not found configure: error: cURL version 7.10.5 or later is required to compile php with cURL support Please checkout the build log file for more details: tail /home/ubuntu/.phpbrew/build/php-7.0.30/build.log