LoginSignup
0
0

More than 1 year has passed since last update.

asdfでPHPやNode.jsをインストールしたかった

Posted at

はじめに

複数言語のバージョン管理ができるasdfでPHPやNode.jsをインストールしたかったというお話。
結論、 PHPプラグインのAppleシリコン対応がまだ不十分なのでHomebrewでPHPをインストールしつつ、Dockerでマルチバージョン環境を作るのが良さそう。

環境

Mac mini m1

asdf

brew install asdf
echo -e "\n. $(brew --prefix asdf)/libexec/asdf.sh" >> ${ZDOTDIR:-~}/.zshrc

Node.js

brew install gpg gawk
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git

asdf list all nodejs lts
asdf global nodejs lts

で現時点で最新のLTS(16.x)がインストールされます。

PHP

ざんねんながら現時点ではasdfでPHPを使うのは面倒そうなのでHomebrewを使います。

8.1(最新バージョン)はバージョン指定なし、それ以前はバージョン番号を@以降に付けて(例:php@7.4)インストール

brew install php

Xdebugをインストール

pecl install xdebug

php.iniの先頭にモジュールの読み込みが追加されているので

/opt/homebrew/etc/php/8.1/php.ini
zend_extension="xdebug.so"

その直下にモード設定を追加

/opt/homebrew/etc/php/8.1/php.ini
zend_extension="xdebug.so"
xdebug.mode=debug

一般的なお作法通りに設定するなら

/opt/homebrew/etc/php/8.1/php.ini
[xdebug]
zend_extension="xdebug.so"
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9003

ついでにデフォルトタイムゾーンの設定も追加

/opt/homebrew/etc/php/8.1/php.ini
;date.timezone =
date.timezone = "Asia/Tokyo"

複数バージョン使いたいならDockerの利用を検討するのが良さそう。

0
0
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
0
0