MacOS 12.1 After successfully installing php 8.1 with homebrew (along with apache/mySQL and phpmyadmin) I am trying unsuccessfully to install/link php 7.4. After following instructions to install, unlink, link, php -v returns 7.4 but phpinfo() shows 8.1. What am I doing wrong?
Strange enough, using a full name such as "shivammathur/php/php#8.1" for the link command is what worked for me.
Eg:
brew link --overwrite --force shivammathur/php/php#7.4
Also, don't forget to close your terminal completely and reopen it before checking the version with php -v.
It looks as if I never successfully killed the included MacOS Apache. I uninstalled home-brew and the server was still running (with PHP8.1!). Not sure what went wrong.
Related
I have php5 installed on my macbook then I tried to update it, to php7 after I successfully installed the php7, I tried to check the installed version using php -v. But to my surprise it shows I still have php5 running on my system. After that I tried to move my php7 to my php5 directory /bin/usr/ but failed. Then I tried to run php-v but the response I got was -bash: command not found. Please how can I solve this both on my terminal and VSCode?
I run php7.2 on mac os mojave. I recently noticed when I run php -v in terminal I get this error
I am not sure what caused it because I noticed it today. uninstalling openssl using homebrew & installing again didn't work.
I installed new php version, php7.72 , it fixed the issue for me.
I am developing a PHP project. I am using Mac OS X now. To be honest, this is the first time developing a PHP project using Mac. I am a Windows. I installed PHP using Brew by running the following command.
brew install php
It gave me the php latest version, 7+. For my project, I need to use php version 5.6. So, I installed another PHP by running this command.
brew install php56
Up until this point when I enter "php --version" in the terminal, it is showing that I am using php version 7+. I found some solution to change php version and so I used one of them and run this command.
alias php='/usr/local/etc/php/5.6/php'
After running that command, when I type in "php --version" in the terminal, it is showing this error.
-bash: /usr/local/etc/php/5.6/php: No such file or directory
Now, I cannot use any PHP on my Mac right now. How can I fix that?
Recently, I wanted to upgrade my php on a mac from 5.4 to 5.5 [latest version], I did it successful with the php-osx's [http://php-osx.liip.ch/] one Line installation.
But however in the terminal when I did php -v, I could see the older version, then tried to uninstall php installed by phposx following their uninstall method.
Later I felt that I had to compile php from the source. I headed to php.net and downloaded 5.5, tar -zxvf, ./configure, make, sudo make install.
Now i feel like i'm going crazy as I have the older version when I issue php -v, also in the /usr/local/bin/php -v is the 5.5 version, and some packages installed with php-osx still available.
I need help with uninstalling the php compiled from source, and also totally remove some packages that where installed with php-osx, so that i just again install that latest version from the one line installer of php-osx and then just symlink it.
Thanks in advance!
Since Mac OS 10.8 had an old PHP version I had to install a never version of PHP. So I just compile PHP 5.4.13. Then I do a php -v on the terminal and it shows me that the new php version is running. But When I do a phpinfo from the browser it shows me the old PHP version which is PHP 5.3.x. This is even after creating a soft link to the new php build,
/opt/local/lib/php(old one) -> /usr/bin/php(new one)
Any ideas how to fix this issue?
I just ran into the same issue, wanting to try Laravel which requires mcrypt.
In a nutshell, I had been using the built-in PHP 5.3.26 that came with Mountain Lion, then some months later after I'd gotten more familiar with homebrew, I used it to install a newer version of PHP.
brew update
brew upgrade
brew install php53 php53-mcrypt ...
I put
<?php phpinfo();
into ~/Sites/info.php then went to localhost/info.php to see my Apache+PHP config. On the page, I saw this, under Loaded Configuration File:
/private/etc/php.ini
Then in Termninal, I ran this:
php -i | grep ini
which showed this output
Loaded Configuration File => /usr/local/etc/php/5.3/php.ini
Plus even more configs loaded as well ...
Additional .ini files parsed => /usr/local/etc/php/5.3/conf.d/ext-mcrypt.ini,
/usr/local/etc/php/5.3/conf.d/ext-xdebug.ini,
/usr/local/etc/php/5.3/conf.d/redis.ini
The problem I had was that mcrypt was loading in the php cli version, but my Laravel test page wouldn't load giving an mcrypt extension not found error [1]
I used a diffmerge tool [2] to compare the original Apple php.ini in /private/etc/ to the one homebrew installed in /usr/local/etc/php/5.3/ and found there to be significant differences! So check carefully before trying this:
What I did next was to backup
sudo mv /private/etc/php.ini /private/etc/php.ini.apple
Then symlink the php.ini to homebrew's instead
ln -s /usr/local/etc/php/5.3/php.ini /private/etc/php.ini
Finally after reloading Apache
sudo apachectl restart
And mcrypt loaded, and now they're using a single config.
If you have another app on your localhost that breaks with the new config, just remove the symlink, and change it to the .apple version and restart Apache to revert back.
Laravel requires the Mcrypt PHP extension
https://sourcegear.com/diffmerge/
This might be a good reference:
how do i install php 5.4 on Mac OS X Lion?
There are some detailed instructions on upgrading PHP to 5.4, and also notes on how MacPorts can make it pretty painless.
I'm running OS X 10.9. I updated PHP to v5.5.8 and found that Apache was correctly running the new version but the terminal was still running the old one. After hunting around for a solution for a while, I eventually thought, "I'll give it a restart."
Bingo! Terminal and Apache are running the same version of PHP.