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
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 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
I'm trying to setup Laravel's Valet which, as a dependency, requires PHP 7. When I try to install PHP 7 with Homebrew I get the following error:
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-dbase https://github.com/Homebrew/homebrew-php/issues/3508
php70-intl not found https://github.com/Homebrew/homebrew-php/issues/3591
php70-opcache install issue https://github.com/Homebrew/homebrew-php/issues/3586
Problem installing php70-mcrypt, php70-opcache, php70-xdebug on El Capitan https://github.com/Homebrew/homebrew-php/issues/3587
Add php70-zmq formula https://github.com/Homebrew/homebrew-php/pull/3474
Problem installing homebrew/php/php70-imagick https://github.com/Homebrew/homebrew-php/issues/3571
Install PHP70: Incompatible library version https://github.com/Homebrew/homebrew-php/issues/3444
brew install php70-redis https://github.com/Homebrew/homebrew-php/issues/2762
Allow --enable-redis-igbinary for php70-redis https://github.com/Homebrew/homebrew-php/pull/3473
Add head formula for php70-uploadprogress https://github.com/Homebrew/homebrew-php/pull/3178
This is on a fresh install of MacOS Sierra (actual release, not a beta) with a fresh install of Homebrew (updated). I have installed, ran and agreed to the Xcode licensing agreement.
I have no idea what these errors mean. How can I fix them?
Right I've figured it out. I'm posting the steps to successfully install the require components below in case anybody else stumbles upon this issue:
1). make sure Homebrew is up to date:
brew update
2). Fix the PHP 7 error by making sure Xcode is installed and then typing the following into the Terminal:
brew install apr apr-util
sudo mkdir -p /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/
sudo ln -s /usr/local/opt/apr/bin/apr-1-config /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/
sudo ln -s /usr/local/opt/apr-util/bin/apu-1-config /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.12.xctoolchain/usr/local/bin/
3). Run the following command (otherwise the PHP installation will complain about missing libz):
xcode-select --install
4). You can now install PHP 7 with Homebrew:
brew install homebrew/php/php70
It may also be important for those using the macOS-delivered installation of Apache with PHP via Homebrew that (quote from Homebrew php70 install):
With the release of macOS Sierra the Apache module is now not built by default. If you want to build it on your system you have to install php with the --with-apache option. See brew options php70 for more details.
I used the following commands to make it work.
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
Here is how I upgrade PHP 5.6 to 7.2 in my Macbook Pro (macOS Sierra)
a. Update the brew package first.
$ brew update && brew upgrade
b. Unlink the old version of PHP if it was installed with Homebrew.
$ brew unlink php56
c. Install the new version of PHP.
$ brew install php72
After installation, it shows:
To enable PHP in Apache add the following to httpd.conf (/etc/apache2) and restart Apache:
d. Using vim edit httpd.conf of apache2.
$ sudo vim /etc/apache2/httpd.conf
Search “php5_module” then commend out the statements as follows:
#Comment out the PHP5 module
#LoadModule php5_module libexec/apache2/libphp5.so
Add the commands as follows:
#Enable PHP 7 module
LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
e. Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html
The php.ini and php-fpm.ini file can be found in:
/usr/local/etc/php/7.2/
f. Restart Apache service
$ sudo apachectl restart
g. check the php version:
$ php -v
PHP 7.2.7 (cli) (built: Jun 22 2018 06:29:00) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
Done!
Please visit the article "Upgrade PHP version from 5.6 to 7.2 on macOS Sierra (10.12)"
of my blog for more information!
Cheer!
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