facebook twitter hatena line email

「Mac/インストール/asdf」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(ページの作成:「==インストール== $ brew install asdf ==shell設定== $ echo -e "\n. $(brew --prefix asdf)/libexec/asdf.sh" >> ~/.zshrc $ source ~/.zshrc ==バージョン確...」)
 
(phpのpathが通ってない場合)
 
(同じ利用者による、間の23版が非表示)
行1: 行1:
 +
==asdfとは==
 +
php,ruby,nodeなどで使えるバージョン管理ツール。
 +
 +
後継にmiseがある。
 +
 +
[[mac/インストール/mise]] [ショートカット]
 +
 
==インストール==
 
==インストール==
 
  $ brew install asdf
 
  $ brew install asdf
行11: 行18:
  
 
==phpプラグイン入れるための準備==
 
==phpプラグイン入れるための準備==
$ brew install bison
+
<pre>
 +
brew install autoconf
 +
brew install automake
 +
brew install libtool
 +
brew install pkg-config
 +
brew install bison
 +
brew install re2c
 +
brew install libzip
 +
brew install oniguruma
 +
 
 +
brew install icu4c
 +
export PKG_CONFIG_PATH="/opt/homebrew/opt/icu4c/lib/pkgconfig"
 +
export LDFLAGS="-L/opt/homebrew/opt/icu4c/lib"
 +
export CPPFLAGS="-I/opt/homebrew/opt/icu4c/include"
 +
 
 +
brew install openssl@3
 +
export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib"
 +
export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"
 +
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig"
 +
</pre>
  
 
==phpプラグイン追加==
 
==phpプラグイン追加==
 
  $ asdf plugin add php
 
  $ asdf plugin add php
  
===php利用可能バージョン==
+
===php利用可能バージョン===
 
  $ asdf list all php
 
  $ asdf list all php
 
<pre>
 
<pre>
行30: 行56:
 
asdf install php 8.5.4
 
asdf install php 8.5.4
 
</pre>
 
</pre>
 +
 +
===composerエラーになる場合===
 +
<pre>
 +
Warning: copy(https://getcomposer.org/installer): Failed to open stream: No such file or directory in Command line code on line 1
 +
Installer verified
 +
Some settings on your machine make Composer unable to work properly.
 +
Make sure that you fix the issues listed below and run this script again:
 +
 +
The openssl extension is missing, which means that secure HTTPS transfers are impossible.
 +
If possible you should enable it or recompile php with --with-openssl
 +
</pre>
 +
 +
--with-openssl をつけてphpをいれる。
 +
PHP_CONFIGURE_OPTIONS="--with-openssl --with-iconv=$(brew --prefix libiconv)" \
 +
asdf install php  8.5.4
 +
 +
composerは手動で入れる。
 +
<pre>
 +
curl -sS https://getcomposer.org/installer | php
 +
mv composer.phar /usr/local/bin/composer
 +
</pre>
 +
 +
==phpインストール済みリスト==
 +
asdf list php
  
 
==phpデフォルト==
 
==phpデフォルト==
  asdf global php 8.5.4
+
  $ asdf global php 8.5.4
  php -v
+
  $ php -v
 +
PHP 8.5.4 (cli) (built: Mar 10 2026 23:15:23) (NTS)
 +
 
 +
==php.ini場所==
 +
~/.asdf/installs/php/5.6.40/etc/php.ini
 +
~/.asdf/installs/php/8.5.4/etc/php.ini
 +
 
 +
==phpのpathが通ってない場合==
 +
export PATH="$HOME/.asdf/shims:$PATH"
 +
source ~/.zshrc
 +
# 確認
 +
echo $PATH
 +
 
 +
==asdfアンインストール==
 +
確認
 +
brew list | grep asdf
 +
アンインストール
 +
brew uninstall asdf
 +
user内データ削除
 +
rm -rf ~/.asdf
 +
~/.zshrc内のasdf削除
 +
vi ~/.zshrc
 +
更新
 +
source ~/.zshrc

2026年4月10日 (金) 14:50時点における最新版

asdfとは

php,ruby,nodeなどで使えるバージョン管理ツール。

後継にmiseがある。

mac/インストール/mise [ショートカット]

インストール

$ brew install asdf

shell設定

$ echo -e "\n. $(brew --prefix asdf)/libexec/asdf.sh" >> ~/.zshrc
$ source ~/.zshrc

バージョン確認

$ asdf --version
$ asdf version 0.18.1 (revision unknown)

phpプラグイン入れるための準備

brew install autoconf
brew install automake
brew install libtool
brew install pkg-config
brew install bison
brew install re2c
brew install libzip
brew install oniguruma

brew install icu4c
export PKG_CONFIG_PATH="/opt/homebrew/opt/icu4c/lib/pkgconfig"
export LDFLAGS="-L/opt/homebrew/opt/icu4c/lib"
export CPPFLAGS="-I/opt/homebrew/opt/icu4c/include"

brew install openssl@3
export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig"

phpプラグイン追加

$ asdf plugin add php

php利用可能バージョン

$ asdf list all php
5.6.40
7.4.33
8.5.4

phpインストール例

asdf install php 5.6.40
asdf install php 7.4.33
asdf install php 8.5.4

composerエラーになる場合

Warning: copy(https://getcomposer.org/installer): Failed to open stream: No such file or directory in Command line code on line 1
Installer verified
Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:

The openssl extension is missing, which means that secure HTTPS transfers are impossible.
If possible you should enable it or recompile php with --with-openssl

--with-openssl をつけてphpをいれる。

PHP_CONFIGURE_OPTIONS="--with-openssl --with-iconv=$(brew --prefix libiconv)" \
asdf install php  8.5.4

composerは手動で入れる。

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

phpインストール済みリスト

asdf list php

phpデフォルト

$ asdf global php 8.5.4
$ php -v
PHP 8.5.4 (cli) (built: Mar 10 2026 23:15:23) (NTS)

php.ini場所

~/.asdf/installs/php/5.6.40/etc/php.ini
~/.asdf/installs/php/8.5.4/etc/php.ini

phpのpathが通ってない場合

export PATH="$HOME/.asdf/shims:$PATH"
source ~/.zshrc
# 確認
echo $PATH

asdfアンインストール

確認

brew list | grep asdf

アンインストール

brew uninstall asdf

user内データ削除

rm -rf ~/.asdf

~/.zshrc内のasdf削除

vi ~/.zshrc

更新

source ~/.zshrc