php -v always returns php#5.6 - php

Installed php#5.6 and php#8.1 with brew. php -v shows php#5.6 after brew link php#5.6 --force --overwrite (normal).
Then, after using brew unlink php#5.6 and brew link php --force --overwrite to switch to php#8.1, php -v still displays php#5.6.
In other words, I'm stuck with php#5.6 and cannot switch to php#8.1.
I know I edited a config file and added a line specifying php#5.6, but I can't remember which file it was.
How can I switch to php#8.1?
I'm using brew in Ubuntu via WSL 2 under Windows. Thanks.

try splitting the command into two like so
brew unlink php && brew link --overwrite --force php#8.1
The command above works for me.
Ref: https://getgrav.org/blog/macos-monterey-apache-multiple-php-versions

Related

Impossible to install PHP 8 on mac

I have a problem when I try to install PHP 8 on macOS. I use the following commands :
brew tap shivammathur/php
brew install shivammathur/php/php#8.0
brew link --overwrite --force php#8.0
But after, when I try to execute php -v I have this result :
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicuio.67.dylib
Referenced from: /usr/local/bin/php
Reason: image not found
[1] 28817 abort php -v
Can you help me ? It seems my $PATH var has a problem.
Thanks
Try
brew install icu4c
or
brew reinstall icu4c
it solved for me

Update PHP to 7.4 macOS Catalina with brew

I try to update my PHP version to 7.4 on macOS Catalina with brew.
I did brew install php#7.4
If I check my version php -v, I still see the old version PHP 7.3.11?
What do I have to do?
Update:
After brew doctor I get:
Warning: Homebrew's sbin was not found in your PATH but you have
installed formulae that put executables in /usr/local/sbin. Consider
setting the PATH for example like so: echo 'export
PATH="/usr/local/sbin:$PATH"' >> ~/.profile
You can find my similar answer for php#7.2.
brew install php#7.4
brew link --force --overwrite php#7.4
brew services start php#7.4
export PATH="/usr/local/opt/php#7.4/bin:$PATH"
export PATH="/usr/local/opt/php#7.4/sbin:$PATH"
try:
brew update
brew upgrade php
php -v
brew services start php
or
brew services restart php
if you use apache server:
sudo apachectl restart
if you use ngnix
sudo nginx -s reload
Edit:
brew unlink php#7.3
brew link php#7.4
If anyone want to downgrade php from latest 8.1.2 to 7.4 on systems demand, try the below commands with homebrew:
Installing PHP 7.4 :
brew install php#7.4
brew services restart php
brew unlink php#8.1
brew link php#7.4
echo 'export PATH="/usr/local/opt/php#7.4/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/php#7.4/sbin:$PATH"' >> ~/.zshrc
Or
export PATH="/usr/local/opt/php#7.4/bin:$PATH"
export PATH="/usr/local/opt/php#7.4/sbin:$PATH"
Using terminal of MacOS. Don't use terminal in vscode.
I recently faced this issue, all the suggestion here didn't work until I ran:
xcode-select --install
Then ran the command I was trying before and the error stopped, for my case it was php
dyld: Library not loaded: /usr/local/opt/openldap/lib/libldap-2.4.2.dylib
Referenced from: /usr/local/opt/php#7.4/bin/php
Reason: image not found
zsh: abort php -v
I move to directory by: cd /usr/local
Find the file location by: find /usr/local/ -name libphp7.so. (Then get the file location at: /usr/local//Cellar/php#7.4/7.4.23/lib/httpd/modules/libphp7.so. I copy this.)
I open the file by: sudo vim /etc/apache2/httpd.conf
Look for the line by: /libphp7.so
Uncomment the line and update the line by: LoadModule php7_module /usr/local//Cellar/php#7.4/7.4.23/lib/httpd/modules/libphp7.so
Restart apache by: sudo apachectl restart
Verify PHP by accessing http://localhost/phpinfo.php

PHP -v shows 7.2.8 version on Mac where as it has php 7.4.8

How to configure PHP 7.4.X in to mac where as it shows 7.2.8 on Php -v command. I tried to install latest version of XXAMP which come with 7.4.8 but still the problem remains the same.
You can use brew to achieve this:
$ brew unlink php#7.2
$ brew install php#7.4
$ brew link php#7.4 --force
Then in the future you can reverse this by doing this:
$ brew unlink php#7.4
$ brew link php#7.2 --force

Homebrew PHP appears not to be linked. - Valet

I had a problem which appeared all of the sudden saying:
Unable to determine linked PHP. which I could not solve so I uninstalled valet, php and dependencies. Then I installed fresh php7.1 but when I run valet install I get quiet slightly similar error: Homebrew PHP appears not to be linked.
First, find the PHP version installed via.
brew list
In my case it was php#7.3, then
brew link php#7.3 --force --overwrite
and finally
valet install
:)
Homebrew can't find the correct PHP version, have you linked them up properly?
brew link php71
brew link php#7.2 --force --overwrite
That will push this--
If you need to have this software first in your PATH instead consider running:
echo 'export PATH="/usr/local/opt/php#7.2/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php#7.2/sbin:$PATH"' >> ~/.bash_profile
I ran both independently then tried valet install (worked like a charm).
brew install php#7.1
then link it
brew link php#7.1 --force --overwrite
$ brew unlink php && brew link --force php#7.1
If you are coming here following a migration from Intel to M1 and having Valet not use the php cask from the /opt/ folder, this did the trick for me:
echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.zshrc.

Install php72 on MacOS using brew

I'm trying to install php72 using brew.
Actually when I do brew install php72 it's downloading "https://homebrew.bintray.com/bottles/php-7.3.0.mojave.bottle.tar.gz".
So when I check php version it's showing me PHP 7.3.0 (cli).
How can I install exactly php72 and not php73 ?
I found the solution.
Instead of installing php72 you must specify version like this php#7.2.
brew unlink [your actual php version linked]
brew install php#7.2
brew link php#7.2
Installing PHP 7.2 on Mac using Homebrew
Check version
php -v
check brew is up to date
brew update
brew upgrade
Unlink php version which is installed in the system
brew unlink php71
Now final step to download**
brew install php72
export PATH=/usr/local/php5/bin:$PATH
This worked for me
brew upgrade
brew unlink php71
brew install php72
then in your ~/.bash_profile
export PATH=/usr/local/Cellar/php\#7.2/7.2.26/bin/:$PATH
brew tap homebrew/homebrew-php
brew unlink php71
brew install php72 --with-argon2
brew install php72-xdebug
For more info follow url https://murze.be/how-to-upgrade-from-php-71-to-72-on-macos-using-homebrew
Note older version's of Mac OS are not supported, I'm trying with docker which also doesn't support older versions of Mac OS completely (no desktop version). Trying with just docker machine as follows;
base=https://github.com/docker/machine/releases/download/v0.16.0 &&
curl -L $base/docker-machine-$(uname -s)-$(uname -m) >/usr/local/bin/docker-machine &&
chmod +x /usr/local/bin/docker-machine

Categories