CentOS5.5 64bit版 へ Apache2 と PHP5 をインストールするには、次のようにします。
あらかじめ必要なものをインストールしておきます。
$ cat install-httpd-php-pre.sh
#!/bin/sh
yum -y install flex
yum -y install libtool libtool-libs
yum -y install libxml2-devel libxml2
yum -y install libjpeg libjpeg-devel
yum -y install libpng-devel libpng
yum -y install freetype freetype-devel
yum -y install mysql-devel
yum -y install libmcrypt
yum -y install libmcrypt-devel
#!/bin/sh
yum -y install flex
yum -y install libtool libtool-libs
yum -y install libxml2-devel libxml2
yum -y install libjpeg libjpeg-devel
yum -y install libpng-devel libpng
yum -y install freetype freetype-devel
yum -y install mysql-devel
yum -y install libmcrypt
yum -y install libmcrypt-devel
Apacheのインストールは次の通りです。
$ cat install-httpd.sh
#!/bin/sh
cd /usr/local/src/
#wget http://ftp.riken.jp/net/apache/httpd/httpd-2.2.16.tar.gz
#wget http://jp.php.net/distributions/php-5.3.2.tar.gz
tar xzf httpd-2.2.16.tar.gz
cd /usr/local/src/httpd-2.2.16
./configure --prefix=/usr/local/apache2 --enable-module=so
make
make install | tee > install.log
#!/bin/sh
cd /usr/local/src/
#wget http://ftp.riken.jp/net/apache/httpd/httpd-2.2.16.tar.gz
#wget http://jp.php.net/distributions/php-5.3.2.tar.gz
tar xzf httpd-2.2.16.tar.gz
cd /usr/local/src/httpd-2.2.16
./configure --prefix=/usr/local/apache2 --enable-module=so
make
make install | tee > install.log
PHPのインストールは次の通り。LDFLAGS=-L/usr/lib64/mysql をつけたり、/usr/lib64 を指定したりするのがポイントになります。(これで、うまくいかないときは、 --with-libdir=lib64 をつけてみるとよいでしょう。)
$ cat install-php.sh
#!/bin/sh
cd /usr/local/src
tar xlf php-5.3.2.tar.bz2
cd /usr/local/src/php-5.3.2
LDFLAGS=-L/usr/lib64/mysql ./configure --prefix=/usr/local/php-5.3.2 \
--with-apxs2=/usr/local/apache2/bin/apxs \
--enable-mbstring --enable-mbregex \
--enable-sockets --with-mhash \
--with-openssl=/usr \
--with-mysql \
--with-pdo-mysql \
--with-mcrypt \
--enable-zend-multibyte --disable-cgi --enable-inline-optimization \
--enable-sigchild --enable-exif --enable-ftp \
--with-gd --with-zlib-dir=/usr/lib64 \
--with-jpeg-dir=/usr/lib64 --with-png-dir=/usr/lib64 \
--with-freetype-dir=/usr/lib64
make
make install 2>&1 | tee ../php-5.3.2.make-install.log
cp /usr/local/src/php-5.3.2/php.ini-production /usr/local/php-5.3.2/lib/php.ini
#!/bin/sh
cd /usr/local/src
tar xlf php-5.3.2.tar.bz2
cd /usr/local/src/php-5.3.2
LDFLAGS=-L/usr/lib64/mysql ./configure --prefix=/usr/local/php-5.3.2 \
--with-apxs2=/usr/local/apache2/bin/apxs \
--enable-mbstring --enable-mbregex \
--enable-sockets --with-mhash \
--with-openssl=/usr \
--with-mysql \
--with-pdo-mysql \
--with-mcrypt \
--enable-zend-multibyte --disable-cgi --enable-inline-optimization \
--enable-sigchild --enable-exif --enable-ftp \
--with-gd --with-zlib-dir=/usr/lib64 \
--with-jpeg-dir=/usr/lib64 --with-png-dir=/usr/lib64 \
--with-freetype-dir=/usr/lib64
make
make install 2>&1 | tee ../php-5.3.2.make-install.log
cp /usr/local/src/php-5.3.2/php.ini-production /usr/local/php-5.3.2/lib/php.ini
最後にphp.iniを編集しています。変更分だけ書いておきます。
# php.ini
extension_dir = “/usr/local/php-5.3.2/ext”
include_path = “.:/usr/local/php-5.3.2/includes”
mbstring.language = Japanese
mbstring.internal_encoding = UTF-8
mbstring.http_output = UTF-8
extension_dir = “/usr/local/php-5.3.2/ext”
include_path = “.:/usr/local/php-5.3.2/includes”
mbstring.language = Japanese
mbstring.internal_encoding = UTF-8
mbstring.http_output = UTF-8
apacheの設定ファイルでは、Listenでポート番号を指定して、user, group を適切な(apacheとか、wwwとか)ものを指定しました。
関連リンク:
関連書籍: