【PHP】7.0.0 ソースからコマンド最短インストール方法
・バージョンは 7.0.0 ですが、7系のマイナーバージョン等でも問題なくインストールできると思います。
・必要最低限のインストール方法なのでセッティング等は必要に応じてご設定ください。
■ 環境
CentOS 7
(基本的に他のバージョン、RedHat系OS でも問題ありません。)
■ ソースダウンロード、コンパイル作業先
/usr/local/src/
■ インストールディレクトリ
/usr/local/php-7.0.0
※ インストール後にシンボリックリンクにて下記で運用すると
複数のバージョンを確認でき、
また、バージョンアップ時にスムーズになるので貼ることをお勧めします。バージョンを複数管理、切り替え等にも便利に利用できます。
1 |
ln -s /usr/local/php-7.0.0 /usr/local/php |
■ インストール
1.コンパイル用事前インストールモジュール
コンパイル時に下記のコマンド、モジュールが必要になりますので未インストールの場合は、yum 等でインストールしておきましょう。
1 2 3 |
yum -y install wget yum -y install gcc-c++ yum -y install libxml2 libxml2-devel |
同時にインストールする場合は下記コマンドを実行しましょう。
1 |
yum -y install wget gcc-c++ libxml2 libxml2-devel |
2.ダウンロード、解凍
・ダウンロード先へ移動
1 |
cd /usr/local/src/ |
・ソースの取得と作業ディレクトリへの移動
1 2 3 |
wget --trust-server-names http://jp2.php.net/get/php-7.0.0.tar.gz/from/this/mirror tar zxvf php-7.0.0.tar.gz cd php-7.0.0 |
3.configure
・必要に応じて変更してください。
・オプションにMySQL のパスが指定してありますので、環境に応じて変更または、オプションを削除して下さい。
■ 最小設定の場合(インストール先ディレクトリのみを指定しています。)
1 2 |
./configure \ --prefix=/usr/local/php-7.0.0 |
■ 基本的に利用頻度の高いオプションを指定した例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
./configure \ --prefix=/usr/local/php-7.0.0 \ --enable-mbstring \ --enable-mbregex \ --with-gd \ --with-freetype-dir=/usr/lib \ --with-jpeg-dir=/usr/lib \ --with-png-dir=/usr/lib \ --with-zlib-dir=/usr/lib \ --enable-gd-native-ttf \ --enable-gd-jis-conv \ --with-xsl \ --enable-dom \ --with-xsl=/usr/libz \ --with-mcrypt \ --with-gettext \ --enable-bcmath \ --enable-sockets \ --with-openssl \ --with-curl |
■ configure エラー一覧(下記エラーが発生した場合は各モジュールをインストールして下さい。)
※ configure: error: xml2-config not found. Please check your libxml2 installation.
1 |
yum -y install libxml2 libxml2-devel |
※ configure: error: Cannot find OpenSSL’s
1 |
yum -y install openssl openssl-devel |
※ configure: error: Please reinstall the libcurl distribution – easy.h should be in /include/curl/
1 |
yum -y install curl-devel |
※ configure: error: jpeglib.h not found.
1 |
yum -y install libjpeg-devel |
※ configure: error: png.h not found.
1 |
yum -y install libpng-devel |
※ configure: error: freetype-config not found.
1 |
yum -y install freetype-devel |
※ configure: error: mcrypt.h not found. Please reinstall libmcrypt.
・CentOS のリポジトリに存在しないため、yum リポジトリを追加しないとインストールできません。
・今回は直接 rpm をダウンロードしてインストールしました。
1 2 3 4 |
wget http://elders.princeton.edu/data/puias/unsupported/6/x86_64/libmcrypt-2.5.8-9.puias6.x86_64.rpm wget http://elders.princeton.edu/data/puias/unsupported/6/x86_64/libmcrypt-devel-2.5.8-9.puias6.x86_64.rpm rpm -ivh libmcrypt-2.5.8-9.puias6.x86_64.rpm rpm -ivh libmcrypt-devel-2.5.8-9.puias6.x86_64.rpm |
※ error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
1 |
yum -y install libxslt-devel |
4.コンパイルとインストール
1 2 3 |
make make test make install |
5.設定
・php.ini の設置
1 |
cp -p /usr/local/src/php-7.0.0/php.ini-development /usr/local/php-7.0.0/lib/php.ini |
・シンボリックリンクを貼る
1 |
ln -s /usr/local/php-7.0.0 /usr/local/php |
6.インストールの確認
1 2 3 4 5 |
/usr/local/php/bin/php -v ------------------------------------------------------------ PHP 7.0.0 (cli) (built: Dec 4 2015 08:59:44) ( NTS ) Copyright (c) 1997-2015 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies |