ravelll の日記

よしなに

CentOS7.2 で PHP5.3.29 をビルドする

そんな必要あるのか!時は2016年だぞ!という話かもしれませんが、実際必要になったのでメモしておきます。

$ cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

まずビルドに必要なツールを入れます。

$ sudo yum install pkg-config libtool

autoconf や bison は CentOS7 にバンドルされているバージョンでは新しすぎるので古いものを入れます。

$ sudo yum install autoconf213
$ wget -O http://rpm.pbone.net/index.php3/stat/4/idpl/14914325/dir/startcom_6/com/bison-2.4.1-5.SEL6.x86_64.rpm.html
$ rpm -ivh --force bison-2.4.1-5.SEL6.x86_64.rpm

buildconf して configure ファイルを作成します。

$ cd php-src
$ PHP_AUTOCONF=autoconf213 ./buildconf --force
$ ls configure
configure

エラー無く configure ファイルが生成されたら必要なビルドを付けて ./configure し、make -> make test -> make install します。

$ PHP_AUTOCONF=autoconf213 ./configure --with-config-file-path=/usr/local/php-5.3.29/etc --with-config-file-scan-dir=/usr/local/php-5.3.29/etc/conf.d --prefix=/usr/local/php-5.3.29 --libexecdir=/usr/local/php-5.3.29/libexec --without-pear --with-gd --enable-sockets --with-jpeg-dir=/usr --with-png-dir=/usr --enable-exif --enable-zip --with-zlib --with-zlib-dir=/usr --with-kerberos --with-openssl --with-mcrypt=/usr --enable-soap --enable-xmlreader --with-xsl --enable-ftp --enable-cgi --with-curl=/usr --with-tidy --with-xmlrpc --enable-sysvsem --enable-sysvshm --enable-shmop --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pdo-sqlite --enable-pcntl --with-readline --enable-mbstring --disable-debug --enable-fpm --enable-bcmath --with-pear --enable-mbstring --with-mysql=/usr --with-libdir=lib64
$ make
$ make test
$ make install

install できたと思ったら、phpinfo を見て構成を確認しましょう。

$ php -r 'phpinfo();' | less

以上です。よろしくお願い致します。