  PostgreSQL + Apache + PHP Zend ġϱ

   suni00@kernel.pe.kr
  v, 2000 2 3

  DB PostgreSQL ϸ Apache  PHP Zend  
  ϴ   ϰ Ѵ.  HOW-TO ⺸ 
  ġ  ǰڴ.
  ______________________________________________________________________

  

  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.  ġϱ 

  ġȯ RedHat 6.0 ̻  ϰڴ.

  ġ    .

  o  PostgreSQL : 6.5.3

  o  Apache     : 1.3.11

  o  PHP      : Zend beta 3

   ϴ   Ʈ Ѵ.

  <http://www.postgresql.org>

  <http://www.apache.org>

  <http://www.php.net>

  2.  PostgreSQL ġϱ

  2.1.  postgres  

  postgres  ׷ . ⺻ RedHat Ű
  useradd  ׷    ش.

          # useradd postgres

  2.2.   ϱ

  ó ġϴ  2.3  ϱ Ѿ.

   postgres  ۾Ѵ.

          $ pg_dumpall -z > db.out

  2.3.  Ϲ ġ

   ϱ postmaster  δ.

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

  PostgreSQL ҽ /usr/local 濡 Ǭ.  Ǯ 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                        ()

  ̸ .

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

  2.4.  ġ ۾

          # vi /etc/ld.so.conf              (̺귯 ã ߰)
            /usr/local/pgsql/lib
          # /sbin/ldconfig

    ȯ溯 ϱ  .bash_profile 
  ߰Ѵ.

          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

  ȯ      Ѵ.

          $ source .bash_profile            (ȯ溯 - )

  ͺ̽ ʱȭ ϱ ( postgres ۾ؾѴ )

          $ initdb -e EUC_KR

  2.5.  postmaster  ٿ

  postgres  ٿ Ѵ.

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

  2.6.    

    db.out ϱ    postgres 
  ۾Ѵ.

          $ psql -e template1 < db.out

  3.  Apache + PHP ġϱ

  ġ 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
                      (ġ php ҽε ٿ ̾ Ѵ)
          # make
          # make install                    (php ġ)

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

  ġ ġ ȯ漳  /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 ֱ

  postgres  Ϲ ڿ DB  ־ DB  
  ִ.

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

  DB    ־ Ѵ.

  4.2.  DB  ̺ 

  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 α׷ ϱ

     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.  Ű ϱ

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

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

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

  ---------------------------------------------------------------------

  

  http://kernel.pe.kr/~suni00

