centos5にphp5.2.10をソースからインストール
[]

2009.09.06

このエントリーをはてなブックマークに追加
はてなブックマーク - centos5にphp5.2.10をソースからインストール

centos5.3にphpmyadminを入れようとしたら、without-mysqlでビルドされたphpパッケージで動かなかったため、ソースからインストールすることにした。

php5.2.10のインストール

yumで入れたphpを削除

$ yum remove php\*

configureを実行

以下は最終的にテストを通過したconfigureオプションです。

$ tar zxf php-5.2.10.tar.gz
$ 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

make install

$make install

configure時に発生したエラー

xml2-configが見つからないエラー

libxml2をインストールする。自分はファイル(libxml2-2.6.32.tar.gz)からインストール。yumでインストールしてもいいかも

g++コマンドが見つからないエラー

$ yum install gcc-c++

pcre.hが見つからないエラー

エラーメッセージ

error: Could not find pcre.h in /usr

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/からpcre-7.6.tar.gzを落としてインストール

# tar zxvf pcre-7.6.tar.gz
# cd pcre-7.6
# ./configure
# make
# make test
# make install

pcreのインストール場所をかえたのでconfigureオプションに反映

--with-pcre-regex=/usr => --with-pcre-regex=/usr/local

/usr/sbin/apxsがみつからない

エラーメッセージ

Sorry, I cannot run apxs.  Possible reasons follow:

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をインストール

$ yum install httpd-devel

bzip2がないのでエラー

エラーメッセージ

configure: error: Please reinstall the BZip2 distribution =>

yumからインストール

$ yum -y install bzip2\*

GDのビルドに失敗する

エラー

configure: error: GD build test failed. Please check the config.log for details.

必要なライブラリをインストール

$ yum -y install gd gd-devel freetype freetype2 libpng libmng\* libtiff\* libjpeg\* libc-client\* giflib\*

libiconvをインストールする

$ curl -O http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
$ tar zxvf libiconv-1.13.1.tar.gz
$ cd libiconv-1.13.1
$ configure --prefix=/usr/local
$ make
$ make install

LDFLAGSをセット

export LDFLAGS=-liconv

pspellがないのでエラー

エラーメッセージ

configure: error: Cannot find pspell

aspellライブラリをインストール

$ yum install aspell-devel

mysqlのヘッダーファイルがないのでエラー

エラーメッセージ

configure: error: Cannot find MySQL header files under yes.

mysql-develをインストール

$ yum install mysql-devel

mcryptのヘッダーファイルがないのでエラー

エラーメッセージ

configure: error: mcrypt.h not found. Please reinstall libmcrypt.

libmcrypt-develをインストール

$ yum install libmcrypt-devel

ODBCヘッダーファイルがみつからないエラー

エラーメッセージ

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

unixODBCをインストール

$ yum install unixODBC unixODBC-devel

make時に発生したエラー

libiconv関連

ext/iconv/.libs/iconv.o: In function `php_iconv_stream_filter_ctor':
/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が見つからない

/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status
make: *** [libphp5.la] エラー 1
$ cd libmcrypt-2.5.7/libltdl/
$ ./configure --enable-ltdl-install
$ make
$ make install

インストール確認

バージョンチェック

$ php -v

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

LoadModule php5_module modules/libphp5.so

AddHandler php5-script .php
AddType application/x-httpd-php .php .phtml

DirectoryIndex index.php

#AddType application/x-httpd-php-source .phps

apacheを再起動して、変更を有効にする。

# apachectl restart

追記

現在(2010年1月)では、下記のリポジトリでphp 5.2.11が提供されているので、それを利用して更新するのが手っとりばやい。

/etc/yum.repos.d/utterramblings.repo

[utterramblings]
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
$ yum install --enablerepo=utterramblings php php-cli php-common php-gd php-mbstring php-mysql php-pdo php-pear

関連エントリー

Leave a Reply