[PHP] CentOS5.3 で PHP5.3をインストール(YUM風オプションで)
こんばんは松本です。
PHP5.3.0がリリースされてから3ヶ月経ちましたが、だいぶ使い勝手にも慣れて来ました。
PHP5.3.1でのBugFixの数もすごいですが、ガベージコレクトやstatic属性など、便利機能が多いですので是非。
自分は CentOS5 x86_64 で利用しているのですが、PHP5.3を導入するにあたり、ソースコードからインストールしています。
できるだけ、標準のPHP(5.1.6)のオプションを踏襲した形でPHP5.3をインストールしました。
既存のPHP(5.1.6)をアンインストール
yum remove php*
付随する php-common などのライブラリも全てアンインストールします。
自分の環境ではYUM経由のPHP関係のライブラリをフルフルに入れていましたので、以下がアンインストールされました。
アンインストールされたYUMライブラリ
php php-bcmath php-cli php-common php-dba php-devel php-eaccelerator php-gd php-imap php-jpgraph-docs php-ldap php-mbstring php-mysql php-ncurses php-odbc php-pdo php-pear php-pear-Date php-pear-File php-pear-HTTP-Request php-pear-MDB2 php-pear-MDB2-Driver-mysql php-pear-Mail-Mime php-pear-Net-Sieve php-pear-Net-Socket php-pear-Net-URL php-pear-date php-pear-db php-pear-file php-pecl-Fileinfo php-pecl-memcache php-pecl-session_mysql php-pgsql php-snmp php-soap php-xml php-xmlrpc
必要なライブラリのインストール
phpをソースコードからインストールするための必要となるライブラリをyumでインストールします。
※レポジトリにはrpmforgeも入れています。
後からpeclのmemcacheも利用しますので、memcached自体もインストールしています。
yum -y install ncurses* yum -y install gcc-c++ yum -y install flex yum -y install libxml* yum -y install gdbm-devel yum -y install gd gd-devel freetype freetype libpng libmng* libtiff* libjpeg* libc-client* giflib* yum -y install httpd httpd-devel yum -y install pcre-devel yum -y install unixODBC-devel yum -y install net-snmp-devel yum -y install openssl* yum -y install bzip2* yum -y install curl* yum -y install gdbm* yum -y install db4* yum -y install gmp* yum -y install libc-client* yum -y install openldap* yum -y install libmcrypt* yum -y install mhash* yum -y install mysql* yum -y install freetds* yum -y install aspell* yum -y install readline* yum -y install libtidy* yum -y install libxslt* yum -y install libtool* yum -y install curl* yum -y install memcache*
PHPのソースコードをダウンロード
php.net からPHPのソースコードをダウンロードします。ダウンロードは こちら から。
wget http://jp2.php.net/get/php-5.3.0.tar.gz/from/this/mirror tar xvzf php-5.3.0.tar.gz
configure
一番面倒なconfigureですが、自分の環境では以下を通しました。
x86_64(64bit環境)の指定と yumでインストールしたapxsのパスあたりがキモです。
./configure \ --with-apxs2=/usr/sbin/apxs \ --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 \ --with-pic \ --with-bz2 \ --with-curl \ --with-exec-dir=/usr/bin \ --with-freetype-dir=/usr \ --with-png-dir=/usr \ --enable-gd-native-ttf \ --with-gettext \ --with-gmp \ --with-iconv \ --with-jpeg-dir=/usr \ --with-openssl \ --with-pcre-regex=/usr/local \ --with-zlib \ --with-layout=GNU \ --enable-exif \ --enable-ftp \ --enable-magic-quotes \ --enable-sockets \ --enable-sysvsem \ --enable-sysvshm \ --enable-sysvmsg \ --enable-wddx \ --enable-ucd-snmp-hack \ --enable-shmop \ --enable-calendar \ --with-libxml-dir=/usr \ --enable-pcntl \ --enable-mbstring \ --enable-mbregex \ --with-gd=shared \ --enable-bcmath=shared \ --enable-dba=shared \ --with-db4=/usr \ --with-xmlrpc=shared \ --with-mysql=/var/lib/mysql \ --with-mysql-sock=/var/lib/mysql/mysql.sock \ --with-mysqli=shared,/usr/bin/mysql_config \ --enable-dom=shared \ --enable-soap=shared \ --with-xsl=shared,/usr \ --enable-xmlreader=shared \ --enable-xmlwriter=shared \ --with-pdo-mysql=shared,/usr \ --enable-zip \ --enable-zend-multibyte \ --with-mcrypt
make ~ インストール
configureが通ったらmakeします。
sudo make install
php -v で以下のように正常にでればとりあえずOKです。
$ php -v PHP 5.3.0 (cli) (built: Jul 20 2009 20:59:23) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
あとはphpinfoで詳細を確認します。
PECLをインストール
peclはコマンドからインストールします。
自分は以下のPECLを利用しています。
pecl install memcache pecl install APC-3.1.3p1 pecl install imagick pecl install tokyo_tyrant-beta pecl install hidef-0.1.2 pecl install xdebug-2.1.0beta1
それぞれのPECLの設定方法については、また後述していきたいと思います。
いかがでしょうか。さらっとした覚え書きではありますが、お役に立てますと幸いです。









[PHP] PHP5.3でAPC3.1.3をインストール - ありんく tech-log | 2009年10月2日 PM 1:17 #
[...] [PHP] CentOS5.3 で PHP5.3をインストール(YUM風オプションで) [...]
[PHP] PHP5.3.0でのアクセラレータ導入 - ありんく tech-log | 2009年10月2日 PM 1:18 #
[...] [PHP] CentOS5.3 で PHP5.3をインストール(YUM風オプションで) [...]