2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Last updated at Posted at 2019-07-14

背景

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

操作

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エラー問題

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?