Mac os change php version

Содержание
  1. How to update PHP version on Mac OS X
  2. Using Homebrew
  3. First, make sure that your homebrew is up to date
  4. Using Brew Tap command allows Homebrew to tap into another repository of formula.
  5. Checking php version using the following commands
  6. To unlink the last version
  7. To install the new version of php
  8. you need to run the following commands
  9. linked to the old version?
  10. How to Switch Between PHP Versions on Your Mac 🔀
  11. Как изменить версию PHP в Mac?
  12. pixeline / php_upgrade_to_71.sh
  13. This comment has been minimized.
  14. n8jadams commented Jul 15, 2017
  15. This comment has been minimized.
  16. coulon-xyz commented Aug 24, 2017
  17. This comment has been minimized.
  18. TomMuc1 commented Sep 17, 2017
  19. This comment has been minimized.
  20. vaske commented Oct 5, 2017 •
  21. This comment has been minimized.
  22. adnauseum commented Oct 9, 2017
  23. This comment has been minimized.
  24. gusbemacbe commented Oct 12, 2017
  25. This comment has been minimized.
  26. TechNinjaWeb commented Oct 25, 2017
  27. This comment has been minimized.
  28. wbswjc commented Oct 25, 2017
  29. This comment has been minimized.
  30. Narven commented Nov 3, 2017
  31. This comment has been minimized.
  32. Peneheals commented Nov 15, 2017 •
  33. This comment has been minimized.
  34. amrutjadhav commented Nov 16, 2017
  35. This comment has been minimized.
  36. COil commented Dec 2, 2017
  37. This comment has been minimized.
  38. alemol commented Dec 11, 2017
  39. This comment has been minimized.
  40. bibibaonam commented Dec 14, 2017
  41. This comment has been minimized.
  42. latheva commented Jan 25, 2018
  43. This comment has been minimized.
  44. dib258 commented Feb 12, 2018
  45. This comment has been minimized.
  46. varshaan0sharma commented Mar 24, 2018
  47. This comment has been minimized.
  48. marknt15 commented Mar 30, 2018
  49. This comment has been minimized.
  50. huebs commented Apr 2, 2018 •
  51. This comment has been minimized.
  52. ToniTonish commented Apr 9, 2018
  53. This comment has been minimized.
  54. heberfomin commented Apr 11, 2018
  55. This comment has been minimized.
  56. artcoholic commented Apr 12, 2018
  57. This comment has been minimized.
  58. gotraveltoworld commented Apr 12, 2018 •
  59. This comment has been minimized.
  60. aoberoi commented Apr 13, 2018
  61. This comment has been minimized.
  62. clozed2u commented Apr 13, 2018 •
  63. This comment has been minimized.
  64. EugenMayer commented Apr 13, 2018
  65. This comment has been minimized.
  66. w0rd-driven commented Apr 14, 2018

How to update PHP version on Mac OS X

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

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

