Install php 7.4 on macos

I try to update my PHP version to 7.4 on macOS Catalina with brew.

I did brew install

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

asked Nov 4, 2020 at 17:13

meezmeez

2,6974 gold badges24 silver badges57 bronze badges

1

You can find my similar answer for .

  • brew install
  • brew link --force --overwrite
  • brew services start
  • export PATH="/usr/local/opt//bin:$PATH"
  • export PATH="/usr/local/opt//sbin:$PATH"

answered Nov 7, 2020 at 3:41

chenruichenrui

7,4933 gold badges30 silver badges39 bronze badges

10

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 
brew link 

answered Nov 4, 2020 at 17:33

SalinesSalines

5,5743 gold badges22 silver badges47 bronze badges

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 
brew services restart php
brew unlink 
brew link 
echo 'export PATH="/usr/local/opt//bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt//sbin:$PATH"' >> ~/.zshrc

Or

export PATH="/usr/local/opt//bin:$PATH"
export PATH="/usr/local/opt//sbin:$PATH" 

Peter Csala

11.8k15 gold badges24 silver badges55 bronze badges

answered Feb 7 at 11:32

ShimantoShimanto

1831 silver badge9 bronze badges

Using terminal of MacOS. Don't use terminal in vscode.

answered Sep 9, 2021 at 12:41

Thiên TrầnThiên Trần

311 silver badge7 bronze badges

1

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//bin/php Reason: image not found zsh: abort php -v

Dharman

27.7k21 gold badges75 silver badges126 bronze badges

answered Jun 6, 2021 at 16:32

  1. I move to directory by: cd /usr/local
  2. Find the file location by: find /usr/local/ -name libphp7.so. [Then get the file location at: /usr/local//Cellar//7.4.23/lib/httpd/modules/libphp7.so. I copy this.]
  3. I open the file by: sudo vim /etc/apache2/httpd.conf
  4. Look for the line by: /libphp7.so
  5. Uncomment the line and update the line by: LoadModule php7_module /usr/local//Cellar//7.4.23/lib/httpd/modules/libphp7.so
  6. Restart apache by: sudo apachectl restart
  7. Verify PHP by accessing //localhost/phpinfo.php

answered Sep 29, 2021 at 7:11

Not the answer you're looking for? Browse other questions tagged php macos homebrew php-7.4 or ask your own question.

How do I upgrade PHP to 7.4 on Mac?

6 Answers.
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".

Can I install PHP on Mac?

PHP is bundled with macOS since macOS X [10.0. 0] prior to macOS Monterey [12.0. 0]. Compiling is similar to the Unix installation guide.

How do I upgrade PHP version on Mac?

To fix this I used the following steps:.
Step 1 | Tap into another repository of formulae. brew tap shivammathur/php..
Step 2 | Install the desired PHP version. brew install shivammathur/php/php@7.4. ... .
Step 3 | Link the PHP Version. brew link --overwrite --force php@7.4..
Step 4 | Restart Terminal..
Step 5 | Check PHP version. php -v..

How do I reinstall PHP on Mac?

Listed below are the commands required for the manual installation of PHP 8.1 on macOS. Check the package naming on your macOS terminal correctly. 2 - In the macOS terminal, execute brew update to update Brew. 3 - Use the command brew install shivammathur/php/php@8.1 for installing PHP 8.1.

Chủ Đề