背景
なんてことはないけど、エラーが多発したので備忘録として
操作
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
がphpinfoでも出ればOK.