Переключить версию php mac os

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

Здравствуйте! Уже какой день пытаюсь изменить версию PHP в Mac OS High Sierra.
php -v сейчас выдает :

Затем запускаю команду:
затем : which php
выдает такое:

Проверяю опять версию PHP и все тоже самое

Помогите , как исправить проблему. Спасибо

  • Вопрос задан более трёх лет назад
  • 3121 просмотр

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

Если не поможет — попробуйте переустановить

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`:

Источник

Change mac os x default php version

In my mac (version 10.13.6 High Sierra) php -v output is PHP 7.1.32 . I need to update this 7.1 version to 7.3.

i tried to remove this version using brew unlink php7.1 but it’s not worked.

How can i upgrade php version.

3 Answers 3

$ brew upgrade php : ( get the latest homebrew php packages )

$ brew install php@7.4 : ( Install php 7.4 )

$ brew link php@7.4 : ( create an alias to this keg-only version; see comments output during installation )

$ echo ‘export PATH=»/usr/local/opt/php@7.4/bin:$PATH»‘ >>

/.bash_profile : ( Add the alias to your path; see comments output during installation )

/.bash_profile : ( Reload .bash_profile to use the new settings immediately )

then install the latest php version (PHP 8.0.8 in the time of writing):

link new version to /usr/local/Cellar/php/8.0.8:

then open the shell’s resource file, located in

/ (in my case Z-shell or ZSH):

press i to insert and somewhere in your resource file append a new path to your $PATH variable, like this:

or in the case of ZSH, you should also be able to do it like this:

then press esc to escape from insert mode, and press :wq to save/write and quit the editor. The final step is to source the file to apply new changes permanently.

Читайте также:  Proxpress m3870fd драйвер windows 10

Источник

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?

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!

Using brew

Show current version

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

Example: Let us switch from php 7.4 to 7.3

If you get Warning: php@7.3 is keg-only and must be linked with —force Then try with:

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:

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.

i have write shell script for disable/enable php_module automatically inside httpd.conf , look at line 46 to line 54 https://github.com/dangquangthai/switch-php-version-on-mac-sierra/blob/master/switch-php#L46

Follow my steps:

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

Источник

Mac / OSx — Change PHP version which is call in bash

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.

How can I set /usr/bin/php as main -> I want when call «php -v» return my 5.3.15 version.

Execuse my bad English, I hope that you understand.

Thank you so much. I have Mac OSx Lion

5 Answers 5

Another way without changing the original php file / link is if you edit your .bashrc file as follows (works with other commands as well):

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):

Читайте также:  Как записать windows directgrub

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.

Have fun, ioCron

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.

Hope this helps.

For brew users, you might not need php55 if you already have 54 — but regardless you should probably run these commands

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:

if it does, then change your .bash_profile like some of the other commenters my brew instance (i think its default) lives in

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:

which means that it already has access to the /usr/local/bin — but i use the alias to specify by adding this line, near the bottom:

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

Источник

Mac / OSx – изменить версию PHP, которая вызывает вызов bash

У меня проблема с PHP, который вызывает команду bash «php»:

/ usr / bin / php # PHP 5.3.15

Я хочу, чтобы вторичная PHP-версия 5.3.15 была в основном, потому что в этой версии я правильно установил расширения и т. Д.

Как я могу установить / usr / bin / php в качестве основного -> Мне нужно, когда вызов « php -v » возвращает мою версию 5.3.15.

Исправьте мой плохой английский, я надеюсь, что вы поймете.

Огромное спасибо. У меня есть Mac OSx Lion

Я бы рекомендовал вам установить php через «Mac Ports».

У вас установлено несколько версий php.

С командой cli, «которая» вы можете:

ОПИСАНИЕ Утилита принимает список имен команд и ищет путь для каждого исполняемого файла, который будет запущен, если бы эти команды были фактически вызваны.

Поэтому прочитайте man-страницы команды cli «which».

Читайте также:  Загрузка outlook при загрузке windows

Сделайте это от своего кли:

а затем вы увидите, где находится ваш исполняемый файл php. Я бы рекомендовал вам заменить исполняемый файл php для символической ссылки на ваш / usr / bin / php.

Другой способ без изменения исходного файла / ссылки php – это отредактировать файл .bashrc следующим образом (также работает с другими командами):

Откройте терминал / Командная строка и введите:

Добавьте следующую строку (измените путь по мере необходимости):

Если вам нужно, чтобы php-alias работал прямо из вашего текущего сеанса оболочки, вам нужно использовать следующую команду (это необязательно, поэтому, только если ур продолжает работать в вашей текущей оболочке):

Вот и все, никаких изменений в папке / usr / bin, и вы можете экспортировать файл / настройки bashrc в любую другую Linux-систему, если это необходимо, даже не касаясь файлов OS / usr / bin. Вы также можете добавить новые псевдонимы для разных версий php, псевдонимы типа «php52», «php53», «php54» и т. Д. Для целей тестирования или вообще.

Для пользователей пивоварения вам может не понадобиться php55, если у вас уже есть 54 – но независимо от того, что вы, вероятно, должны запускать эти команды

вы можете заменить 54 номером, если хотите. последний я проверил, что он был на 56

затем, основываясь на некоторых комментариях выше, вы должны запустить:

он, вероятно, отобразит:

если это так, то измените свой .bash_profile, как некоторые из других комментаторов, мой экземпляр brew (я думаю, его по умолчанию) живет в

поскольку вещи устанавливаются с использованием варева, они попадают в Подвал и соединяются через корзину. но в этом случае нам нужно переопределить php

мой вид выглядит так:

это означает, что он уже имеет доступ к / usr / local / bin – но я использую псевдоним для указания, добавив эту строку, в нижней части:

сохранить и закрыть окно терминала, открыть еще один, и он должен показать что-то вроде:

ОС: OSX Yosemite
Просто выберите аналогичную проблему с помощью vim

export PATH = / usr / local / bin: $ PATH
export PATH = / Приложения / MAMP / bin / php / php5.5.10 / bin: $ PATH

Убедитесь, что порядок верен. Поместить export PATH=/usr/local/bin:$PATH перед export PATH=/Applications/MAMP/bin/php/php5.5.10/bin:$PATH

/ usr / local / bin содержит макрос по умолчанию mac.

Надеюсь это поможет.

Вы должны найти путь и проверить все каталоги в пути для символической ссылки на неправильную версию php.

Затем вы можете удалить эту символическую ссылку и заменить ее ссылкой на нужную версию.

Вы также можете использовать find для просмотра всех экземпляров:

Источник

Оцените статью