centos5にphp5.2.10をソースからインストール
2009.09.06
centos5.3にphpmyadminを入れようとしたら、without-mysqlでビルドされたphpパッケージで動かなかったため、ソースからインストールすることにした。
php5.2.10のインストール
yumで入れたphpを削除
configureを実行
以下は最終的にテストを通過したconfigureオプションです。
$ cd php-5.2.10
$ ./configure
--prefix=/usr
--exec-prefix=/usr
--bindir=/usr/bin
--build=i686-redhat-linux-gnu
--target=i386-redhat-linux
--cache-file=../config.cache
--datadir=/usr/share
--host=i686-redhat-linux-gnu
--includedir=/usr/include
--infodir=/usr/share/info
--libdir=/usr/lib
--libexecdir=/usr/libexec
--localstatedir=/var
--mandir=/usr/share/man
--program-prefix=
--sbindir=/usr/sbin
--sharedstatedir=/usr/com
--sysconfdir=/etc
--enable-calendar
--enable-cli
--enable-dom
--enable-exif
--enable-ftp
--enable-gd-native-ttf
--enable-json
--enable-mbstring=all
--enable-pdo
--enable-shmop
--enable-sockets
--enable-sysvmsg
--enable-sysvsem
--enable-sysvshm
--enable-ucd-snmp-hack
--enable-wddx
--enable-xmlreader
--enable-xmlwriter
--disable-rpath
--with-apxs2=/usr/sbin/apxs
--with-bz2
--with-config-file-path=/etc
--with-config-file-scan-dir=/etc/php.d
--with-curl=/usr
--with-exec-dir=/usr/bin
--with-freetype-dir=/usr
--with-gd=/usr
--with-gdbm
--with-gettext
--with-jpeg-dir=/usr
--with-kerberos
--with-layout=GNU
--with-libdir=lib
--with-libxml-dir=/usr
--with-mcrypt
--with-mysql
--with-openssl
--with-pcre-regex=/usr/local
--with-pear
--with-pic
--with-png-dir=/usr
--with-pspell=/usr
--with-sqlite
--with-t1lib=/usr/local
--with-unixODBC=shared,/usr
--with-xpm-dir=/usr
--with-zlib
--without-mime-magic
make
make install
configure時に発生したエラー
xml2-configが見つからないエラー
libxml2をインストールする。自分はファイル(libxml2-2.6.32.tar.gz)からインストール。yumでインストールしてもいいかも
g++コマンドが見つからないエラー
pcre.hが見つからないエラー
エラーメッセージ
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/からpcre-7.6.tar.gzを落としてインストール
# cd pcre-7.6
# ./configure
# make
# make test
# make install
pcreのインストール場所をかえたのでconfigureオプションに反映
/usr/sbin/apxsがみつからない
エラーメッセージ
1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)
The output of /usr/sbin/apxs follows:
./configure: line 6731: /usr/sbin/apxs: No such file or directory
configure: error: Aborting
httpd-develをインストール
bzip2がないのでエラー
エラーメッセージ
yumからインストール
GDのビルドに失敗する
エラー
必要なライブラリをインストール
libiconvをインストールする
$ tar zxvf libiconv-1.13.1.tar.gz
$ cd libiconv-1.13.1
$ configure --prefix=/usr/local
$ make
$ make install
LDFLAGSをセット
pspellがないのでエラー
エラーメッセージ
aspellライブラリをインストール
mysqlのヘッダーファイルがないのでエラー
エラーメッセージ
mysql-develをインストール
mcryptのヘッダーファイルがないのでエラー
エラーメッセージ
libmcrypt-develをインストール
ODBCヘッダーファイルがみつからないエラー
エラーメッセージ
unixODBCをインストール
make時に発生したエラー
libiconv関連
/home/yokada/php-5.2.10/ext/iconv/iconv.c:2491: undefined reference to `libiconv_open'
collect2: ld returned 1 exit status
make: *** [sapi/cli/php] エラー 1
やはり export LDFLAGS=-liconv しか解決策は無いのか?
ltdlが見つからない
collect2: ld returned 1 exit status
make: *** [libphp5.la] エラー 1
$ ./configure --enable-ltdl-install
$ make
$ make install
インストール確認
バージョンチェック
PHP 5.2.10 (cli) (built: Oct 12 2009 22:23:44)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
apache設定
/etc/httpd/conf.d/php.conf
AddHandler php5-script .php
AddType application/x-httpd-php .php .phtml
DirectoryIndex index.php
#AddType application/x-httpd-php-source .phps
apacheを再起動して、変更を有効にする。
追記
現在(2010年1月)では、下記のリポジトリでphp 5.2.11が提供されているので、それを利用して更新するのが手っとりばやい。
/etc/yum.repos.d/utterramblings.repo
name=Jason’s Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=0
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

