スポンサーリンク

【PHP】5.6.14 ソースからのコマンド最短インストール方法

2015年10月31日 現在

バージョンは 5.6.14 ですが、マイナーバージョン等でも問題なくインストールできると思います。
必要最低限のインストール方法なのでセッティング等は必要に応じてご設定ください。

■ 環境

CentOS 7
(基本的に他のバージョン、RedHat系OS でも問題ありません。)

■ ソースダウンロード、コンパイル先

/usr/local/src/

■ インストール先

/usr/local/

■ インストールディレクトリ

/usr/local/php-5.6.14

※ インストール後にシンボリックリンクにて下記で運用すると
複数のバージョンを確認でき、
また、バージョンアップ時にスムーズになるでしょう。

ln -s /usr/local/php-5.7.9 /usr/local/php

■ インストール

1.ダウンロード、解凍
・ダウンロード先へ移動

cd /usr/local/src/

・ソースを取得

wget --trust-server-names http://jp2.php.net/get/php-5.6.14.tar.gz/from/this/mirror
tar zxvf php-5.6.14.tar.gz
cd php-5.6.14

2.configure
・基本的に良く使われるオプションをしています。必要に応じて変更してください。
・オプションにMySQL のパスが指定してありますので、環境に応じて変更または、オプションを削除して下さい。

./configure \
--prefix=/usr/local/php-5.6.14 \
--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 \
--with-mysql=/usr/local/mysql \
--with-pdo-mysql=shared,/usr/local/mysql

configure エラー一覧(下記エラーが発生した場合は各モジュールをインストールして下さい。)
※ configure: error: xml2-config not found. Please check your libxml2 installation.

yum install -y libxml2 libxml2-devel

※ configure: error: Cannot find OpenSSL’s <evp.h>/strong>

yum install -y openssl openssl-devel

※ configure: error: Please reinstall the libcurl distribution – easy.h should be in <curl-dir>/include/curl/

yum install -y curl-devel

※ configure: error: jpeglib.h not found.

yum install -y libjpeg-devel

※ configure: error: png.h not found.

yum install -y libpng-devel

※ configure: error: freetype-config not found.

yum install -y freetype-devel

※ configure: error: mcrypt.h not found. Please reinstall libmcrypt.
・CentOS のリポジトリに存在しないため、yum リポジトリを追加しないとインストールできません。
・今回は直接 rpm をダウンロードしてインストールしました。

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

※ configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

yum install -y libxslt-devel

3.コンパイルとインストール

make
make test
make install

4.設定
・php.ini の設置

cp -p /usr/local/src/php-5.6.14/php.ini-development /usr/local/php-5.6.14/lib/php.ini

・シンボリックリンクを貼る

ln -s /usr/local/php-5.6.14 /usr/local/php

5.インストールの確認

/usr/local/php/bin/php -v
------------------------------------------------------------
PHP 5.6.14 (cli) (built: Oct 31 2015 21:35:23)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

 

以上

タイトルとURLをコピーしました