mac os change php version

How to update PHP version on Mac OS X

mac os change php version. Смотреть фото mac os change php version. Смотреть картинку mac os change php version. Картинка про mac os change php version. Фото mac os change php version

Dec 17, 2018 · 2 min read

This was written in 2018. Now, all the brew taps in this blog have been deprecated.

Using Homebrew

First, make sure that your homebrew is up to date

brew update && brew upgrade

If you didn’t have homebrew, install it right away!

Using Brew Tap command allows Homebrew to tap into another repository of formula.

brew tap homebrew/dupes
These formulae were those that duplicated software provided by macOS.

brew tap homebrew/versions
These formulae provided multiple versions of existing packages or newer versions of packages that were too incompatible to go in homebrew/core.

brew tap homebrew/homebrew-php
A centralized repository for PHP-related brews.

Checking php version using the following commands

To unlink the last version

brew unlink php
[depends on the current version on your computer]

For instance, your current php version is 5.5
brew unlink php55

To install the new version of php

brew install php
[If you need another version just change the version number]

If you need php 7.1
brew install php71

then check php version again

If everything looks fine then congratulation! you’ve finished the php updated.

But I f you find the following errors
Error:Could not symlink file: /urs/local/Cellar/php.

you need to run the following commands

check php version again

linked to the old version?

Source your file with source

/.bash_profile or source

/.profile
(same as close and reopen your terminal).

Источник

How can I easily switch between PHP versions on Mac OSX?

I would like to test my application on PHP 5.3 up to PHP 7.0.

Where and how can I install the versions and how can I switch them by running a small script?

mac os change php version. Смотреть фото mac os change php version. Смотреть картинку mac os change php version. Картинка про mac os change php version. Фото mac os change php version

7 Answers 7

If you have both versions of PHP installed, you can switch between versions using the link and unlink brew commands.

For example, to switch between PHP 7.4 and PHP 7.3

PS: both versions of PHP have be installed for these commands to work.

I found this very good tutorial on how to install and switch php versions on OSX.

I can switch the version like

Exactly what I want!

mac os change php version. Смотреть фото mac os change php version. Смотреть картинку mac os change php version. Картинка про mac os change php version. Фото mac os change php version

Using brew

Show current version

Change to different version
(eg. changing from 5.5.x to version 7.0.latest) :

mac os change php version. Смотреть фото mac os change php version. Смотреть картинку mac os change php version. Картинка про mac os change php version. Фото mac os change php version

Example: Let us switch from php 7.4 to 7.3

If you install PHP with homebrew, you can switch between versions very easily. Say you want php56 to point to Version 5.6.17, you just do:

mac os change php version. Смотреть фото mac os change php version. Смотреть картинку mac os change php version. Картинка про mac os change php version. Фото mac os change php version

i think unlink & link php versions are not enough because we are often using php with apache(httpd), so need to update httpd.conf after switch php version.

1) Check installed php versions by brew, for sure everything good

Источник

I have a problem with PHP which is call through bash command «php»:

I want secondary PHP version 5.3.15 as mainly, because in this version I have correctly installed extensions etc.

Execuse my bad English, I hope that you understand.

Thank you so much. I have Mac OSx Lion

5 Answers 5

Open your Terminal / Commandline and type in:

Add the following line (change the path as needed):

If you need the php-alias to work right out of your current shell-session, then you have to use the following command (that’s optional, so only if u r continuing to work in your current shell):

That’s it, no change in the /usr/bin folder needed, and u can export your bashrc file / settings to any other linux / bsd like system if needed without even touching your OS /usr/bin files. You can also add new aliases for different php versions, aliases like «php52», «php53», «php54», etc. for testing purposes or whatsoever.

OS: OSX Yosemite
Just sort out a similar issue by vim

export PATH=/usr/local/bin:$PATH
export PATH=/Applications/MAMP/bin/php/php5.5.10/bin:$PATH

Make sure the order is correct. Put export PATH=/usr/local/bin:$PATH before export PATH=/Applications/MAMP/bin/php/php5.5.10/bin:$PATH

