cannot update php 7 cli in my mac - php

To install php7 I run:
curl -s http://php-osx.liip.ch/install.sh | bash -s 7.1
php -v
It show php 5.6.30
Then, I run this in my terminal:
export PATH=/usr/local/php5/bin:$PATH
php-v
It show the latest version of php : 7.1 .
When I closing the terminal and run the php -v again.
it show the old version php again 5.6.30
Why is this happening?

Related

OSX - phpinfo() and php -v versions are different

I've formatted my computer, install Homebrew and run brew install php && brew upgrade php, and after check my php version with php -v shows me 7.4 that's correct. But when I run phpinfo() in localhost, shows me php version is 7.1.
I have put paths to .bash_profile file like that
export PATH=/usr/local/Cellar/php/7.4.5_1/bin:$PATH
export PATH=/usr/local/Cellar/php/7.4.5_1/sbin:$PATH
php -v is true, php-fpm -v is true but apache shows me PHP Version 7.1.23
How can I fix this?

Set php version in CentOS 6

I just successfully upgraded my server php version from 5.3 to 5.6
When I run:
php -v
I get:
PHP 5.6.40 (cli)
But when I create a file write
echo phpInfo();
The php version showing is 5.3.3
How do I set the php version on phpinfo() to show 5.6
Thanks,
Try this..
rm /usr/bin/php
ln -s /usr/bin/php56 /usr/bin/php
service httpd restart
And then run
php -v

Mac OSX Terminal Setting PHP path not permanent

I've got a MAC OSX (Capitan to be precise).
I have installed PHP7 by using this line of code in the terminal:
curl -s http://php-osx.liip.ch/install.sh | bash -s 7.0
After it installed I run this:
export PATH=/usr/local/php5/bin:$PATH
After this when I run:
PHP -v
I get PHP 7.0.10 (cli) (built: Aug 31 2016 10:25:51) ( NTS )...
when is what I need it to do, so great BUT my problem is that as soon as I close my terminal and I run PHP -v again I get PHP 5.5
Why doesn't it keep PHP 7.0 ?
Add export PATH=/usr/local/php5/bin:$PATH to your ~/.profile dotfile so that the PATH variable is exported when you start your system (requires restart).
Or add it to ~/.bashrc file so that it gets exported when you start you start bash.
I recommend using ~/.profile.

Ampps selected PHP 5.6 by PHP -v says it's got PHP 5.5

I'm using a Mac and AMPPS ... I've selected to use PHP 5.6 and I have been able to install Magento 2 which has min requirements of PHP 5.6.
Magento 2 is installed and working fine.
Now, when I open my terminal and type: PHP -v
It says I'm using PHP 5.5.
Why could this be happening, any ideas?
I found a solution that worked for me. I was basically installing the php update but I also needed to set the path so he's the solution:
1. curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6
2. export PATH=/usr/local/php5/bin:$PATH
3. php -v
You'll now get version 5.6

How to check if there are multiple versions of PHP installed on Ubuntu 12.04 LTS?

How to know if I have both php5.3 and php5.5 installed in my system? How to delete php5.3 if it is there and configuring Apache2 to work with php5.5?
I use the following command to view installed PHP versions in Ubuntu:
sudo update-alternatives --list php
Second way go to php directory where all PHP version configuration file stored:
cd /etc/php
dir
Output:
> 5.6 7.0 7.1
Since you have a Linux environment, you can run this on your console:
locate bin/php
And then for anything that looks like a PHP binary, get the version. The output for me for the above is:
/home/xx/Development/Personal/Project1/webapp/bin/phpunit
/home/xx/Development/Personal/Project1/webapp-backup/vendor/bin/phpunit
/home/xx/Development/Personal/Project2/app/vendor/bin/phpunit
/home/xx/php-threaded/bin/php
/home/xx/php-threaded/bin/php-cgi
/home/xx/php-threaded/bin/php-config
/home/xx/php-threaded/bin/phpize
/usr/bin/php
/usr/bin/php5
/usr/local/bin/php-cgi
/usr/local/bin/php-config
/usr/local/bin/php53
/usr/local/bin/phpize
/usr/sbin/php5dismod
/usr/sbin/php5enmod
/usr/sbin/php5query
Out of those, there are a few that look like PHP binaries. So let's get the version for each:
/home/xx/php-threaded/bin/php -v
/usr/bin/php -v
/usr/bin/php5 -v
/usr/local/bin/php53 -v
That will give you the versions of PHP you have installed.
I wouldn't bother deleting an old version, it might remove files that will stop things working. You can just configure the console version, or the Apache version, to use the version you want.
In answer to your supplementary question: it seems that you've followed the instructions here to add an unofficial repo to your version of Ubuntu, since the standard repo does not support 5.5.
We discovered together that the way to get it working was first to upgrade Apache from 2.2 to 2.4:
sudo apt-get upgrade apache2
It should be noted that this can cause some vhost repair to be required, as some Apache directives changed in this version. Once you have done that, you can get the new version of mod_php:
sudo apt-get install libapache2-mod-php5
To check your installed versions type:
cd /etc/php
in your terminal to go to the configuration folder of your PHP installations and then you type:
ls
The output will be the folders that corresponds to the versions installed in your machine. In my case the command outputs:
5.6 7.0 7.1
I am always using this command to see list of PHP versions and also for switching one version to another install PHP version.
sudo update-alternatives --config php
You can run this on your console:
find / -name php | grep bin
I use the following to view installed php versions in Ubuntu:
sudo dpkg --list | grep ' php[0-9]\.[0-9] '
Get a list of all installed packages and filter installed PHP versions:
sudo apt list --installed 2>/dev/null | cut -d / -f 1 | grep ^php[0-9].[0-9]$;
or
sudo apt list --installed 2>/dev/null | cut -d / -f 1 | grep ^php[0-9].[0-9]$ | xargs;
if you really need to get only installed PHP versions without unnecessary.
Or
sudo update-alternatives --list php;

Categories