Help us understand the problem. What is going on with this article?

macOS Mojaveで最新のPHP(7.3)にVersion upする

背景

なんてことはないけど、エラーが多発したので備忘録として

操作

Homebrewはインストールしている前提

$ brew search php@7
$ brew install php@7.3

Pythonインストール時にerrorがでる

An unexpected error occurred during the `brew link` step
The formula built, but is not symlinked into /usr/local
Permission denied @ dir_s_mkdir - /usr/local/Frameworks

以下のコマンド実行

$ sudo mkdir /usr/local/Frameworks
$ sudo chown $(whoami):admin /usr/local/Frameworks
$ brew link python

もう一度

$ brew search php@7
$ brew install php@7.3

今度は

Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink sbin/php-fpm
/usr/local/sbin is not writable.

You can try again using:
  brew link php

Pythonインストール時のエラー同様に以下を実行

$ sudo mkdir /usr/local/sbin
$ sudo chown $(whoami):admin /usr/local/sbin
$ brew link php

以下のメッセージがでる

If you need to have php@7.3 first in your PATH run:
  echo 'export PATH="/usr/local/opt/php@7.3/bin:$PATH"' >> ~/.bash_profile
  echo 'export PATH="/usr/local/opt/php@7.3/sbin:$PATH"' >> ~/.bash_profile

指示通り

$ echo 'export PATH="/usr/local/opt/php@7.3/bin:$PATH"' >> ~/.bash_profile
$ echo 'export PATH="/usr/local/opt/php@7.3/sbin:$PATH"' >> ~/.bash_profile
$ brew services start php

ターミナルを再起動してPHPのVersion確認

$ php -v

以下のメッセージが出れば成功

PHP 7.3.7 (cli) (built: Jul  5 2019 12:44:05) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.7, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.7, Copyright (c) 1999-2018, by Zend Technologies

念の為 phpinfoを確認

$ touch index.php
$ echo "<?php phpinfo(); ?>" >> index.php
$ php -S localhost:8000

スクリーンショット 2019-07-14 15.59.42.png

がphpinfoでも出ればOK.

参考

MacのPHPのバージョンを 7.3 に上げた

Homebrewで入れたPythonでのlinkエラー問題

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした