I have a very annoying problem. I have 2 versions of PHP on MacOS Catalina, and no matter what I do, I cant seem to get rid of the old (php 7.3.x) version. I can't change anything in /usr/bin/ on my Mac, even though I'm an admin user.
The 2 versions of PHP are:
$ /usr/bin/php -v
PHP 7.3.11 (cli) (built: Apr 17 2020 19:14:14) ( NTS )
$ /usr/local/bin/php -v
PHP 7.4.9 (cli) (built: Aug 7 2020 19:23:06) ( NTS )
Even though which php and php -v use 7.4:
$ which php
/usr/local/bin/php
$ php -v
PHP 7.4.9 (cli) (built: Aug 7 2020 19:23:06) ( NTS )
The problem is that when my cron job runs, it uses /usr/bin/php (version 7.3.x), making my cron job fail (turns out some Laravel package code - specifically Mailcoach - is not compiant with php 7.3.* and NEEDS php v 7.4 or above.
This is what my PATH variable looks like:
$ echo $PATH
/usr/local/bin/php:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:./vendor/bin:/usr/local/sbin:/Users/kunalpunjabi/.composer/vendor/bin:/usr/local/mysql/bin:/usr/local/bin/mysql
If you've encountered this before or know how to fix it, please help!
Did you install them trough homebrew?
If so try linking php7.4
First look at what php is currently running trough
brew services list
Then stop and unlink that version with
brew services stop {PHP}
brew unlink {PHP}
Then link the correct version
brew link --force --overwrite php#7.4
brew services start php#7.4
Could you try this?
If this not works, could you upload a screenshot of your 'brew services list'
Related
I am trying to install php 5.6 on centos 8. I understand it is no longer supported (eol), but due to an old project, it needs it.
I have tried:
sudo dnf --enablerepo=remi install php56
Installs with no issue, hitting localhhost/ throws an error
Running php --version gives me an error
bash: /usr/bin/php: No such file or directory
Howver running php56 --version works.
How do i make it such that any reference to php will use php56?
The Software Collections are designed for parallel installation of multiple versions. So you have to enable the collection of the version you want.
Example:
$ module load php80
$ php -v
PHP 8.0.9 (cli) (built: Jul 29 2021 12:53:58) ( NTS gcc x86_64 )
$ module load php56
$ php -v
PHP 5.6.40 (cli) (built: Jun 28 2021 00:00:00)
For web server, if only one version is installed, it will be used for all pages.
If multiple versions are installed you have to set the proper handler (socket path) for each vhost / project / directory to use the wanted FPM backend.
How do i make it such that any reference to php will use php56?
If you really need only one version, you can also install the php56-syspaths package, which provides /usr/bin/php (a symlink)
To be more precise, I don't even see where PHP 7.1 is installed.
When I run php -v in the terminal, I get:
PHP 7.1.23 (cli) (built: Feb 22 2019 22:19:32) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
So I thought I would use Homebrew to unlink 7.1 and install 7.2. Should be straightforward. However, running brew unlink php71 returns an error saying:
No such keg: /usr/local/Cellar/php71
And, indeed, in /usr/local/Cellar there is nothing resembling a PHP version.
I tried running brew update and brew upgrade just in case, but it didn't help.
I also tried running a PHP application locally and did phpinfo() within the application, and I got the same version info I got in the console.
When I ran whereis php it gave me the result /usr/bin/php. When I ran whereis php71 it came up with nothing which, I suppose, is to be expected in this situation.
The question is, how do I replace PHP 7.1 with 7.2 in the least painful way? Ideally, I would like to get brew to do this so I can update future version through brew as well.
Mac OS has its own PHP version installed, which is complete independent from brew.
You need to force link your brew version.
brew link php#7.2 --force
I tried to install Phalcon PHP but I got an error
php 5.3 is no longer supported
I check PHP Version
$ php -v
return
PHP 7.0.25-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Oct 27 2017 13:43:45) ( NTS )
but I check in phpinfo();
PHP Version 5.6.32-1+ubuntu16.04.1+deb.sury.org+1
Phpinfo() will always show the version your server is currently running. You will need to change the php version that apache is using. You can do this by disabling PHP 5 module by checking your apcahe files or disabling with 'sudo a2dismod php5'. Then you will need to enable php 7 by allocating in your files or again enabling it with 'sudo a2enmod php7.1'. To see results you will need to restart apache. I hope this helps
Recently I updated the default PHP version on MacOS X 10.11 to the newer 7.1.4, but when I do php -v on the terminal it says this: PHP 5.5.38 (cli) (built: Aug 21 2016 21:48:49).
I created the phpinfo on the web root and it says that the version is actually the 7.1.4.
What should I do to resolve this issue? Is this a real issue?
Since you said:
I used the command curl -s php-osx.liip.ch/install.sh | bash -s 7.1
I took a look at https://php-osx.liip.ch, which says:
Why does php -v on the command line still show my old version?
php-osx doesn't overwrite the php binaries installed by Apple, but
installs everything in /usr/local/php5. The new php binary is
therefore in /usr/local/php5/bin/php.
You can also adjust your PATH do include that directory, eg. write
into your ~/.profile file the following
export PATH=/usr/local/php5/bin:$PATH
i was using appserv 5.8
and in my phpinfo.php the php version was 5.6.26
now i installed laravel5.5
and its required phpversion 7
so i changed the php version to 7 from 5
now in my phpinfo.php
PHP Version 7.0.11
and when i write in the command
php -v
its give me
PHP 5.6.26 (cli) (built: Sep 15 2016 18:12:07)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
and i cant install the packages with laravel 5.5 bc the version in command line is 5.6 not 7
but when i check in phpinfo its 7
i have read something thats the command php -v tack the version from php-cli
so how can i change the php -v to be 7.0.1 as phpinfo.php
thanks ..
phpinfo.php shows what version of PHP Apache is using. -v shows what's in your $PATH.
If you're on a Mac I recommend using homebrew to install php 7 as described here
To clarify, PHP can be run in 3 ways: behind a web server, for command line scripting, and for GUI building. You have 2 versions: the web server one, which Apache is calling and invoking phpinfo.php, and PHP-CLI, which is invoked from the command line with php -v.
It seems like your PHP CLI version is different than the PHP web version. Upgrade your PHP CLI package.
You have two PHP binaries installed. In my Mac OSX:
$ which php
/usr/local/bin/php
$ /usr/local/bin/php -v
PHP 7.0.20 (cli) (built: Jul 12 2017 09:47:44) ( NTS )
And in same machine:
$ whereis php
/usr/bin/php
$ /usr/bin/php -v
PHP 5.6.30 (cli) (built: Feb 7 2017 16:18:37)
You should put /usr/local/bin in your PATH. Edit ~/.bash_profile
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
Open a new terminal and check your php version.
For me(Windows) changing CLI version also didn't work, finally
changing PHP version at Environment Variable PATH worked!!