How do i remove old versions of php mac?

First check your current version on mac. Please enter below command in your terminal.

Ex :- php -v
Output : PHP 7.1.2

Enter next command for uninstall the PHP on your system.

Ex :- brew uninstall

After select new version as you want to install, Please enter below command in your terminal.

Ex :- brew install

If you want to used in your valet system, Then please enter below command.

Ex :- valet use

After check your php version, Your php version updated in your system.

I have been trying to figure out how to completely remove preinstalled Apache and PHP from my macbook pro ... The reason is that I am using the homebrew version of both Apache and PHP. The current version of PHP that I am using is PHP 7 as you can see in the screenshot below

but when I use php -v in the terminal it shows me PHP version 5.6 .. see screenshot below.

I am trying to find the preinstalled PHP but can't seem to find it ... Can you guys help me out and point me to the right direction ? Thank You.

asked Aug 29, 2017 at 8:04

2

Removing system macOS binaries is not a good idea, they will be reinstalled during a next system upgrade and they could be needed by some system scripts.

To enable the homebrew php from the command line, read the output of brew info php70:

If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc, ~/.zshrc, ~/.profile or your shell's equivalent configuration file: export PATH="$[brew --prefix homebrew/php/php70]/bin:$PATH"

If you have installed php 7.2, check the output of brew info php72.

answered Aug 30, 2017 at 6:04

Ortomala LokniOrtomala Lokni

4,0735 gold badges25 silver badges52 bronze badges

4

I've tried this

export PATH=/usr/local/php5/bin:$PATH

and it works, php -v is showing me the correct version, see //php-osx.liip.ch/#faq

!!! Note that you need to add export PATH=/usr/local/php5/bin:$PATH to your ~/.bash_profile file in order to have this change permanent, otherwise it will go away on first reboot and you'll have to run this command every time you reboot.

answered Dec 8, 2017 at 10:09

1

Export your PATH with some like this [check your php version]:

export PATH=/usr/local/Cellar/php71/7.1.14_25/bin:$PATH

answered Feb 26, 2018 at 23:29

racarracar

811 silver badge2 bronze badges

1

Expanding on the answer of @Lokni, to use the php version of 'whatever homebrew installed' instead of /usr/bin/php, I added this as the first line of my ~/.bash_profile [or ~/.zprofile on some macs]:

export PATH="$[brew --prefix php]/bin:$PATH"

In my case, brew --prefix php returns

/usr/local/opt/php

So now, if I open new terminal and type which php it says

/usr/local/opt/php/bin/php

answered Apr 6, 2021 at 14:23

1

export PATH=/usr/local/Cellar/php/7.3.9_1/bin:$PATH

answered Sep 15, 2019 at 12:59

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged

.

How do I uninstall old version of PHP?

Select Add/ Remove Components. Select Web Hosting >> PHP interpreter versions. Select the outdated version of PHP, and then select Remove. Select Continue.

How do I reinstall PHP on Mac?

Install PHP on macOS Monterey.
brew --version. Installing PHP. ... .
brew install php. This will take a while and will produce some output in the Terminal window. ... .
command -v php. The command should display something like..
/usr/local/bin/php. or..
/opt/homebrew/bin/php. ... .
#!/usr/bin/env php. ... .
b] You can include inline scripts in expansions..

How do I update my PHP version on Mac?

To update the PHP version, update the brew using the command brew update . Then, use the command brew upgrade php . It upgrades the current version to the latest version of PHP. Then, restart the webserver to see the changes.

How do I uninstall PHP?

To uninstall the PHP agent from your system:.
Remove the agent files from your system: RedHat or CentOS. ... .
Remove any remaining New Relic configuration files. ... .
If you use a package manager, remove files specific to the manager: ... .
Restart your web servers [Apache, Nginx, PHP-FPM, etc.]..

Chủ Đề