FAT47の底辺インフラ議事録

学んだことのメモ帳です

CentOS5.6にApache2.2.20とPHP5.3.8をソースコードからインストール

cd /home/work

wget http://www.meisei-u.ac.jp/mirror/apache/dist//httpd/httpd-2.2.20.tar.gz
wget http://jp2.php.net/get/php-5.3.8.tar.gz/from/jp.php.net/mirror
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-devel-5.5.15-1.linux2.6.x86_64.rpm/from/http://ftp.jaist.ac.jp/pub/mysql/
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-client-5.5.15-1.linux2.6.x86_64.rpm/from/http://ftp.jaist.ac.jp/pub/mysql/
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-shared-5.5.15-1.linux2.6.x86_64.rpm/from/http://ftp.iij.ad.jp/pub/db/mysql/

tar zxvf httpd-2.2.20.tar.gz

cd httpd-2.2.20
./configure --enable-so --enable-rewrite --disable-actions --disable-asis --disable-cgi --disable-env --disable-imap --disable-include --enable-cache --enable-disk-cache --enable-mem-cache

make
make install


#httpdグループとユーザを作成
groupadd -g 803 httpd
useradd -u 803 -g 803 httpd

vi /usr/local/apache2/conf/httpd.conf
ServerNameの#をはずして名前をつける

#httpd起動スクリプト

#!/bin/sh
# chkconfig: - 85 15
# description: Apache HTTP Server.
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/httpd ]; then
        . /etc/sysconfig/httpd
fi

apachectl=/usr/local/apache2/bin/apachectl
httpd=/usr/local/apache2/bin/httpd
pid=/var/run/httpd.pid
prog=httpd
RETVAL=0

start() {
        echo -n $"Starting $prog: "
        daemon $httpd $OPTIONS
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
        return $RETVAL
}
stop() {
        echo -n $"Stopping $prog: "
        killproc $httpd
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd $pid
}
reload() {
        echo -n $"Reloading $prog: "
        killproc $httpd -HUP
        RETVAL=$?
        echo
}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status $httpd
        RETVAL=$?
        ;;
  restart)
        stop
        start
        ;;
  condrestart)
        if [ -f $pid ] ; then
                stop
                start
        fi
        ;;
  reload)
        reload
        ;;
  graceful|help|configtest|fullstatus)
        $apachectl $@
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $prog {start|stop|restart|condrestart|reload|status"
		echo $"|fullstatus|graceful|help|configtest}"
        exit 1
esac

exit $RETVAL
chmod 755 /etc/init.d/httpd
chkconfig --add httpd
chkconfig httpd on

#PHPインストール
#先にこれらを導入しておく
rpm -ivh MySQL-devel-5.5.15-1.linux2.6.x86_64.rpm
rpm -ivh MySQL-client-5.5.15-1.linux2.6.x86_64.rpm
rpm -ivh MySQL-shared-5.5.15-1.linux2.6.x86_64.rpm 

cd /home/work
tar zxvf php-5.3.8.tar.gz
cd php-5.3.8
./configure --with-libdir=lib64 --with-apxs2=/usr/local/apache2/bin/apxs --enable-mbstring --enable-mbregex --with-pdo-mysql --with-mysql --with-gd --with-zlib=/usr --with-jpeg-dir=/usr --with-png-dir=/usr --with-freetype-dir=/usr/local --with-curl --enable-sockets --enable-bcmath
make
make install

#php.iniの複製
cp /home/src/php-5.3.8/php.ini-development /usr/local/lib/php.ini

#httpd.confに以下の内容を追記
AddType application/x-httpd-php .php

httpd再起動