Lapp環境
(Apahe,PostgreSQL,PHP)
をソースからインストール
    - CentOS環境 -


             山内公之(やまうちきみゆき)@kimiyukiy
                           2013.02.23(sat)
makeに必要なツールのイン
ストール
# yum groupinstall “Development Tools”
# yum install libxml2-devel readline-devel
# yum install vim
#yum install wget
#yum install system-config-firewall
Apacheインストール(1)

ApacheのmakeにAPR、APR-Util、PCREが必須のため、
まずこれらをインストールしたのちApacheをインストール
◎APRのインストール
$ wget http://ftp.tsukuba.wide.ad.jp/software/apache//apr/apr-1.4.6.tar.bz2
$ tar jxfv apr-1.4.6.tar.bz2
$ cd apr-1.4.6/
$ ./configure --prefix=/usr/local/apr
$ make
# make install
Apacheインストール(2)
◎APR-Utilのインストール
$ wget http://ftp.kddilabs.jp/infosystems/apache//apr/apr-util-1.5.1.tar.bz2
$ tar jxfv apr-util-1.5.1.tar.bz2
$ cd apr-util-1.5.1/
$ ./configure --prefix=/usr/local/apr-util --with-
apr=/usr/local/apr
$ make
# make install
Apacheインストール(3)
◎PCREのインストール
$ wget http://sourceforge.net/projects/pcre/files/pcre/8.32/pcre-8.32.tar.bz2
$ tar jxvf pcre-8.32.tar.bz2
$ cd pcre-8.32/
$ ./configure --prefix=/usr/local/pcre
$ make
# make install
Apacheインストール(4)
◎Apaheのインストール
$ wget http://ftp.riken.jp/net/apache//httpd/httpd-2.4.3.tar.bz2
$ tar jxfv httpd-2.4.3.tar.bz2
$ cd httpd-2.4.3/
$ ./configure --prefix=/usr/local/apache --enable-so
--enable-rewrite --with-apr=/usr/local/apr --with-apr-
util=/usr/local/apr-util --with-pcre=/usr/local/pcre
$ make
# make install
Apacheインストール(5)
◎Apache実行用のユーザ、グループ作成
# groupadd apache && useradd -g apache apache
◎Apache設定ファイルの変更
# cd /usr/local/apache/conf/
# cp httpd.conf httpd.conf.bak
# vi httpd.conf
(155行目) daemon => apache
(156行目) daemon => apache
(186行目)#ServerName www.example.com:80
           => ServerName localhost
Apacheインストール(6)

◎Apaheの動作確認
# system-config-firewall
(このツールを使って、80番ポートを開ける)
# /usr/local/apache/bin/apachectl start
=> ブラウザでアクセスし、「It works!」と表示さ
れること
Apacheインストール(7)

◎自動起動の設定
# cp build/rpm/httpd.init /etc/init.d/httpd
# vi /etc/init.d/httpd
(60行目)httpd=${HTTPD-/usr/local/apache/bin/httpd}
(61行目)pidfile=${PIDFILE-/usr/local/apache/logs/${prog}.pid}
(62行目)lockfile=${LOCKFILE-/usr/local/apache/logs/${prog}}
(67行目)CONFFILE=/usr/local/apache/conf/httpd.conf
# chkconfig --add httpd
# chkconfig httpd on
# chkconfig --list httpd
=> 自動起動が正常に行わることを確認
Apacheインストール(8)

◎起動
# serivce http start
◎停止
# service httpd stop
◎ステータス確認
# service httpd status
PostgreSQLのインストー
ル(1)
# adduser postgres
# passwd postgres
# mkdir /usr/local/pgsql
# chown postgres.postgres /usr/local/pgsql
# su – postgres
$ wget http://ftp.postgresql.org/pub/source/v9.2.3/postgresql-9.2.3.tar.bz2
$ tar jxvf postgresql-9.2.3.tar.bz2
$ cd postgresql-9.2.3/
$ ./configure
$ make
$make install
PostgreSQLのインストー
ル(2)
$ cd ~
$ vi .bashrc
(以下を追記し、保存)
POSTGRES_HOME=/usr/local/pgsql
export PATH="$PATH":/usr/local/pgsql/bin
export PGLIB=$POSTGRES_HOME/lib
export PGDATA=$POSTGRES_HOME/data
export MANPATH="$MANPATH":$POSTGRES_HOME/man

$ source .bashrc
PostgreSQLのインストー
ル(3)
$ initdb --no-locale --encoding=UNICODE
$ vi /usr/local/pgsql/data/postgresql.conf
(300行目)logging_collector = on
(309行目)log_filename = '%a.log'
(上記のように変更し保存)
$ pg_ctl start
$ psql -l
  (これで、データベースの一覧が表示されたらOK)
$pg_ctl stop
(で、停止)
PostgreSQLのインストー
ル(4)
◎自動起動の設定
# cp /home/postgres/postgresql-
9.2.3/contrib/start-scripts/linux
/etc/init.d/postgres
# chmod 755 /etc/init.d/postgres
# chkconfig postgres on
=> 自動起動が正常に行わることを確認
PostgreSQLのインストー
ル(5)
◎起動
# serivce postgres start
◎停止
# service postgres stop
◎ステータス確認
# service postgres status
PHPのインストール(1)
(別途、ソースファイルをダウンロード)
$ tar jxvf php-5.4.11.tar.bz2
$ cd php-5.4.11/
$ ./configure --with-
apxs2=/usr/local/apache/bin/apxs --enable-
mbstring --enable-mbregex --with-pgsql --with-zlib
$ make
# make install
# cp php.ini-development /usr/local/lib/php.ini
PHPのインストール(2)
# vi /usr/local/apache/conf/mime.types
(以下のを追加し、保存)
application/x-httpd-php php
# vi /usr/local/apache/htdocs/test.php
(以下の内容を記述し、保存)
<?php phpinfo() ?>
# /usr/local/apache/bin/apachectl restart
=> ブラウザで、サーバのtest.phpにアクセスし、
PHPの画面が表示されればOK

Lapp環境をソースからインストールする(centos)