sudo chown -R$(whoami) /usr/local/*
brew list | while read f; do brew unlink f; brew link $f; done
brew unlink php >
brew link —overwrite php >

Читайте также:  Настройка ядра windows 10

check php version again

linked to the old version?

So open you .profile or .bash_profile
like nano or vim

Source your file with source

/.bash_profile or source

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

Источник

How to Switch Between PHP Versions on Your Mac 🔀

Mar 23, 2018 · 2 min read

If you do development work on a Mac, chances are you’re using Homebrew to install and maintain the v a rious tools, languages, and packages that make up your local development environment. One of the most common things folks use Brew to install is PHP. Homebrew makes it very easy to install any PHP versions you’re interested in along with any extensions your environment may require. But here’s where one of the biggest Brew/PHP pain points appears: there’s no simple out-of-the-box method of managing multiple PHP versions and switching between them in Brew. We’ve all got those legacy projects that won’t work on newer versions of PHP, but at the same time we want to (or have to) use a newer version for any newer development projects! Because of this, people generally end up turning to other options (like MAMP) that provide better options for switching between the currently installed PHP versions.

This pain-point is why I built my newest side-project, switch-php ; a simple command-line script that we can use to switch PHP with one small command.

There are currently several methods of installation:

  1. You can install with NPM: $ npm install —global switch-php
  2. You can install with Yarn: $ yarn global add switch-php
  3. You can manually download the switch-php.sh file from the switch-php repo and move it into your home directory. Then you’ll need to add this line in your .bashrc / .zshrc /etc.: source

Once you install it via one of the above methods, you will be able to access switch-php globally.

Here’s an bare-minimum example of how to use it:

Here’s what we’re doing:

  1. switch-php → The main command. (Required)
  2. 72 → Specify the version of PHP you want to switch too, in this case we’re asking for php72 . (Required)

However, you can also pass some optional parameters that provide some additional functionality. For example:

  • -v → Request verbose output (Optional)
  • -m 512M → Request a custom PHP memory setting. If you don’t pass an additional argument, the memory will be reset to the Valet default. (Optional)

Please download switch-php , give it a spin, and let me know your thoughts! Any bugs or feature requests can be added to the Github repo. If you found switch-php useful in your workflow, please share it with your friends and help them enjoy Brewing PHP again! Thanks!

As always, if you found this post helpful or enjoyed the read, please follow me here or on Twitter to see future posts!

Источник

Как изменить версию 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`:

Источник

pixeline / php_upgrade_to_71.sh

# 1. Install brew —> http://brew.sh/
# 2. run the following commands in your Terminal
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew install —with-openssl curl
brew install —with-homebrew-curl —with-apache php71
brew install php71-mcrypt php71-imagick
# 3. Follow these instructions to make Apache and php-cli use the newer php executable and make the change persist after reboot.
brew info php71
# restart apache
sudo apachectl restart
# apply PATH changes without relogging
source

This comment has been minimized.

Copy link Quote reply

n8jadams commented Jul 15, 2017

Thanks for this! I tried a million other ways and this is what eventually got it to work.

This comment has been minimized.

Copy link Quote reply

coulon-xyz commented Aug 24, 2017

This comment has been minimized.

Copy link Quote reply

TomMuc1 commented Sep 17, 2017

thanks for sharing — worked instantly 🙂

This comment has been minimized.

Copy link Quote reply

vaske commented Oct 5, 2017 •

Thanks for this one, I followed up instructions and after sudo apachectl restart I keep getting this kind of error:

Can’t find solution for it, if I revert back to php56 it works, but php71 or php70 runs into this issue, any idea what might cause it?
I already added ServerName localhost to httpd.conf

Also apache use /etc/php.ini which is ini file of php56 default one.

This comment has been minimized.

Copy link Quote reply

adnauseum commented Oct 9, 2017

Thanks for your time and effort!

This comment has been minimized.

Copy link Quote reply

gusbemacbe commented Oct 12, 2017

If you use macOS High Sierra, it comes already with php71. If you want to upgrade to php72, and in these commands, change from php71 to php72. And you have to write brew install homebrew/php/php72-mcrypt and brew install homebrew/php/php72-imagick .

This comment has been minimized.

Copy link Quote reply

TechNinjaWeb commented Oct 25, 2017

This was the solution for me. Thanks for your help!

This comment has been minimized.

Copy link Quote reply

wbswjc commented Oct 25, 2017

@vaske Try add 127.0.0.1 vaske-mbp.local to /etc/hosts .

This comment has been minimized.

Copy link Quote reply

Narven commented Nov 3, 2017

brew tap homebrew/dupes deprecated

This comment has been minimized.

Copy link Quote reply

Peneheals commented Nov 15, 2017 •

If you are using AMPPS or any other solution not just pure Apache, and imagick or other php extensions are not important, just use this:

This comment has been minimized.

Copy link Quote reply

amrutjadhav commented Nov 16, 2017

Saved me lot of time. Thanx for this gist.

This comment has been minimized.

Copy link Quote reply

COil commented Dec 2, 2017

Yeah thanks, I always forget the —with-apache stuff.

This comment has been minimized.

Copy link Quote reply

alemol commented Dec 11, 2017

In case of facing this warning:

$ brew install —with-homebrew-curl —with-apache php71
Warning: homebrew/php/php71 7.1.12_23 is already installed, it’s just not linked.
You can use brew link php71 to link this version.

Then this error:

$ brew link php71
Linking /usr/local/Cellar/php71/7.1.12_23.
Error: Could not symlink sbin/php-fpm
/usr/local/sbin is not writable.

The solution is this:

$ sudo mkdir /usr/local/sbin
$ sudo chown -R whoami :admin /usr/local/sbin
$ brew link php71
Linking /usr/local/Cellar/php71/7.1.12_23. 17 symlinks created

This comment has been minimized.

Copy link Quote reply

bibibaonam commented Dec 14, 2017

thank you so much, it works great.

This comment has been minimized.

Copy link Quote reply

latheva commented Jan 25, 2018

Thanks, it helped me a lot.

This comment has been minimized.

Copy link Quote reply

dib258 commented Feb 12, 2018

I had to make some modification to make gist work ! 🙂

This comment has been minimized.

Copy link Quote reply

varshaan0sharma commented Mar 24, 2018

brew install homebrew/php/php71-mcrypt worked for me

This comment has been minimized.

Copy link Quote reply

marknt15 commented Mar 30, 2018

At first I tried to make it work but there are errors and I thought of another way. The MAMP way.
Add this in you .bash_profile

I will try the brew php71 way some other time

This comment has been minimized.

Copy link Quote reply

huebs commented Apr 2, 2018 •

I believe I just ran into a related issue:

If you’re seeing this error when opening a new terminal:

/.bashrc for a line that looks like this:

And change it to this:

If you’re seeing this error when opening a new terminal:

/.bashrc for a line that looks like this:

And change it to this:

This comment has been minimized.

Copy link Quote reply

ToniTonish commented Apr 9, 2018

i’m sorry if this isn’t the correct section where report errors.
i got this when brew install —with-homebrew-curl php71
the error is Warning: php@7.1: this formula has no —with-homebrew-curl option so it will be ignored!

any advice on how to solve it? i need to change from SSL Version => SecureTransport to SSL Version => OpenSSL/1.0.2j

This comment has been minimized.

Copy link Quote reply

heberfomin commented Apr 11, 2018

Hello Guys,
First of all, I’m sorry, I’m not an expert in linux environment, worst in MacOs so, if I made any stupid question, please forgive me.
I’m trying to install extension for MACOS php mcrypt. My environment is MacOs High Sierra with 7.1.1 php.
I’ve tryed this:
$ brew install php71-mcrypt php71-imagick

But I received these errors:
Error: No available formula with the name «php71-mcrypt»
==> Searching for a previously deleted formula (in the last month).
Error: No previously deleted formula found.
==> Searching for similarly named formulae.
==> Searching local taps.
Error: No similarly named formulae found.
==> Searching taps.
==> Searching taps on GitHub.
Error: No formulae found in taps.

it seems that i’m trying to install something that doesn’t exist anymore.

Does anybody knows how could I resolve this?

This comment has been minimized.

Copy link Quote reply

artcoholic commented Apr 12, 2018

I have the same problem as heberfomin. Any help would be appreciated. Thank you!

This comment has been minimized.

Copy link Quote reply

gotraveltoworld commented Apr 12, 2018 •

In fact, Homebrew/php is deprecated, so you can not use this command to install php71.

Today, I also find this problem, I still search for solutions.

You could see origin information from this: https://github.com/Homebrew/homebrew-php

This comment has been minimized.

Copy link Quote reply

aoberoi commented Apr 13, 2018

This comment has been minimized.

Copy link Quote reply

clozed2u commented Apr 13, 2018 •

@gotraveltoworld You can still install older version of PHP via homebrew by using php@ eg. php@7.1 . For extensions I recommend pecl.

This comment has been minimized.

Copy link Quote reply

EugenMayer commented Apr 13, 2018

@clozed2u problematic right now is xdebug though, but well, i do not need it.

This comment has been minimized.

Copy link Quote reply

w0rd-driven commented Apr 14, 2018

Ran into the depreciation today and the recommendation is buried at the end of Homebrew/homebrew-core#26362, to use pecl.

My need is fortunately only for imagick and xdebug and it was relatively trivial to run pecl install package but it just jams the extensions into php.ini haphazardly which don’t even point to the right location.

I was able to salvage the old files in /usr/local/etc/php/7.1/conf.d and for imagick the file is:

Where the directory /usr/local/Cellar/php@7.1/7.1.16_1/pecl/20160303/ is not /usr/local/Cellar/php@7.1/7.1.16_1/lib/php/20160303/ as it expects. I was getting errors like the following, repeated for each extension installed this way:

Fortunately it isn’t a huge manual change but this totally breaks the normal expected workflow and I sincerely hope I don’t have to do this manual hackery every time or I’m going to learn to stop updating php real quick.

Источник

Читайте также:  Перезагрузка windows при печати
Оцените статью