/usr/local/bin contains the mac default php.

mac os change php version. Смотреть фото mac os change php version. Смотреть картинку mac os change php version. Картинка про mac os change php version. Фото mac os change php version

you can substitute 54 with the latest number if you want. last i checked it was on 56

then based on some of the comments above you should run:

it will probably display:

as things get installed using brew, they get put in Cellar and linked through the bin. but in this case we need to override the php

mine kinda looks like:

save and close the terminal window, open up another one, and it should show something like:

Источник

Как изменить версию PHP в Mac?

mac os change php version. Смотреть фото mac os change php version. Смотреть картинку mac os change php version. Картинка про mac os change php version. Фото mac os change php version

mac os change php version. Смотреть фото mac os change php version. Смотреть картинку mac os change php version. Картинка про mac os change php version. Фото mac os change php version

mac os change php version. Смотреть фото mac os change php version. Смотреть картинку mac os change php version. Картинка про mac os change php version. Фото mac os change php version

mac os change php version. Смотреть фото mac os change php version. Смотреть картинку mac os change php version. Картинка про mac os change php version. Фото mac os change php version

mac os change php version. Смотреть фото mac os change php version. Смотреть картинку mac os change php version. Картинка про mac os change php version. Фото mac os change php version

mac os change php version. Смотреть фото mac os change php version. Смотреть картинку mac os change php version. Картинка про mac os change php version. Фото mac os change php version

mac os change php version. Смотреть фото mac os change php version. Смотреть картинку mac os change php version. Картинка про mac os change php version. Фото mac os change php version

mac os change php version. Смотреть фото mac os change php version. Смотреть картинку mac os change php version. Картинка про mac os change php version. Фото mac os change php version

Так же посмотрите
brew doctor

mac os change php version. Смотреть фото mac os change php version. Смотреть картинку mac os change php version. Картинка про mac os change php version. Фото mac os change php version

mac os change php version. Смотреть фото mac os change php version. Смотреть картинку mac os change php version. Картинка про mac os change php version. Фото mac os change php version

Warning: You have MacPorts or Fink installed:
/opt/local/bin/port

This can cause trouble. You don’t have to uninstall them, but you may want to
temporarily move them out of the way, e.g.

У вас стоит так же MacPorts, рекомендуется выбрать что-то одно.

Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
python@2

запустите brew link python@2

Warning: Broken symlinks were found. Remove them with `brew prune`:

Источник

Updating to PHP versions 7.4 and 8 on macOS 11 Big Sur and Catalina

The latest macOS versions of Big Sur and Catalina currently ship with PHP 7.3 and have a deprecation notice that they intend to drop support for PHP altogether in a future upgrade.

So moving forward the best solution is to use Homebrew to install and then choose whichever version of PHP you want including 7.4 and version 8.

So once you have Homebrew installed on your macOS a particular PHP Homebrew formulae will need to be added from this maintainer, what is great about this, is all PHP versions are available whereas only some versions are available on the default Homebrew formulas.

After Homebrew install, follow the below:

Add the PHP formulae

Choose the PHP version – example uses 7.4

Link the PHP Version

Change your version to match

Restart the Terminal

You should now see the new version, to change to another version just repeat the process from the brew install. then unlink and link in the new PHP version by issuing a command like below but with your correct version:

Using new PHP in macOS Shipped Apache

If you are using macOS in built shipped Apache, you can use the new PHP version by editing the Apache file:

Find the PHP module and comment it out and add in the new PHP version path:

Now the new PHP version will be used.

You could download all the versions and just uncomment the one you want if you intend to swap around:

PHP 8 and macOS Apache

One extra step is needed for PHP 8 and macOS bundled Apache:

Add the new PHP 8 and comment out the old one.

Go to the end of the file and add:

Removing Older Homebrew PHP version (optional)

If you have the older PHP formulas from an older Homebrew installation, you may wish to remove these:

Remove old PHP Launch Agents and daemons, if present:

Remove the deprecated homebrew/php tap, if present:

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *