インストール(アップグレード)を行う前に必ずサーバのバックアップをとること!
■ソースの入手
wget http://jp2.php.net/distributions/php-5.3.0.tar.gz
■解凍
tar -xvf php-5.3.0.tar.gz
参考
■configure
configureは環境を検査しソースコードの修正を行う。
./configure --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-exec-dir=/usr/bin --with-pcre-regex=/usr --enable-bcmath --enable-dom --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-soap --enable-xml --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 --enable-soap --disable-fileinfo --with-apxs2=/usr/sbin/apxs --with-unixODBC=shared,/usr --with-freetype-dir=/usr/include --with-bz2 --with-curl --with-mysql=/usr/lib64/mysql/mysql_config --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --with-gettext --with-kerberos=/usr/kerberos --with-mcrypt --with-mhash --with-pear --with-gd --with-zlib --with-jpeg-dir=/usr/local/lib --with-png-dir=/usr/local/lib --with-openssl
参考
エラー1
loading cache ./config.cache
checking for Cygwin environment... no
checking for mingw32 environment... no
checking for egrep... grep -E
checking for a sed that does not truncate output... //bin/sed
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for gcc... no
checking for cc... no
configure: error: no acceptable cc found in $PATH
対策
yum install gcc
これで上述のエラーは出なくなる。
エラー2
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
対策
yum install gcc-c++
エラー2
checking for Apache 2.0 handler-module support via DSO through 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 apxs follows:
./configure: line 6548: apxs: command not found
configure: error: Aborting
親切だ。親切な書き方だが何して良いか全く分からない。
対策
httpd-develのインストールだ。
yum install httpd-devel
エラー3
どうやらxml関連のエラーのようだ。
checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2 installation.
対策
libxslt-develのインストールだ。
yum install libxslt-devel
エラー4
OpenSSLが無いと言われる。
Cannot find OpenSSL's libraries
対策
yum install openssl-devel
しかし以下のようにopenssl関係でエラーが出るようだ。
checking for pkg-config... /usr/bin/pkg-config
configure: error: Cannot find OpenSSL's <evp.h>
対策
wget http://www.openssl.org/source/openssl-0.9.8k.tar.gz
tar xzf openssl-0.9.8k.tar.gz
cd openssl-0.9.8k
./config --prefix=/usr/local shared -fPIC
make
make install
間違ったconfigureオプションを指定すると、configureできずに一瞬で終了するので注意が必要だ。特にshredや-fPCがついてないと後でmakeのときに、エラーが表示され困ったことになる。
参考
エラー5
libjpeg関連でエラーが出るようだ。
configure: error: libjpeg.(a|so) not found.
対策
wget http://www.ijg.org/files/jpegsrc.v7.tar.gz
tar xzf jpegsrc.v7.tar.gz
cd jpeg-7
./configure --prefix=/usr/local --enable-shared --enable-static
make
make install
yum install libjpeg-devel
参考
エラー6
libpng関連でエラーが出るようだ。
checking for jpeg_read_header in -ljpeg... yes
configure: error: libpng.(a|so) not found.
対策
wget http://jaist.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.39.tar.gz
tar xvf libpng-1.2.39.tar.gz
cd libpng-1.2.39
./configure --prefix=/usr/local --enable-shared
make
make install
yum install libpng-devel
参考
エラー7
freetype関連でエラーが出る。
configure: error: freetype.h not found.
対策
freetypeのインストールだ。
yum install freetype
yum install freetype-devel
エラー8
どうやらlibmcrypt関連のエラーらしい。
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
対策
開発ライブラリのインストールだ。
yum install libmcrypt-devel
エラー9
どうやらlibmysqlclientがみつからないと言われているらしい。
configure:58647: checking for mysql_close in -lmysqlclient
configure:58666: gcc -o conftest -I/usr/include -g -O2 -fvisibility=hidden -Wl,-rpath,/usr/lib/mysql -L/usr/lib/mysql -L/usr/lib -Wl,-rpath,/usr/local/lib -L/usr/local/lib conftest.c -lmysqlclient -lmcrypt -lltdl -lfreetype -lpng -lz -ljpeg -lssl -lcrypto -lz -lssl -lcrypto -lm -ldl -lnsl -lxml2 -lz -lm -lxml2 -lz -lm 1>&5/usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.so when searching for -l
mysqlclient
/usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.a when searching for -lm
ysqlclient
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
configure: failed program was:
#line 58655 "configure"
#include "confdefs.h"
configure:58889: checking for mysql_error in -lmysqlclient
configure:58908: gcc -o conftest -I/usr/include -g -O2 -fvisibility=hidden -Wl,-rpath,/usr/lib/mysql -L/usr/lib/mysql -L/usr/lib -Wl,-rpath,/usr/local/lib -L/usr/local/lib -Wl,-rpath,/usr -L/usr conftest.c -lmysqlclient -lz -lmcrypt -lltdl -lfreetype -lpng -lz -ljpeg -lssl -lcrypto -lz -lssl -lcrypto -lm -ldl -lnsl -lxml2 -lz -lm -lxml2 -lz -lm 1>&5/usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.so when searching for -lmysqlclient/usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.a when searching for -lmysqlclient
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
configure: failed program was:
#line 58897 "configure"
#include "confdefs.h"
対策
libディレクトリにライブラリを探しにいってるようだが、自分のマシンは64bitマシンなので、configureオプションを修正する必要がある。以下を付加してlib64の方を探すようにすてあげると良い。
--with-libdir=lib64
参考
ちなみにmy.cnfはUNIX系、Windows系で動作し、my.iniはWindows系のみで動作する。
エラー10
pcre関連でエラーが出る。
checking for PCRE headers location... configure: error: Could not find pcre.h in /usr
対策
pcreのインストールだ。
yum install "pcre*"
エラー11
BZip2関連でエラーが出る。
checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution
対策
bzip2-libsとbzip2-develのインストールだ。
yum install "bzip*"
エラー12
curl関連でエラーが出る。
checking if we should use cURL for url streams... no
checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution - easy.h should be in <curl-dir>/include/curl/
対策
curlとcurl-develのインストールだ。
yum install "curl"
yum install "curl-devel"
エラー13
unixODBC関連でエラーが出る。
checking for unixODBC support... configure: error: ODBC header file '/usr/include/sqlext.h' not found!
対策
unixODBCとunixODBC-develのインストールだ。
yum install "unixODBC*"
エラー14
なぜかconfigureオプションにmysql関連を付加したらmakeで以下のようなエラーが出るようになった。
/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status
make: *** [libphp5.la] Error 1
対策
以下の作業で対処できる。
wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
tar xvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
cd libltdl
./configure --enable-ltdl-install
make
make install
make clean
参考
エラー15
BZip2系でエラーが出る。
configure: error: Please reinstall the BZip2 distribution
対策
開発用ライブラリのインストールだ。
yum install bzip2-devel
エラー15
libXpm関連でエラーがでる。
対策
yum install libXpm-devel
■make
いよいよmakeできる。機械語に変換(コンパイル)する時間がかかる作業だ。
エラー1
どうやらメモリを使いきってしまうようだ。
gcc: Internal error: Terminated (program cc1)
Please submit a full bug report.
See <URL:http://bugzilla.redhat.com/bugzilla> for instructions.
make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1
virtual memory exhausted: Cannot allocate memory
make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1
対策
httpdを停止してみる。当然、Webサーバが停止するので、サーバの用途により真似できない。但し。メモリを大量消費するのはmakeの間でも一部分に過ぎないようだ。
試行錯誤
shellが利用できるメモリを制限したら、もっと初期の段階でエラーになった。
ulimit -v 131072
virtual memory exhausted: Cannot allocate memory
make: *** [ext/date/lib/parse_date.lo] Error 1
/usr/bin/ld: /usr/local/lib/libcrypto.a(x86_64cpuid.o): relocation R_X86_64_PC32 against`OPENSSL_cpuid_setup' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
make: *** [libphp5.la] Error 1
参考
■make test
エラー1
MySQL関連のテストで大量にエラーが出た。
=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Timeout again inside register_shutdown_function [tests/lang/045.phpt]
Bug #48555 (ImageFTBBox() differs from previous versions for texts with new lines) [ext/gd/tests/bug48555.phpt]
Bug #16069 (ICONV transliteration failure) [ext/iconv/tests/bug16069.phpt]
mysql connect [ext/mysql/tests/001.phpt]
mysql_connect() [ext/mysql/tests/mysql_connect.phpt]
mysql_[p]connect() - max_links/max_persistent [ext/mysql/tests/mysql_max_links.phpt]
mysql_[p]connect() - safe_mode [ext/mysql/tests/mysql_sql_safe_mode.phpt]
mysqli_connect() [ext/mysqli/tests/mysqli_connect.phpt]
new mysqli() [ext/mysqli/tests/mysqli_connect_oo.phpt]
new mysqli() [ext/mysqli/tests/mysqli_connect_oo_defaults.phpt]
mysqli_poll() & references [ext/mysqli/tests/mysqli_poll_reference.phpt]
Bug #41125 (PDO mysql + quote() + prepare() can result in seg fault) [ext/pdo_mysql/tests/bug41125.phpt] (warn: ing: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) in /home/admin/php-5.3.0/ext/pdo/tests/pdo_test.inc on line 36)
Bug #44327 (PDORow::queryString property & numeric offsets / Crash) [ext/pdo_mysql/tests/bug44327.phpt] (warn: ing: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) in /home/admin/php-5.3.0/ext/pdo/tests/pdo_test.inc on line 36)
対策
試行錯誤中
MySQL が UNIX socket をどこに生成しているかを確認
mysqladmin -p version
Connection Localhost via UNIX socket
UNIX socket /var/lib/mysql/mysql.sock
MySQLクライアントのバージョンを確認してみる
mysql -V
5.0.45だ。古すぎるなんてことはなさそうだ。
参考
■make install
特に大きな問題はなかった。
■インストール後
エラー1
httpdを再起動するために以下のコマンドを入力すると、エラーが出てしまうようになった。
/etc/init.d/httpd restart
[warn] module php5_module is already loaded, skipping
対策
以下のコマンドでhttpd.confファイルを編集する。
vi /etc/httpd/conf/httpd.conf
#LoadModule php5_module /usr/lib64/httpd/modules/libphp5.so
コメントアウトで対応。
参考
エラー2
date系の関数で軒並みエラーが出るようになった。
対策
vi /etc/php.ini
date.timezone = Asia/Tokyo
date.timezoneがコメントアウトされているので;を消し、値を書き加え対応。
エラー3
mysqlへの接続関数でエラーが出るようになった。
OK packet 6 bytes shorter than expected
原因
新しい mysqlnd ライブラリは古い16バイトのパスワードをサポートしていない。
対策1
configureオプションを修正してmysqlndの使用をしないようにする。
--with-mysql=/usr/lib64/mysql/mysql_config --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
以下のようにすると良い。
--with-mysql=/usr/lib64/mysql/mysql_config --with-mysqli=/usr/lib64/mysql/mysql_config --with-pdo-mysql=/usr/lib64/mysql/mysql_config
対策2
新しく登録するユーザのパスワードを41バイトになるようにし、既にMySQLのuserテーブルに入っているパスワードを41バイトに修正する。
vi /etc/my.cnf
以下の行をコメントアウトすると41バイトのパスワードでユーザが作られるようになる。
#old_passwords=1
参考