3
2

More than 5 years have passed since last update.

CentOS7にPHPBrewインストール

Last updated at Posted at 2015-07-25

自分でこんなサイトあったらいいなーって思い、たまにはPHPのフレームワークで実装してみようってことで、
今後を考慮し開発環境はPHPバージョン管理可能にしたい。
そこでPHPBrewのバージョン管理興味あったのでインストールしてみました。

PHPBrewに必要なモジュールをインストール

  • PHPインストールのオプションに依存するのでここは皆さんの環境に合わせてインストールしてください
  • libcryptはCentOSのリポジトリではインストールできないのでepelリポジトリ追加
yum install -y epel-release
vi /etc/yum.repos.d/rpmforge.repo
yum --enablerepo=epel install libmcrypt-devel
  • apxsを利用するため
yum install httpd httpd-devel
  • PHPBrewを利用するにはphpが必要
yum install php libxml2-devel bzip2-devel libxslt-devel 

PHPBrewインストール

  • インストール
# rootで実行する
cd /usr/local/src
curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew
chmod +x phpbrew
cp phpbrew /usr/bin/phpbrew
  • PHPBrewの設定を読み込む。
# rootで実行する
vi /etc/bashrc

# これを記載する
phpbrew init

# 設定反映する
source /etc/bashrc
  • PHPの複数バージョン管理をhogeユーザで利用可能にする
# hogeで実行する

vi /home/hoge/.bash_profile

# これを記載する
source ~/.phpbrew/bashrc

# 設定反映する
source /home/hoge/.bash_profile
  • 5.6.11をインストールする
# rootで実行。
# hogeでPHPBrewを利用してインストールするとapacheの設定あたりでパーミッションエラーとなるので変更。
chown root:hoge /usr/bin/apxs
chmod 774 /usr/bin/apxs
chown root:hoge /usr/lib64/httpd/modules
chmod 774 /usr/lib64/httpd/modules
chown root:hoge /etc/httpd/conf
chmod 774 /etc/httpd/conf

# hogeで実行
phpbrew install 5.6.11 +default +mysql +gd +json +mbregex +mbstring +mcrypt +readline +session +xml_all +apxs2=/usr/bin/apxs +openssl=/usr -- --with-libdir=lib64

主な操作

# 最新のPHPBrewリストを取得
phpbrew known --update

# インストールされているPHPを表示
phpbrew list

# 利用するPHPの反映。use switchどちらで利用可能
phpbrew use php-5.6.11
phpbrew off
phpbrew switch php-5.6.11
phpbrew switch-off

# 利用できる拡張モジュールリスト
phpbrew variants

# あとから拡張モジュール追加する場合
phpbrew ext install gd

# 拡張の有効無効切り替え
phpbrew ext enable gd
phpbrew ext disable gd

# 現在利用しているphpバージョンのphp.iniを編集
phpbrew config
3
2
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
3
2