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
Related
I successfully installed homebrew by following the instructions of the official website (https://brew.sh/).
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
It was installed under /opt/homebrew
I then did install php with brew install php#8.1
If I restart php with brew services restart php I get the following error message:
Permission denied # rb_sysopen - /Users/USER/Library/LaunchAgents/homebrew.mxcl.php.plist
I use macOS Monterey 12.4
Using sudo to restart php results in the warning:
Warning: php must be run as non-root to start at user login!
Does anybody have an idea on how to solve this issue?
Command to restart my php-fpm:
brew services restart php#8.1
If you don't have brew services, try installing it like this:
brew tap homebrew/services
Edit: Solved by using 'chown' on a sub directory that was still running under the wrong user.
OS: macOS 11 (big sur)
Homebrew: 2.5.12
PEAR Version: 1.10.12
I just upgraded the php on my mac from php7.1 to php7.4 with homebrew (brew install php#7.4).
Then, when I try to install mcrypt extension, I got the error:
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
ERROR: `/private/tmp/pear/install/mcrypt/configure --with-php-config=/usr/local/homebrew/opt/php#7.4/bin/php-config --with-mcrypt' failed
Here is what I did:
brew isntall mcrypt
install the pecl
sudo pecl install mcrypt -- The error goes here.
What I tried:
Located the mcrypt.h and put manually the file to the several locations (based on the php-config), not work.
Cleaned the brew and reinstall/relink the mcrypt(libmcrypt), not work.
Removed the legacy mcrypt files of the old brew version.
I ran into the same problem. So after installing libmcrypt with brew install mcrypt it seems like configure is not able to resolve the path to mcrypt.h automatically. It also does not work to specify the CPPFLAGS or giving the homebrew include path.
But I found a solution that works for me by giving pecl the install location of mcrypt in the Homebrew Cellar. This is what the following code does automatically:
pecl install mcrypt <<<"$(ls -d $(brew --prefix)/Cellar/mcrypt/* | tail -1)"
if you using brew try this :
1.Unistall existing php then Install shivammathur/php
add shivammathur php
brew tap shivammathur/php
change php version with you needed (5.6 or 7.2 or 7.4 or 8.1 or next version)
brew install shivammathur/php/php#7.4
2.Install shivammathur/extensions it s will add extension to php
then
brew tap shivammathur/extensions
brew install shivammathur/extensions/mcrypt#7.4
then you install mcrypt with same version as php version
brew install mcrypt#7.4
then restart httpd
brew services restart httpd
Ref :
https://github.com/shivammathur/homebrew-php
https://github.com/shivammathur/homebrew-extensions
The problem here is the configure command can't find the libmcrypt installed by homebrew
You can
Download the source code of mcrypt-1.0.4, then cd in the folder
run "phpize"
run "./configure --with-mcrypt=/opt/homebrew/Cellar/mcrypt/2.6.8", you can change the path here with your path for homebrew lib
run "make && make install"
add extension=mcrypt.so to your config file
ps: Use php -i | grep "Loaded Configuration File" to locate your php configure file
in case of an error on macOS use the complete path in php.ini like:
extension="/opt/homebrew/Cellar/php/8.1.9/pecl/20210902/mcrypt.so"
I would like to upgrade my PHP from 7.2 to 7.3 on my Mac Mojave.
My current version is 7.2.25 (when I execute php -v).
I did that:
brew install php#7.3
It seems that it installed some things. But php -v still displays 7.2.25.
I restarted my computer, and still get the same. What more can I do?
need to own /usr/local/optif you face any problem to unlink or link.
sudo chown -R `whoami`:admin /usr/local/opt
brew unlink php#7.2 && brew link --force --overwrite php#7.3 after running this command close all terminal and open fresh terminal to see reflection.
To change active version with Apache,in file /usr/local/etc/httpd/httpd.conf
load your desired php module. Commented php7.2 and added php7.3
#LoadModule php7_module /usr/local/opt/php#7.2/lib/httpd/modules/libphp7.so
LoadModule php7_module /usr/local/opt/php#7.3/lib/httpd/modules/libphp7.so
You can try to run either of the following commands
brew install php#7.3
OR
curl -s http://php-osx.liip.ch/install.sh | bash -s 7.3
And The last step is
export PATH=/usr/local/php5/bin:$PATH
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.
I currently have PHP 5.6.23 installed on my system.. However, I am trying to install PHP7 on my system (macOS Sierra Beta), I'm trying to do this with brew install homebrew/php/php70.
However, I get the following error:
$ brew install php70
Warning: You are using OS X 10.12.
We do not provide support for this pre-release version.
You may encounter build failures or other breakages.
Please create pull-requests instead of filing issues.
==> Installing php70 from homebrew/php
==> Downloading https://php.net/get/php-7.0.9.tar.bz2/from/this/mirror
Already downloaded: /Users/Removed/Library/Caches/Homebrew/php70-7.0.9
==> ./configure --prefix=/usr/local/Cellar/php70/7.0.9 --localstatedir=/usr/local/var --sy
Last 15 lines from /Users/Removed/Library/Logs/Homebrew/php70/01.configure:
checking for pthreads_lib...
Configuring SAPI modules
checking for Apache 2.0 handler-module support via DSO through APXS...
Sorry, I cannot run apxs. Possible reasons follow:
1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)
The output of /usr/sbin/apxs follows:
apxs:Error: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/apr-1-config not found!.
configure: error: Aborting
READ THIS: https://git.io/brew-troubleshooting
If reporting this issue please do so at (not Homebrew/brew):
https://github.com/Homebrew/homebrew-php/issues
These open issues may also help:
php70-yaf https://github.com/Homebrew/homebrew-php/issues/3328
Install PHP70: Incompatible library version https://github.com/Homebrew/homebrew-php/issues/3444
No solr available for php70 yet https://github.com/Homebrew/homebrew-php/issues/3454
brew install php70-redis https://github.com/Homebrew/homebrew-php/issues/2762
php70-imagick has warnings https://github.com/Homebrew/homebrew-php/issues/2766
Add head formula for php70-uploadprogress https://github.com/Homebrew/homebrew-php/pull/3178
"brew upgrade" fails: php56 conflicting with php70 when upgrading phpmyadmin https://github.com/Homebrew/homebrew-php/issues/2945
10.6.8 "brew install php70" failed with Error 139 https://github.com/Homebrew/homebrew-php/issues/2708
Adds a new php70-gearman formula that updates php56-gearman https://github.com/Homebrew/homebrew-php/pull/3120
Why does wp-cli formula try to install php56 if php70 is already there? https://github.com/Homebrew/homebrew-php/issues/3179
Warning: You are using OS X 10.12.
We do not provide support for this pre-release version.
You may encounter build failures or other breakages.
Please create pull-requests instead of filing issues.
The outcome of brew doctor is this:
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
Warning: You are using OS X 10.12.
We do not provide support for this pre-release version.
You may encounter build failures or other breakages.
Please create pull-requests instead of filing issues.
Any guidance/help would be much appreciated!
Try this:
$ brew link apr-util --force
$ brew link apr --force
$ which apu-1-config
/usr/local/bin/apu-1-config
$ which apr-1-config
/usr/local/bin/apr-1-config
$ sudo mkdir -p /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/
$ sudo ln -s /usr/local/bin/apu-1-config /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/
$ sudo ln -s /usr/local/bin/apr-1-config /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/
$ brew tap homebrew/dupes
$ brew tap homebrew/versions
$ brew tap homebrew/homebrew-php
$ brew update && brew install apr apr-util
$ brew link apr-util --force
$ brew link apr --force
$ which apu-1-config
$ which apr-1-config
$ sudo mkdir -p /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/
$ sudo ln -s /usr/local/bin/apu-1-config /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/
$ sudo ln -s /usr/local/bin/apr-1-config /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/
$ brew install php70
In terminal,
curl -s http://php-osx.liip.ch/install.sh | bash -s 7.0
will install php7 on macOS Sierra, I just tested.
Edit httpd.conf (located in /etc/apache2/) file.
Comment below line.
#LoadModule php5_module libexec/apache2/libphp5.so