LoginSignup
5
2

More than 5 years have passed since last update.

CentOS 6.x に phpenv をインストール

Last updated at Posted at 2016-12-04

EPELリポジトリのインストール

PHPのビルドで利用する libmcrypt-devel や re2c パッケージはEPELリポジトリにあるようなので事前にインストール

bash
cd /tmp

curl -O http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm

yum -y install epel-release-6-8.noarch.rpm

# 追記: 
sudo sed -i 's/enabled=1/enabled=0/g;s/mirrorlist=https:/mirrorlist=http:/g' /etc/yum.repos.d/epel.repo

以前はなぜか問題なかったのですが、改めてやってみるとエラーで困りました。
cf. https://qiita.com/kyrya/items/d3a4cba0ff2aa9a4a402
cf. https://qiita.com/maruware/items/eb659266a45021cf486c

php の build に必要なパッケージのインストール

bash
yum -y --enablerepo=epel install git libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel libXpm-devel freetype-devel re2c libmcrypt-devel libicu-devel readline-devel libtidy-devel libxslt-devel bzip2-devel gcc gcc-c++ cmake

phpenv のインストール

特に指定しない場合は $HOME/.phpenv にインストールされますが、下記のようにインストール先を指定することもできます。

bash
# 例: `/usr/local/phpenv` にインストール
export PHPENV_ROOT="/usr/local/phpenv"

phpenv 本体のインストール

bash
curl -L https://raw.githubusercontent.com/CHH/phpenv/master/bin/phpenv-install.sh | bash

echo -e "export PATH=\"${PHPENV_ROOT}/bin:\$PATH\"\neval \"\$(phpenv init -)\"" >> ~/.bash_profile

source ~/.bash_profile

php-build のインストール

bash
yum -y install git

git clone https://github.com/php-build/php-build ${PHPENV_ROOT}/plugins/php-build

おまけ: PHPのインストール

bash
# バージョンは適宜
PHP_VERSION=7.1.0
phpenv install $PHP_VERSION
phpenv global $PHP_VERSION
phpenv rehash
# インストールバージョンを確認
php -v


5
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
5
2