CentOS 6.8 PHP5.1をソースからインストール

2021-06-24

CentOS 6 に PHP5.1のインストール

CentOS 5がサポート期間終了で、CentOS 6.8に移行する案件で、以前のPHPのバージョン(PHP 5.1)のままで移行する必要がありましたその際にソースからインストールした記事です。

CentOS 5.1のconfigureのオプションを確認

CentOS 5の場合は、yumでインストールしたので、インストール時のconfigureのオプションが分かりません。configureのオプションは以下のコマンドでわかります

php -i | grep configure | sed -e 's/ /\n/g’

ずらずらと長いオプションが表示されます。

$ php -i | grep configure | sed -e 's/ /\n/g'
Configure
Command
=>

'./configure'
'--build=x86_64-redhat-linux-gnu'
'--host=x86_64-redhat-linux-gnu'
'--target=x86_64-redhat-linux-gnu'
'--program-prefix='
'--prefix=/usr'
'--exec-prefix=/usr'
'--bindir=/usr/bin'
'--sbindir=/usr/sbin'
'--sysconfdir=/etc'
'--datadir=/usr/share'
'--includedir=/usr/include'
'--libdir=/usr/lib64'
'--libexecdir=/usr/libexec'
'--localstatedir=/var'
'--sharedstatedir=/usr/com'
'--mandir=/usr/share/man'
'--infodir=/usr/share/info'
'--cache-file=../config.cache'
'--with-libdir=lib64'
'--with-config-file-path=/etc'
'--with-config-file-scan-dir=/etc/php.d'
'--disable-debug'
'--with-pic'
'--disable-rpath'
'--without-pear'
'--with-bz2'
'--with-curl'
'--with-exec-dir=/usr/bin'
'--with-freetype-dir=/usr'
'--with-png-dir=/usr'
'--enable-gd-native-ttf'
'--without-gdbm'
'--with-gettext'
'--with-gmp'
'--with-iconv'
'--with-jpeg-dir=/usr'
'--with-openssl'
'--with-png'
'--with-pspell'
'--with-expat-dir=/usr'
'--with-pcre-regex=/usr'
'--with-zlib'
'--with-layout=GNU'
'--enable-exif'
'--enable-ftp'
'--enable-magic-quotes'
'--enable-sockets'
'--enable-sysvsem'
'--enable-sysvshm'
'--enable-sysvmsg'
'--enable-track-vars'
'--enable-trans-sid'
'--enable-yp'
'--enable-wddx'
'--with-kerberos'
'--enable-ucd-snmp-hack'
'--with-unixODBC=shared,/usr'
'--enable-memory-limit'
'--enable-shmop'
'--enable-calendar'
'--enable-dbx'
'--enable-dio'
'--with-mime-magic=/usr/share/file/magic.mime'
'--without-sqlite'
'--with-libxml-dir=/usr'
'--with-xml'
'--with-system-tzdata'
'--enable-force-cgi-redirect'
'--enable-pcntl'
'--with-imap=shared'
'--with-imap-ssl'
'--enable-mbstring=shared'
'--enable-mbstr-enc-trans'
'--enable-mbregex'
'--with-ncurses=shared'
'--with-gd=shared'
'--enable-bcmath=shared'
'--enable-dba=shared'
'--with-db4=/usr'
'--with-xmlrpc=shared'
'--with-ldap=shared'
'--with-ldap-sasl'
'--with-mysql=shared,/usr'
'--with-mysqli=shared,/usr/lib64/mysql/mysql_config'
'--enable-dom=shared'
'--with-dom-xslt=/usr'
'--with-dom-exslt=/usr'
'--with-pgsql=shared'
'--with-snmp=shared,/usr'
'--enable-soap=shared'
'--with-xsl=shared,/usr'
'--enable-xmlreader=shared'
'--enable-xmlwriter=shared'
'--enable-fastcgi'
'--enable-pdo=shared'
'--with-pdo-odbc=shared,unixODBC,/usr'
'--with-pdo-mysql=shared,/usr/lib64/mysql/mysql_config'
'--with-pdo-pgsql=shared,/usr'
'--with-pdo-sqlite=shared,/usr'
'--enable-dbase=shared'

このままでは不要な文字が入っているので、私の場合はviで生成して以下のようにしました

$ php -i | grep configure | sed -e 's/ /\n/g' > php_confugure_o.txt
$ vim php_confugure_o.txt 
#「'」を空白に置換して削除
:%s/\'//g

#「改行キー」を置換して一行に統一
:%s/$¥n/ /g

# 置換すると以下のようになります。
# 一行で置換されますが、見やすくするために改行を入れています
./configure
--build=x86_64-redhat-linux-gnu
--host=x86_64-redhat-linux-gnu
--target=x86_64-redhat-linux-gnu
--program-prefix=
--prefix=/usr
--exec-prefix=/usr
--bindir=/usr/bin
--sbindir=/usr/sbin
--sysconfdir=/etc
--datadir=/usr/share
--includedir=/usr/include
--libdir=/usr/lib64
--libexecdir=/usr/libexec
--localstatedir=/var
--sharedstatedir=/usr/com
--mandir=/usr/share/man
--infodir=/usr/share/info
--cache-file=../config.cache
--with-libdir=lib64
--with-config-file-path=/etc
--with-config-file-scan-dir=/etc/php.d
--disable-debug
--with-pic
--disable-rpath
--without-pear
--with-bz2
--with-curl
--with-exec-dir=/usr/bin
--with-freetype-dir=/usr
--with-png-dir=/usr
--enable-gd-native-ttf
--without-gdbm
--with-gettext
--with-gmp
--with-iconv
--with-jpeg-dir=/usr
--with-openssl
--with-png
--with-pspell
--with-expat-dir=/usr
--with-pcre-regex=/usr
--with-zlib
--with-layout=GNU
--enable-exif
--enable-ftp
--enable-magic-quotes
--enable-sockets
--enable-sysvsem
--enable-sysvshm
--enable-sysvmsg
--enable-track-vars
--enable-trans-sid
--enable-yp
--enable-wddx
--with-kerberos
--enable-ucd-snmp-hack
--with-unixODBC=shared,/usr
--enable-memory-limit
--enable-shmop
--enable-calendar
--enable-dbx
--enable-dio
--without-sqlite
--with-libxml-dir=/usr
--with-xml
--with-system-tzdata
--enable-force-cgi-redirect
--enable-pcntl
--with-imap=shared
--with-imap-ssl
--enable-mbstring=shared
--enable-mbstr-enc-trans
--enable-mbregex
--with-ncurses=shared
--with-gd=shared
--enable-bcmath=shared
--enable-dba=shared
--with-db4=/usr
--with-xmlrpc=shared
--with-ldap=shared
--with-ldap-sasl
--with-mysql=shared,/usr
--with-mysqli=shared,/usr/lib64/mysql/mysql_config
--enable-dom=shared
--with-dom-xslt=/usr
--with-dom-exslt=/usr
--with-pgsql=shared
--with-snmp=shared,/usr
--enable-soap=shared
--with-xsl=shared,/usr
--enable-xmlreader=shared
--enable-xmlwriter=shared
--enable-fastcgi
--enable-pdo=shared
--with-pdo-odbc=shared,unixODBC,/usr
--with-pdo-mysql=shared,/usr/lib64/mysql/mysql_config
--with-pdo-pgsql=shared,/usr
--with-pdo-sqlite=shared,/usr
--enable-dbase=shared

CentOS 6 に PHP5.1をソースからインストール

configureのオプションがわかったんで、configureでMakefile実行します

# 改行を入れていますが、実際には1行です

$ ./configure
--build=x86_64-redhat-linux-gnu
--host=x86_64-redhat-linux-gnu
--target=x86_64-redhat-linux-gnu
--program-prefix=
--prefix=/usr
--exec-prefix=/usr
--bindir=/usr/bin
--sbindir=/usr/sbin
--sysconfdir=/etc
--datadir=/usr/share
--includedir=/usr/include
--libdir=/usr/lib64
--libexecdir=/usr/libexec
--localstatedir=/var
--sharedstatedir=/usr/com
--mandir=/usr/share/man
--infodir=/usr/share/info
--cache-file=../config.cache
--with-libdir=lib64
--with-config-file-path=/etc
--with-config-file-scan-dir=/etc/php.d
--disable-debug
--with-pic
--disable-rpath
--without-pear
--with-bz2
--with-curl
--with-exec-dir=/usr/bin
--with-freetype-dir=/usr
--with-png-dir=/usr
--enable-gd-native-ttf
--without-gdbm
--with-gettext
--with-gmp
--with-iconv
--with-jpeg-dir=/usr
--with-openssl
--with-png
--with-pspell
--with-expat-dir=/usr
--with-pcre-regex=/usr
--with-zlib
--with-layout=GNU
--enable-exif
--enable-ftp
--enable-magic-quotes
--enable-sockets
--enable-sysvsem
--enable-sysvshm
--enable-sysvmsg
--enable-track-vars
--enable-trans-sid
--enable-yp
--enable-wddx
--with-kerberos
--enable-ucd-snmp-hack
--with-unixODBC=shared,/usr
--enable-memory-limit
--enable-shmop
--enable-calendar
--enable-dbx
--enable-dio
--without-sqlite
--with-libxml-dir=/usr
--with-xml
--with-system-tzdata
--enable-force-cgi-redirect
--enable-pcntl
--with-imap=shared
--with-imap-ssl
--enable-mbstring=shared
--enable-mbstr-enc-trans
--enable-mbregex
--with-ncurses=shared
--with-gd=shared
--enable-bcmath=shared
--enable-dba=shared
--with-db4=/usr
--with-xmlrpc=shared
--with-ldap=shared
--with-ldap-sasl
--with-mysql=shared,/usr
--with-mysqli=shared,/usr/lib64/mysql/mysql_config
--enable-dom=shared
--with-dom-xslt=/usr
--with-dom-exslt=/usr
--with-pgsql=shared
--with-snmp=shared,/usr
--enable-soap=shared
--with-xsl=shared,/usr
--enable-xmlreader=shared
--enable-xmlwriter=shared
--enable-fastcgi
--enable-pdo=shared
--with-pdo-odbc=shared,unixODBC,/usr
--with-pdo-mysql=shared,/usr/lib64/mysql/mysql_config
--with-pdo-pgsql=shared,/usr
--with-pdo-sqlite=shared,/usr
--enable-dbase=shared

