  PostgreSQL + Apache + Zend ġϱ

   suni00@kernel.pe.kr
  v0.3, 2000 2 16

  DB PostgreSQL ϸ Apache  PHP Zend  
  ϴ   Ѵ.
  ______________________________________________________________________

  

  1. ġϱ 
  2. PostgreSQL ġϱ
     2.1 postgres  
     2.2  ϱ
     2.3 Ϲ ġ
     2.4 ġ ۾
     2.5 postmaster  ٿ
     2.6   

  3. Apache + PHP ġϱ
  4. ġ ׽Ʈ ϱ
     4.1 Ϲ ڿ DB ֱ
     4.2 DB  ̺ 
     4.3 PHP α׷ ϱ
     4.4 Ű ϱ

  ______________________________________________________________________

  1.  ġϱ 

  o  ġȯ RedHat 6.0 ̻  ϰڴ.

  o  ġ    .

  o  PostgreSQL : 6.5.3

  o  Apache     : 1.3.11

  o  PHP      : Zend beta 3

  o   ϴ   Ʈ Ѵ.

  o  <http://www.postgresql.org>

  o  <http://www.apache.org>

  o  <http://www.php.net>

  2.  PostgreSQL ġϱ

  2.1.  postgres  

  o  postgres  ׷ . ⺻ RedHat Ű
     useradd  ׷    ش.

             # useradd postgres
             # passwd postgres

  2.2.   ϱ

  o  ó ġϴ  '2.3 Ϲ ġ' Ѿ.  
     postgres  ۾Ѵ.

             $ pg_dumpall -z > db.out

  2.3.  Ϲ ġ

  1.  ϱ postmaster  δ.

             # ps -aux | grep postmaster
             # kill PID ( ã pid ȣ)

  2. PostgreSQL ҽ /usr/local 濡 Ǭ.

  3. Ǯ postgresql-6.5.3̶ 丮 µ ̸ pgsql
     ٲش.  ( pgsql 丮  ϸ ̸
     ٲش.)

             # mv postgresql-6.5.3 pgsql      (̸ pgsql ٲ۴)

             # chown -R postgres.postgres pgsql (user group ٲ۴)

             # cd /usr/local/pgsql/src
             # vi Makefile.custom              (Pentitum pro ̻󿡼 ȭ
               CFLAG+= -m486                     Ѵ)

             # ./configure --with-mb=EUC_KR    (ѱ  )

             # cd /usr/local/pgsql/doc
             # make install                    ( , HTML  ġ)

             # cd /usr/local/pgsql/src
             # make all                        ()

  4. ̸ .

             # su postgres                     (postgres  ۾ϱ)
             $ make install                    (ġ)

  2.4.  ġ ۾

  1. ̺귯 ߰

             # vi /etc/ld.so.conf
               /usr/local/pgsql/lib
             # /sbin/ldconfig

  2. ȯ溯 ߰

       ȯ溯 ϱ  .bash_profile  ߰Ѵ.
     (DB   ȯ溯  - postgres  Ų.)

             PATH=$PATH:/usr/local/pgsql/bin
             MANPATH=$MANPATH:/usr/local/pgsql/man
             PGLIB=/usr/local/pgsql/lib
             PGDATA=/usr/local/pgsql/data
             export PATH MANPATH PGLIB PGDATA

  3. ȯ  

       ؼ ȯ溯 Ų.
             $ source .bash_profile

  4. ͺ̽ ʱȭ ϱ

     postgres ۾ؾѴ.
             $ initdb -e EUC_KR

  2.5.  postmaster  ٿ

  o  postgres  ٿ Ѵ.

             $ postmaster -i -S -D /usr/local/pgsql/data

  2.6.    

  o    db.out ϱ    postgres 
     ۾Ѵ.

          $ psql -e template1 < db.out

  3.  Apache + PHP ġϱ

  1. ȯ漳 

     ġ PHP /usr/local 丮 Ǯ ġ ҽ 丮
     /usr/local/apache_1.3.11̸ PHP ҽ 丮 /usr/local/php-4.0b3̴.
      root  ۾Ѵ.

             # cd /usr/local/apache_1.3.11     (ġ ҽ 丮 ̵)

             # ./configure --prefix=/etc/httpd (   δ
                                                 /etc/httpd ̴)

             # cd /usr/local/php-4.0b3         (php ҽ 丮 ̵)

             # ./configure --with-apache=/usr/local/apache_1.3.11
                           --with-pgsql=/usr/local/pgsql
                           --enable-track-vars
                         (ġ postgres ε ٿ ̾ Ѵ)
             # make
             # make install                    (php ġ)

             # cp php.ini-dist /usr/local/lib/php.ini (php ɼǵ)

             # cd /usr/local/apache_1.3.11     (ġ 丮 ̵)
             # ./configure --prefix=/etc/httpd
                           --activate-module=src/modules/php4/libphp4.a
                     (php  ԽŴ,  ٷ ̾ Ѵ)
             # make
             # make install                    (ġ ġ)

  2. ġ 

     ġ ġ ȯ漳  /etc/httpd/conf/httpd.conf  
       Ǿִ Ȯϰ ּ Ǯش.

             AddType application/x-httpd-php .php
             AddType application/x-httpd-php-source .phps

  4.  ġ ׽Ʈ ϱ

  ݺ Ű ̿ PHP + PostgreSQL  ī͸ 
  ġ  Ǿ Ȯ .    suni00
  ϰڴ.

  4.1.  Ϲ ڿ DB ֱ

  o  postgres  Ϲ ڿ DB  ־ DB  
     ִ.

             $ su - postgres                   (ڸ postgres ٲ۴)
             $ createuser suni00               ( ְ  ´)

  DB    ־ Ѵ.

  4.2.  DB  ̺ 

  o  postgres   Ϲݻڰ   DB ̺
     Ѵ.

             $ su - suni00                     (Ϲݰ ڷ ٲ۴)
             $ createdb test                   (test DB )
             $ psql test                       (test DB )

             test=> create table counter ( count int );  (table )
             test=> insert into counter values ( 0 );    (0 Է)
             test=> \q                                   (DB )

  4.3.  PHP α׷ ϱ

  o     count.php  .

     <?
             $connect=pg_connect("dbname=test user=suni00");
             $result=pg_exec($connect,"select * from counter");

             $count_num = pg_result($result,0,"count");

             if (!$counted) {
                     $count_num++;
                     pg_exec($connect,"update counter set count=$count_num");
             }

             echo $count_num;
     ?>

      о reload   ϳ īƮ
  ϴ°   ִ.

  4.4.  Ű ϱ

  o  տ  īʹ reload Ҷ ϹǷ ׸ Ȯ 
      ִ. ׷   Ű ̿Ͽ ణ̳ ŷ
      ְ غ.  Ű  ±׺ ־ ϱ  < html
     >  ±׺ ٿ   ־ش.

             <? if (!$counted) { setcookie("counted",1,time()+3600); } ?>

     ϸ 3600(1ð) $counted  1 
  ش. ׷Ƿ ѹ  1ð ڿ ؾ īʹ
  Ѵ.

