2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CentOS6系にPHP4をインストール

Posted at

環境

$ cat /etc/redhat-release 
CentOS release 6.9 (Final)
$ uname -sr
Linux 2.6.32-696.el6.x86_64

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

# yum -y install flex libcurl-devel libxml2-devel libjpeg-turbo-devel libpng-devel freetype-devel

ソースのダウンロード

# mkdir /root/src
# cd /root/src
# wget https://museum.php.net/php4/php-4.4.9.tar.gz
# tar zxvf php-4.4.9.tar.gz 
# cd php-4.4.9

OpenSSLのバージョンが合わなくてmakeでこける

php4のソースの openssl.c を openssl1.0.0に合わせる
参照:【php】CentOS6(Scientific Linux 6)にて php4がコンパイルできない(別解)

# mv ext/openssl/openssl.c ext/openssl/openssl.c.org
# wget https://www.softel.co.jp/blogs/tech/wordpress/wp-content/uploads/2012/10/openssl.c -O ext/openssl/openssl.c

libjpeg, libpngのconfigure修正

参照:64bitカーネルのLinuxにPHP4を入れる場合。

# cp -p configure configure.org
# vi configure
# diff -uBb configure.org configure                                                                                                                                                    
--- configure.org       2008-08-06 17:36:41.000000000 +0900                                                                                                                                                 
+++ configure   2018-08-08 10:55:44.327900515 +0900                                                                                                                                                         
@@ -21232,8 +21232,8 @@                                                                                                                                                                                     
   withval="$with_jpeg_dir"                                                                                                                                                                                 

     for i in $withval /usr/local /usr; do                                                                                                                                                                  
-      if test -f "$i/lib/libjpeg.$SHLIB_SUFFIX_NAME" -o -f "$i/lib/libjpeg.a"; then                                                                                                                        
-        CPDF_JPEG_DIR=$i                                                                                                                                                                                   
+      if test -f "/usr/lib64/libjpeg.$SHLIB_SUFFIX_NAME" -o -f "/usr/lib64/libjpeg.a"; then                                                                                                                
+        CPDF_JPEG_DIR=/usr/lib64                                                                                                                                                                           
         break;                                                                                                                                                                                             
       fi                                                                                                                                                                                                   
     done
@@ -33554,7 +33554,7 @@
   if test "$PHP_JPEG_DIR" != "no"; then

     for i in $PHP_JPEG_DIR /usr/local /usr; do
-      test -f $i/lib/libjpeg.$SHLIB_SUFFIX_NAME -o -f $i/lib/libjpeg.a && GD_JPEG_DIR=$i && break
+      test -f /usr/lib64/libjpeg.$SHLIB_SUFFIX_NAME -o -f /usr/lib64/libjpeg.a && GD_JPEG_DIR=/usr/lib64 && break                                                                                         
     done

     if test -z "$GD_JPEG_DIR"; then
@@ -33829,7 +33829,7 @@
   if test "$PHP_PNG_DIR" != "no"; then

     for i in $PHP_PNG_DIR /usr/local /usr; do
-      test -f $i/lib/libpng.$SHLIB_SUFFIX_NAME -o -f $i/lib/libpng.a && GD_PNG_DIR=$i && break
+      test -f /usr/lib64/libpng.$SHLIB_SUFFIX_NAME -o -f /usr/lib64/libpng.a && GD_PNG_DIR=/usr/lib64 && break                                                                                            
     done

     if test -z "$GD_PNG_DIR"; then
@@ -33840,7 +33840,7 @@
       { echo "configure: error: PNG support requires ZLIB. Use --with-zlib-dir=<DIR>" 1>&2; exit 1; }
     fi

-    if test ! -f $GD_PNG_DIR/include/png.h; then
+    if test ! -f /usr/include/png.h; then
       { echo "configure: error: png.h not found." 1>&2; exit 1; }
     fi

@@ -35350,7 +35350,7 @@
   if test "$PHP_JPEG_DIR" != "no"; then

     for i in $PHP_JPEG_DIR /usr/local /usr; do
-      test -f $i/lib/libjpeg.$SHLIB_SUFFIX_NAME -o -f $i/lib/libjpeg.a && GD_JPEG_DIR=$i && break
+      test -f /usr/lib64/libjpeg.$SHLIB_SUFFIX_NAME -o -f /usr/lib64/libjpeg.a && GD_JPEG_DIR=/usr/lib64 && break
     done

     if test -z "$GD_JPEG_DIR"; then

ビルドとインストール

# ./configure \
--with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d \
--with-apxs2=/usr/sbin/apxs \
--with-pgsql=/usr/lib64/pgsql \
--enable-mbstring \
--enable-mbstr-enc-trans \
--without-mysql \
--with-gd \
--with-dom \
--with-zlib-dir=/usr \
--enable-gd-native-ttf \
--with-freetype-dir=/usr \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-iconv \
--with-curl \
--enable-versioning \
--enable-dbx \
--with-emoji \
--with-authcheck \
--enable-ftp \
--with-openssl \
&& make && make install

バージョン確認

# php -v
PHP 4.4.9 (cli) (built: Aug  14 2018 00:00:00)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?