ここからが本番です、エラーがたくさんでて必要なパッケージをインストールしていきます

apxsが無いと怒っているので、httpd-develを入れます

/usr/sbin/apxs: No such file or directory
configure: error: Aborting
# yum install httpd-devel

「libcurl」が足りないみたいです。curl-develを入れます

configure: error: Please reinstall the libcurl distribution -
    easy.h should be in /include/curl/
# yum install curl-devel

configure: error: Could not find pcre.h in /usr のエラー止まります。「pcre-devel」を入れます

 configure: error: Could not find pcre.h in /usr
# yum install pcre-devel

configure: error: Please reinstall the BZip2 distribution のエラー止まります。「bzip2-devel」を入れます

 configure: error: Please reinstall the BZip2 distribution
# yum install bzip2-devel

configure: error: freetype2 not found! のエラー止まります。「freetype freetype-devel」を入れます

If configure fails try --with-xpm-dir=

configure: error: freetype2 not found! # yum install freetype freetype-develconfigure: error: Unable to locate gmp.h のエラー止まります。「gmp-devel」を入れます

configure: error: Unable to locate gmp.h
# yum install gmp-devel

configure: error: Cannot find rfc822.h. Please check your c-client installation. のエラー止まります。「libc-client-devel」を入れます

configure: error: Cannot find rfc822.h. Please check your c-client installation.
# yum install libc-client-devel

MySQLの入れ忘れです。MySQL関係をインストールします

configure: error: Cannot find MySQL header files under /usr.
Note that the MySQL client library is not bundled anymore!
# yum install mysql-devel mysql-server

error: ODBC header file '/usr/include/sqlext.h’ not のエラー止まります。「unixODBC-devel」を入れます

checking for unixODBC support... configure: error: ODBC header file '/usr/include/sqlext.h' not found!
# yum install unixODBC-devel

configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path のエラー止まります。「postgresql-devel」を入れます

configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
# yum install postgresql-devel

configure: error: Please reinstall the sqlite3 distribution のエラー止まります。「sqlite-devel」を入れます

configure: error: Please reinstall the sqlite3 distribution
# yum install sqlite-devel

configure: error: Cannot find pspell のエラー止まります。「aspell-devel.x86_64」を入れます

configure: error: Cannot find pspell
# yum install aspell-devel.x86_64

configure: error: SNMP sanity check failed. Please check config.log for more information. のエラー止まります。「net-snmp net-snmp-devel」を入れます

configure: error: SNMP sanity check failed. Please check config.log for more information.
# yum install net-snmp net-snmp-devel

configure: error: xslt-config not found. Please reinstall the libxslt >= 1.0.18 distribution のエラー止まります。「libxslt-devel」を入れます

configure: error: xslt-config not found. Please reinstall the libxslt >= 1.0.18 distribution
# yum install libxslt-devel

とても手間がかかりましたが、何かとか configure がとおりました

+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

PHP 5.1のmakeを実行

何とかconfigure が通りましたので、makeを実行します。だけどここで落とし穴がありました。

makeすると、以下のエラーで止まります。調べてみるとOpenSSLの特定バージョンとPHPの相性問題でコンパイルエラーが発生するようです。

【参考URL】
PHP :: Bug #53547 :: Cannot compile PHP with OpenSSL
CentOS 6.3に「–with-openssl」オプション付きでPHP 5.1/5.2系をインストールしようとするとエラー

# make
/usr/local/src/php-5.1.6/ext/openssl/openssl.c:2073: error: 'struct php_x509_request' has no member named 'priv_key_encrypt'
make: *** [ext/openssl/openssl.lo] Error 1

ここまで頑張ってエラーで駄目になったので力尽きてもう少し深く調べて解決方法を調べる元気が無くなりました。ソースからのインストールは諦めて違う方法をインストールしています

スポンサーリンク

0
0

LinuxCentOS 6

Posted by admin