블로그 이미지
좋은느낌/원철
이것저것 필요한 것을 모아보렵니다.. 방문해 주셔서 감사합니다..

calendar

1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

Notice

    '개발'에 해당되는 글 91

    1. 2009.06.11 아파치 톰켓 연동하기
    2. 2009.06.11 httpd.conf 설정값 설명
    3. 2009.06.11 httpd_2.0.55 with mod_ssl
    4. 2009.06.10 Apache+SSL+Tomcat 설치
    5. 2009.05.27 AJAX 예제들
    6. 2009.05.21 리눅스 환경에서 Oracle JDBC설정
    7. 2009.05.19 Listener
    8. 2009.05.18 jdk 설치
    9. 2009.05.13 like 대신 instr
    10. 2009.05.13 [ORACLE]SGA
    2009. 6. 11. 17:44 개발/Linux 계열

    아파치 톰켓 연동하기

     OS =  linux redhat 9.0
    아파치 버젼 : 1.3.31
    Tomcat 버젼 : 5.0.28
    Connectors  : jakarta-tomcat-connectors-jk2-2.0.4-src

    1. 아파치 설치
     가. tar -xvzf apache_1.3.31.tar.gz
     나. ./configure --prefix=/usr/local/apache --enable-rule=SHARED_CORE --enable-shared=max --enable-module=so
     다. make
     라. mkke install
     설치 완료

    2. connector 만들기(mod_jk2.so)
     가. tar xvzf jakarta-tomcat-connectors-jk2-src-current.tar.gz
     나. apr-0.9.4.tar.gz , apr-util-0.9.4.tar.gz 파일이 필요함
        참고 http://mirror.apache.or.kr/apr/apr-0.9.4.tar.gz
             http://mirror.apache.or.kr/apr/apr-util-0.9.4.tar.gz
        위 2개 파일을 받아 압축을 푼다.
     다. cd jakarta-tomcat-connectors-jk2-2.0.4-src/jk/native2/
     라. ./buildconf.sh 
     마. ./configure --with-apxs=/usr/local/apache/bin/apxs --with-apr=/경로/apr-0.9.4 --with-apr-util=/경로/apr-util-0.9.4
     바. make 
     사. cd jakarta-tomcat-connectors-jk2-2.0.4-src/jk/build/jk2/apache13 로 이동
     아. cp mod_jk2.so /usr/local/apache/libexec/mod_jk2.so
     자. chmod 755 /usr/local/apache/libexec/mod_jk2.so
     차. cp jakarta-tomcat-connectors-jk2-2.0.4-src/jk/conf/workers2.properties /usr/local/apache/conf 에 복사

    3. apahce 환경 설정
     가. /usr/local/apahce/conf/httpd.conf 수정
         # Apache Tomcat5 Connector
           LoadModule jk2_module         libexec/mod_jk2.so
           AddModule mod_jk2.c
           추가
     나. User nobody --> xxx 사용자로
         Group nobody --> xxx 그룹 사용자로 이걸 수정하는 이유는 기본적으로 apache는 nobody 유저로 나중에권한문제가
          생길수 있기때문에 변경한다. 보통 403 에러가 나타남.

     다. DocumentRoot "/usr/local/apache/htdocs" 는 jsp 파일이 놓일 위치다 변경가능 (tomcat의 context 위치와 같게 설정한다.)
         같이 변경
     
     라. 
     DirectoryIndex index.html index.jsp -> index.jsp 추가한다. 
     

     마. Options Indexes FollowSymLinks MultiViews 이부분을 주석으로 막는다.( http://www.xxx.com/ 이런경우 주석으로 처리하면 
           파일리스트 목록이  보이는 현상을 제거한다.

    4. /usr/local/apache/conf/workers2.properties 수정
       
     [logger]
     level=DEBUG

     [config:]
     file=${serverRoot}/conf/workers2.properties
     debug=0
     debugEnv=0

     [uriMap:]
     info=Maps the requests. Options: debug
     debug=0

     # Alternate file logger
     #[logger.file:0]
     #level=DEBUG
     #file=${serverRoot}/logs/jk2.log

     [shm:]
     info=Scoreboard. Required for reconfiguration and status with multiprocess servers
     file=${serverRoot}/logs/jk2.shm
     size=1000000
     debug=0
     disabled=0

     [workerEnv:]
     info=Global server options
     timing=1
     debug=0
     # Default Native Logger (apache2 or win32 )
     # can be overriden to a file logger, useful
     # when tracing win32 related issues
     #logger=logger.file:0

     [lb:lb]
     info=Default load balancer.
     debug=0

     [lb:lb_1]
     info=A second load balancer.
     debug=0
     [channel.socket:localhost:8009]

     info=Ajp13 forwarding over socket
     debug=0
     tomcatId=localhost:8009

     [channel.socket:localhost:8019]
     info=A second tomcat instance.
     debug=0
     tomcatId=localhost:8019
     lb_factor=1
     group=lb
     group=lb_1
     disabled=0

     [channel.un:/opt/33/work/jk2.socket]
     info=A second channel connecting to localhost:8019 via unix socket
     tomcatId=localhost:8019
     lb_factor=1
     debug=0

     [channel.jni:jni]
     info=The jni channel, used if tomcat is started inprocess

     [status:]
     info=Status worker, displays runtime informations

     [vm:]
     info=Parameters used to load a JVM in the server process
     #JVM=C:\jdk\jre\bin\hotspot\jvm.dll
     classpath=${TOMCAT_HOME}/bin/tomcat-jni.jar
     classpath=${TOMCAT_HOME}/server/lib/commons-logging.jar
     OPT=-Dtomcat.home=${TOMCAT_HOME}
     OPT=-Dcatalina.home=${TOMCAT_HOME}
     OPT=-Xmx128M
     #OPT=-Djava.compiler=NONE
     disabled=1

     [worker.jni:onStartup]
     info=Command to be executed by the VM on startup. This one will start tomcat.
     class=org/apache/jk/apr/TomcatStarter
        #ARG=start
     # For Tomcat 5 use the 'stard' for startup argument
        ARG=stard
     disabled=1
     stdout=${serverRoot}/logs/stdout.log
     stderr=${serverRoot}/logs/stderr.log

     [worker.jni:onShutdown]
     info=Command to be executed by the VM on shutdown. This one will stop tomcat.
     class=org/apache/jk/apr/TomcatStarter
     ARG=stop
     disabled=1

     [uri:/jkstatus/*]
     info=Display status information and checks the config file for changes.
     group=status:

     [uri:127.0.0.1:8003]
     info=Example virtual host. Make sure myVirtualHost is in /etc/hosts to test it
     alias=myVirtualHost:8003

     [uri:127.0.0.1:8003/ex]
     info=Example webapp in the virtual host. It'll go to lb_1 ( i.e. localhost:8019 )
     context=/ex
     group=lb_1


     [ajp13:localhost:8009]
     channel=channel.socket:localhost:8009

     [uri:/*.jsp]
     info=All jsp page  mapping


     [uri:localhost/*.jsp]
     info=All jsp page  mapping
     worker=ajp13:localhost:8009

     [uri:/servlet/*]
     info=All Servlet  page  mapping

     [uri:/*]

     위와 같이 설정했음.

    5. Tomcat5 설치
     가. tar -xvzf jakarta-tomcat-5.0.28.tar.gz  
        나. conf/server.xml 수정
       
          위 부분 주석처리

       
                   port="8009" minProcessors="5" maxProcessors="75"
                   enableLookups="true" redirectPort="8443" acceptCount="10"
                   debug="0" connectionTimeout="20000" useURIValidationHack="false"
                   protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler" />
          위 부분 추가

        
                  위 부분 주석 해제

       
        위 부분 주석처리

          appBase="webapps" 를 -- >"/" 수정했음.
          unpackWARs="true" autoDeploy="true"
          xmlValidation="false" xmlNamespaceAware="false">
        
         
         위 부분 추가
     
     6. conf/jk2.properties  수정
        # Set the desired handler list
      handler.list=apr,request
     # handler.list=apr,request,channelJni
     #
     # Override the default port for the socketChannel
      channelSocket.port=8019
     # Default:
     # channelUnix.file=${jkHome}/work/jk2.socket
     # Just to check if the the config  is working
      shm.file=${jkHome}/work/jk2.shm

     # In order to enable jni use any channelJni directive
     # channelJni.disabled = 0
     # And one of the following directives:

     # apr.jniModeSo=/opt/apache2/modules/mod_jk2.so

     # If set to inprocess the mod_jk2 will Register natives itself
     # This will enable the starting of the Tomcat from mod_jk2
      apr.jniModeSo=inprocess

      위 와같이 설정했음.

    posted by 좋은느낌/원철
    2009. 6. 11. 17:43 개발/Linux 계열

     

      httpd.conf 파일은 크게 세부분으로 나누어져 있다.

        Section 1: Global Environment  : 아파치 전체적인 영향이 미치는 설정
        Section 2: 'Main' server configuration : 주 서버에 대한 설정
        Section 3: Virtual Hosts : 가상 호스트에 대한 설정

      자, 그럼 이제부터 이 아파치웹서버의 모든 환경을 설정하는 아파치환경파일 httpd.conf파일의 설정방법에 대해서 상세히 알아보도록 하자.

     

     ### Section 1: Global Environment

      전제환경설정 파트로 Section 1에서 설정하는 것들은 아파치 웹서버에 
    전반적인 영향을 미친다.

    ServerType standalone

      서버의 구동방법으로는 standalone과 inetd방식이 있는데,  standalone 
    방식은 하나의 웹데몬(아파치서버)이 클라이언트의 접속을 모두 처리하는 
    방식으로 응답속도가 빠른 방법으로 주로 이방식을 사용한다. inetd 방식은 
    inetd라는 시스템의 /etc디렉토리 끝에 존재하는 inetd라는 슈퍼데몬이 
    클라이언트의 접속요구가 있을 때마다 웹서버를 구동하는 방식이다. 
    일반적으로 응답속도가 빠르고 효율적인 standalone으로 설정하여 사용한다.


    ServerRoot "/usr/local/apache"

      아파치서버의 홈디렉토리를 지정하며 절대경로로 지정한다. 이후로 나오는 
    대부분의 패스들은 이 경로에 대한 상대경로로 지정이 된다. 예를 들어 
    환경설정파일, 에러로그파일등의 상대경로의 기준이 되는 위치이다.


    LockFile logs/accept.lock

      아파치 컴파일시 USE_FCNTL_SERIALIZED_ACCEPT나 
    USE_FLOCK_SERIALIZED_ACCEPT으로 컴파일 했을 때 사용되는 
    LockFile의 경로지정시에 사용된다. 가급적 기본값으로 사용한다.


    PidFile logs/httpd.pid

      PidFile 설정은 ServerType을 Standalone으로 설정했을때만 유효한 
    것으로 아파치 서버의 프로세스가 생성되어 있을 때 그 프로세서ID(PID)를 
    기록하는 파일을 지정한다.  당연히 아파치서버가 재시작되거나 과부하로 
    인해 PID가 바뀌게 될 경우에는 이 파일의 PID값도 바뀌게 된다.  즉 
    다시말해서 여기서 지정된 파일(httpd.pid)에 실행되고 있는 아파치서버의 
    프로세스번호(PID)값이 기록된다고 하면 정답이다. ServerRoot를 기준으로한 
    상대경로로 지정된다.  절대경로로 지정하려면 "/"로 시작하는 절대경로를 
    적어주면 된다.

     


    ResourceConfig conf/srm.conf 
    AccessConfig conf/access.conf

      아파치 서버의 환경설정파일은 3개이au httpd.conf, srm.conf, access.conf 
    가 그것이다. 그러나 하나의 설정파일로 하는 것이 효율적이기 때문에 
    지금은 httpd.conf파일안에 3개의 파트(Section)로 나누어서 하나의 
    파일안에서 설정을 하고 있다. srm.conf와 access.conf파일의 내용은 현재 
    비어있는 상태이지만, 필요하다면 이 파일 내에도 설정을 할 수 있다. 
    아파치 서버가 실행이 될 때는 httpd.conf, srm.conf, access.conf 순으로 
    언제나 이 3개의 파일을 모두 읽고 난뒤에 실행이 되기 때문이다. 만약 이 
    두 개의 파일을 서버가 무시하도록 하려면 다음과 같이 하거나 "#"으로 붙여 
    두면 주석처리되어 무시된다.

    ResourceConfig /dev/null
    AccessConfig /dev/null


    Timeout 300

      클라이언트의 요청에 의해 서버와 연결이 되었을 때 클라이언트와 
    서버간에 아무런 메시지가 발생하지 않았을 때 오류로 처리될 시간을 
    초단위로 설정한다. 초기값은 1200이며 보통은 300초로 지정을 한다. 
    네트웍의 속도가 나쁠수록 수치값은 높게 설정하는 것이 좋다.

    KeepAlive On

      접속한 채로 특별한 요청없이 지속적인 연결을 허용할 것인지를 설정한다. 
    허용하지 않으려면 off

    MaxKeepAliveRequests 100

      클라이언트가 접속된 시간동안 아파치서버에 요청할 수 있는 최대의 
    개수를 지정한다. 0을 지정하면 제한없음을 의미하며, 서버의 성능향상을 
    위하여 가능한 높은 값이 좋다.
     
    KeepAliveTimeout 15

      아파치 서버는 같은 접속상태의 클라이언트에서 여기서 지정한 초만큼의 
    요청이 없었을 때 접속을 끊게 된다.

    MinSpareServers 5
    MaxSpareServers 10

      아파치 웹서버는 성능향상과 빠른 응답속도를 위해 유휴서버(현재 
    서비스대기 중인 프로세스)를 만들게 되는데 이 유휴서버의 개수는 시스템의 
    상황에 따라 달라지게 된다. 유휴서버가 MinSpareServers의 개수(5) 보다 
    적게되면 추가로 생성을 하게 되며 MaxSpareServers의 개수(10)보다 많게 
    되면 죽이게 된다. 즉, 유휴서버의 개수를 적절히 조절하기 위한 것이라 
    생각하면 된다.


    StartServers 5  

      아파치 웹데몬이 구동될 때 자식프로세스를 몇 개로 할 것인가를 
    지정한다. 시작할 때 동시에 띄우게 될 웹데몬의 개수이다. 그러나 웹데몬이 
    구동되고 난 뒤엔 시스템의 상황(부하율등)에 따라 대부분 합리적인 
    개수만큼 동적으로 생성되었다가 죽기도 하므로 큰 의미를 가지는 것은 
    아니다.

    MaxClients 150

      아파치웹서버에 접근할 수 있는 클라이언트의 최대갯수는 이 상한값으로 
    제한한다. 여기서 지정한 개수이상의 클라이언트의 요청이 생긴다면 
    아파치는 응답하지 않고 이 요청을 무시한다.  이를 제한하는 이유는 
    시스템의 자원을 아파치 웹서버가 무한정 차지하는 것을 방지하기 위한 
    것이다.

    MaxRequestsPerChild 30

      아파치 웹서버의 자식프로세스들이 클라이언트의 요청 개수를 지정한다. 
    만약 자식프로세스가 이 값만큼의 클라이언트요청을 받았다면 이 
    자식프로세스는 자동으로 죽게된다. 이 값이 0으로 설정이 된다면 
    자식프로세스가 자동으로 죽는일은 없을 것이다. 그러나 0아닌 다른 값으로 
    설정함으로서 프로세스의 수를 적절히 조절하여 시스템의 부하조절과 
    자원낭비를 어느정도 방지 할 수 있다.

    Listen 3000
    Listen 12.34.56.78:80

      시스템의 기본값이외에 다른 IP Address와 포트에 대해서도 연결할 수 
    있도록 해 준다. 환경설정파일(httpd.conf) 맨뒤에 나오는 가상호스트(Virtual 
    Host)부분에서 설정되는 가상호스트를 설정하기 위해 필요하다.


    BindAddress *

      서버가 응답할 수 있는 IP Address를 설정하는 것이다. 하나의 시스템에 
    있는 아파치웹서버 하나로 여러 웹서버처럼 관리하는 웹호스팅서비스등에서 
    많이 이용하는 것으로 여러 IP Address를 인식할 수 있게 한다. "*"으로 
    설정이 되었다면 모든  IP Address에 대해 응답할 수 있으며, IP Address를 
    지정한다면 지정한 IP Address에 대해서만 응답할 수 있게 된다.  여러개의 
    IP Address를 ISP로부터 할당받아서 웹호스팅서비스를 하고자 한다면 
    이부분에서 지정해 주면된다. 이 설정파일의 맨 뒷부분에 나오는 
    <VirtualHost>~</VirtualHost>부분의 IP bind 가상호스트부분에서 아파치 
    웹서버가 응답할 수 있도록 하려면 여기서 IP Address를 지정해 줘야 한다.

    ExtendedStatus On

      server-status로 아파치웹서버의 상태를 상태를 모니터링 할 때 
    "자세한상태정보"기능을 제공할 것인지(On) 아닌지(Off)를 설정하는 것이다.

    ### Section 2: 'Main' server configuration

      Section 2에서 설정하는 항목들은 아파치의 주된서버가 사용할 값들을 
    지정한다. <VirtualHost>에 정의된 가상호스트들에서 지정하지 않는 것은 
    여기서 지정된 값이 기본값으로 적용된다. 또한 여기서 지정하는 값을 각 
    <VirtualHost>내에도 지정할 수 있으며 이경우엔 각<VirtualHost>내에서 
    지정한 값이 우선적용된다.

    Port 80

      아파치웹서버의 기본포트를 지정한다. 특별하게 사용하는 것이 아니라면 
    80번으로 해둬야 한다. 사용가능한 포트는 0 ~ 65535이며 1024이하의 
    포트번호는 시스템에서 특별하게 예약되어 있으므로 80번 이외의 다른 
    포트를 사용하려면 1024이상의 포트번호를 지정해서 사용해야 할 것이다. 
    특별한 지정이 없다면 <VirtualHost>에 정의된 각각의 가상호스트들의 
    기본포트가 된다. 만약 <VirtualHost> 내에서 Port가 지정이 된다면 그 
    포트번호가 우선한다.

    (특별히 PORT를 따로 지정해 줄 필요가 있을 때는 따로 지정해 주며, 
    이때는 웹서버로 접근할 때 반드시 따로지정한 PORT번호로 접근해야 한다. 
    예를들어 Port 1234로 지정했다면, 접근시 : http://www.domain.co.kr:1234 
    로 접속해야한다. 단, 80번은 default이므로 Port번호를 입력하지 않아도 
    도메인만으로 그냥 접근할 수 있다. 예: http://www.domain.co.kr )

    User nobody 
    Group nobody

      아파치 웹데몬이 요청을 받았을 때 여기서 지정한 user와 group으로 
    응답을 하게된다. 이 설정은 ServerType이 Standalone방식이며, 아파치의 
    실행이 root권한으로 실행이 되었을 때 유효한 것이다. 많은 
    웹서버관리자들이 nobody로 설정을 해 두고 있으며, 만약 시스템에 nobody 
    user가 없다면 새로생성(useradd)을 해야 할 것이다. 단, root로 설정하는 
    것은 절대로 있어서는 안되며 nobody이외의 다른 시스템사용자 id로 지정을 
    한다면 정말 신중히 모든면(시스템 보안 및 자원사용등)에서 깊게 고려를 
    해봐야 한다.

    ServerAdmin webmaster@www.domain.co.kr

      여기서 지정하는 email address는 웹문서 로딩에러등의 문제에서 
    클라이언트측으로 보내질 메일주소값이다. 대부분 
    웹서버관리자의 email address로 설정을 한다.

    ServerName new.host.name

      클라이언트에게 보여주는 호스트이름을 지정한다. www를 쓰지않는 
    호스트에서 www를 쓰는 것처럼 보이게 할 수 있다. 예를 들어 
    bbs.manualand.co.kr을 www.manualand.co.kr로 지정해서 쓸 수 있다. 
    이곳에 IP Address를 적게 되면 클라이언트에는 Ip Address를 보여준다.

    DocumentRoot "/usr/local/apache/htdocs"

      아파치 웹서버의 웹문서가 있는 경로를 지정한다. 예를 들어 
    "http://www.manualand.co.kr/index.html"의 초기 문서라면 이 초기문서의 
    절대 경로는 여기서 지정된 "/usr/local/apache/htdocs/index.html"이 된다. 
    경로의 맨 마지막에 "/"를 추가해서는 안된다. Alias를 사용하여 다른 위치를 
    지정할 수도 있다.

    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>      
                    

    <Directory>에서 지정되는 값에 대한 옵션은 다음과 같은 의미를 가지고 
    있다.
            None : 일단 모든허용을 하지 않는다.
            All : 모든허용을 한다.
            Indexes :
            Includes :
            FollowSymlinks :
            ExeCGI :
            MultiViews :


    UserDir public_html

      하나의 아파치 웹서버에서 여러 사용자의 홈페이지를 별도로 만들어 
    관리할 때 필요한 개별 가입자의 홈페이지 디렉토리이름이다. 예를 들어 
    sspark이란 계정가입자의홈페이지는 "http://manualand.co.kr/~sspark"라는 
    홈페이지를 가지고 있을 때 sspark의 계정에서 "public_html"이란 
    디렉토리가 홈디렉토리가 되어 이 디렉토리에 있는 초기문서 index.html을 
    불러서 보여주게 된다.

    <Directory /home/*/public_html>
        AllowOverride FileInfo AuthConfig Limit
        Options MultiViews Indexes SymLinksIfOwnerMatch 
    IncludesNoExec
        <Limit GET POST OPTIONS PROPFIND>
            Order allow,deny
            Allow from all
        </Limit>
        <Limit PUT DELETE PATCH PROPPATCH MKCOL COPY 
    MOVE LOCK UNLOCK>
            Order deny,allow
            Deny from all
        </Limit>
    </Directory>

    계정사용자의 홈페이지(public_html)의 접근에 대한 옵션을 지정한 것이다.


    DirectoryIndex index.html

      디렉토리만을 지정했을 경우에 그 디렉토리에서 찾게될 문서의 순서를 
    지정해 준다. 즉, 디렉토리 이름만을 지정하더라도 여기서 지정한 
    index.html을 찾아서 웹브라우즈에 보여준다. 여러개의 파일을 지정할 수 
    있으며, 이런 경우에는 순서대로 찾아서 보여준다. 예를 들어 
    "DirectoryIndex index.html index.htm"로 지정했다면 먼저 "index.html"을 
    찾아서 있다면 이 파일을 로딩하고, "index.html"이 없다면 "index.htm"을 
    찾아서 로딩해 준다.

    AccessFileName .htaccess

      디렉토리별로 접근제어할 정보(ID, Password)를 담고 있는 파일을 
    지정한다. 디렉토리별로 인증을 거쳐서 접근할 수 있는 설정을 하기위한 
    것이다. 예를 든다면 어떤 홈페이지의 전부나 혹은 일부에로 접근하려고 할 
    때 ID, Password를 묻는 창이 뜨면서 맞게 입력한 경우에만 접근허용하는 
    것이다.  보안상의 이유로 이 파일의 이름을 다른 이름으로 바꾸로 싶다면 
    ".htaccess"대신에 다름이름을 적어주면 된다.

    <Files ~ "^\.ht">
        Order allow,deny
        Deny from all
    </Files>

      바로위에서 설정한 파일(".htaccess")의 내용을 볼 수 없게 할 때 사용하는 
    옵션이다. 보안상의 이유로 이 옵션은 설정해 두는 것이 좋다. 만약 이 
    옵션을 주석처리해 둔다면 ".htaccess"파일에 대한 보안은 누구도 장담할 수 
    없을 것이다.


    UseCanonicalName On

     

    TypesConfig conf/mime.types

    웹서버의 mime type을 지정한 파일을 지정한다. mime.types파일은 서버에 
    의해 리턴될 수 있는 파일명과 mime형식을 기술해 놓은 파일이다.

    DefaultType text/plain

    mime.types 파일에 정의 되어있지 않은 파일형식에 대한 요청을 받았을 때 
    알 수 없는 문서타입에 대하여 사용할 기본적인 mime 타입을 정해둔다.


    HostnameLookups Off

      웹서버의 로그(access_log)를 지정하는 Format에서 "DNS Lookup"으로 
    지정하였을 때, domain으로 남길 것인가, IP Address로 남길 것인가를 
    지정한다. Default로 Off는 IP Address로 남기는 것이며, Domain으로 변경할 
    필요가 없으므로 on으로 설정한 것보다는 속도가 조금빠르다.on으로 하게 
    되면 IP address를 IP Domain으로 변환해야 하므로 속도가 조금 느릴 수 
    있다.

    ErrorLog logs/error_log

      아파치 웹서버의 에러로그 기록파일을 지정한다.  참고할 사항은 맨 
    마지막에 설정하는 <VirtualHost>부분에서 각서버에 대한 에러파일을 
    지정해 두지 않으면 그에 대한 에러로그도 여기에 기록되며, 지정해 두게 
    되면 그에 해당하는 로그는 이 파일에 기록되지 않는다.

    LogLevel warn

      바로위에서 설정한 에러로그 파일에 얼마나 자세하게 적을 것인지를 
    결정한다. 다음에 해당하는 순서대로 중요도가 정해진다. " debug → info → 
    notice → warn → error → crit → alert! → emerg "

    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" 
    \"%{User-Agent}i\"" combind
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    LogFormat "%{Referer}i -> %U" referer
    LogFormat "%{User-agent}i" agent

      바로 아래에서 사용할 CustomLog에서 사용할 몇가지 로그형식의 별명을 
    정한 곳이다.
    웹서버의 관리자나 서버관리자는 이 부분을 특히 유심히 봐둬야 한다. 
    웹서버의 로그를 어떤 식으로 남길 것인가를 결정하는 Format을 지정하는 
    곳이다. 원하는 정보를 지정해서 볼 수 있으므로, 관리자에게 필요한 
    Format으로 설정해야 하며, 또한 접속통계를 내기에 적당한 Format으로 
    설정해 둬야 한다.

    CustomLog logs/access_log common

      위에서 정한 로그형식(여기선 common)대로 로그를 남기게 된다. 
    맨마지막에서 지정하는 <VirtualHost>부분에서도 아파치 1.3.9버전 부터는 
    CustomLog를 가상호스트별로 지정할수 있도록 CustomLog를 제공한다. 
    <VirtualHost>에서 CustomLog를 지정하지 않으면 여기서 지정한 형식대로 
    로그를 남기게 되며 <VirtualHost>부분에서 CustomLog를 지정했을 
    경우에는 여기서 지정한 로그형식은 무시된다.

    #CustomLog logs/referer_log referer
    #CustomLog logs/agent_log agent
    #CustomLog logs/access_log combined

      위에서 지정한 4가지의 로그형식(combind, common, referer, agent)중에서 
    원하는 부분의 #(주석행)을 제거하면 지정된다.

    ServerSignature On

      서버가 생성하는 문서(error documents, FTP directory listings, 
    mod_status and mod_info output etc., but not CGI generated documents)의 
    trailing footer line의 설정을 가능하게 한다.

    Alias /icons/ "/usr/local/apache/icons/"

      필요한 만큼의 디렉토리 별칭을 만들어 쓸 수 있다. 사용하는 형식은 
    다음과 같다. 
    Alias fakename(가상이름) realname(진짜이름)

    ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"

      ScriptAlias는 서버스크립트를 포함한다. ScriptAlias는 실제디렉토리 안에 
    들어있는 문서를 서버에 의해 응용프로그램으로 취급되어 실행되는 것을 
    제외하고는 근본적으로 Aliases와 같다.

     
    IndexOptions FancyIndexing

      IndexOPtions는 디렉토리목록을 표시할 때 사용할 옵션을 지정한다. 
    Standard는 표준적인 디렉토리를 나타내며, FancyIndexing은 좀더 예쁜 
    디렉토리목록을 표시해 준다.

     

      아래에서 지정하는 AddIcon으로 시작하는 설정은 바로위에서 설정한 
    디렉토리인덱싱 옵션을 FancyIndexing으로 한 경우에 해당하며 디렉토리 
    목록을 표시할 때 각 파일 확장자에 따라서 어떤 아이콘을 선택하여 보여줄 
    것인지를 지정한다.

    AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
    AddIconByType (TXT,/icons/text.gif) text/*
    AddIconByType (IMG,/icons/image2.gif) image/*
    AddIconByType (SND,/icons/sound2.gif) audio/*
    AddIconByType (VID,/icons/movie.gif) video/*

    AddIcon /icons/binary.gif .bin .exe
    AddIcon /icons/binhex.gif .hqx
    AddIcon /icons/tar.gif .tar
    AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
    AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
    AddIcon /icons/a.gif .ps .ai .eps
    AddIcon /icons/layout.gif .html .shtml .htm .pdf
    AddIcon /icons/text.gif .txt
    AddIcon /icons/c.gif .c
    AddIcon /icons/p.gif .pl .py
    AddIcon /icons/f.gif .for
    AddIcon /icons/dvi.gif .dvi
    AddIcon /icons/uuencoded.gif .uu
    AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
    AddIcon /icons/tex.gif .tex
    AddIcon /icons/bomb.gif core

    AddIcon /icons/back.gif ..
    AddIcon /icons/hand.right.gif README
    AddIcon /icons/folder.gif ^^DIRECTORY^^
    AddIcon /icons/blank.gif ^^BLANKICON^^


    DefaultIcon /icons/unknown.gif

      여기서 지정한 확장가가 아닌 경우에 여기서 지정한 기본아이콘으로 
    보여준다.

    AddDescription "GZIP compressed document" .gz
    AddDescription "tar archive" .tar
    AddDescription "GZIP compressed tar archive" .tgz

      AddDescription은 서버가 생성한 인덱스의 파일 뒤에 간단한 설명을 
    표시할 때 사용한다. 이 설정은 IndexOptions가 FancyIndexing으로 
    설정되었을때만 표시되며, 설정형식은 다음과 같다.
    형식 : AddDescription "표시할 설명" 파일확장자

    ReadmeName README

      ReadmeName은 디렉토리목록표시 뒤에 붙여서 보여줄 README파일의 
    이름을 지정한다.(일종의 꼬릿말)

    HeaderName HEADER

      HeaderName은 디렉토리목록표시 앞에 붙여질 파일의 이름을 지정한다. 
    (일종의 머릿말)

    IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t

      디렉토리목록을 인덱싱할 때 제외할 파일명을 지정한다. 즉 디렉토리 
    목록에 포함하지 않을 파일을 지정한다. 쉘스타일의 와일드카드(*, ?)가 
    허용된다.

    AddEncoding x-compress Z
    AddEncoding x-gzip gz tgz

      AddEncoding은 특정브라우즈(Mosaic/X 2.1+)에서 받고있는 중에 정보에 
    대한 압축해제를 할 수 있도록한다. 단 모든 웹브라우즈에서 이 기능을 
    제공하는 것은 아니다.

    AddLanguage en .en
    AddLanguage fr .fr
    AddLanguage de .de
    AddLanguage da .da
    AddLanguage el .el
    AddLanguage it .it

      AddLanguage는 문서의 언어를 지정하게 한다.

    LanguagePriority en fr de

      언어의 우선순위를 내림차순으로 지정한다.

    AddType application/x-httpd-php3 .php3
    AddType application/x-httpd-php3-source .phps
    AddType application/x-tar .tgz

      AddType은 mime.types의 실제 편집없이도 mime을 설정할 수 있다.

    AddHandler cgi-script .cgi

      AddHandler는 파일확장자를 처리기(Handler)에 매핑(연결)시켜주게 된다.

    AddType text/html .shtml
    AddHandler server-parsed  .shtml

      SSI(Server Side Include)문서를 인식하게 하기위한 설정이다. SSI코드가 
    들어가 있는 문서는 확장자가 *.shtml이다. 시스템의 날짜와 카운터등 
    CGI프로그램을 하지 않아도 HTML문서에서 단 몇줄로 CGI의 효과를 낼 수 
    있는 SSI기능을 인식하게끔 하는 설정이다. "7장. 아파치와 SSI"편에서 자세히 
    설명되어 있다.


    #Format: Action media/type /cgi-script/location
    #Format: Action handler-name /cgi-script/location

      Action은 매칭되는 파일이 호출될때마다 스크립트를 실행시킬 수 있도록 
    미디어 타입을 정의한다.

    MetaDir .web

      MetaDir은 아파치가 찾을 메타정보파일들의 디렉토리이름을 지정한다. 이 
    파일들은 문서를 전송할 때 포함되는 HTTP 헤더정보가 포함되어 있다.

    MetaSuffix .meta

      MetaSuffix는 메타정보를 포함하고 있는 접미어의 이름을 지정한다.


    에러발생시 응답을 정의할 수 있는 방법을 3가지 나타내고 있다.

        1) 일반적인 텍스트

    ErrorDocument 500 "The server made a boo boo.

        2) 지역적인 방향전환

    ErrorDocument 404 /missing.html
    ErrorDocument 404 /cgi-bin/missing_handler.pl

        3) 외부 방향전환

    ErrorDocument 402 
    http://some.other_server.com/subscription_info.html


      다음의 BrowserMatch는 keepalives기능을 쓰지못하게 하며 HTTP 
    헤드방식을 설정한다.

    BrowserMatch "Mozilla/2" nokeepalive

      이 설정은 Netscape 2.x 또는 이를 따르는 브라우즈에 대하여 KeepAlive 
    기능을 쓰지 못하게한다.

    BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 
    force-response-1.0

      이 설정은 잘못구현된 HTTP/1.1과 301또는 302반응에 대하여 
    KeepAlive를 적절히 제공하지 못하는 마이크로소프트 인터넷익스플로러 
    4.0b2d에 관한 것이다.

    BrowserMatch "RealPlayer 4\.0" force-response-1.0
    BrowserMatch "Java/1\.0" force-response-1.0
    BrowserMatch "JDK/1\.0" force-response-1.0

      위의 3가지 설정은 기본적인 1.1반응도 처리하지 못하며 HTTP/1.0 스팩을 
    제한하고 있는 브라우즈에 대하여 HTTP/1.1반응을 하지 못하게 한 것이다.

    <Location /server-status>
        SetHandler server-status
        Order deny,allow
        Deny from all
        Allow from www.manualand.co.kr
    </Location>

      서버의 상태를 점검할 수 있게하는 설정이다. 이는 
    "http://www.manualand.co.kr/server-status"와 같은 형식으로 서버의 상태를 
    점검할 수 있다. "6장. 아파치서버 모니터링"편에서 자세히 설명되어 있다. 
    여기서 지정한 "SetHandler server-status"의 설정으로 인해 서버 
    모니터링을 할 수 있는 것이다.

    <Location /server-info>
        SetHandler server-info
        Order deny,allow
        Deny from all
        Allow from www.manualand.co.kr
    </Location>

      이설정을 위해서는 mod_info.c가 적재되어야 하며, 이는 
    "http://www.manualand.co.kr/server-info"와 같은 방식으로 서버의 정보를 
    볼 수 있다. 위에서 설정한 server-status와 함께 실행중인 웹서버의 
    상태점검을 위한 것이다.

    <Location /cgi-bin/phf*>
        Deny from all
        ErrorDocument 403 http://phf.apache.org/phf_abuse_log.cgi
    </Location>

      아파치 1.1이전 버전의 오래된 버그에 대한 악용이 있을시에는 지정한곳 
    (http://phf.apache.org/phf_abuse_log.cgi) 으로 방향을 전환시킨다.


    <IfModule mod_proxy.c>
    ProxyRequests On

      아파치 웹서버를 Proxy서버로 사용할 때 on을 해줘야 한다. 즉   
    프락시서버 지시자로서 프락시서버를 on 시킨다.

    <Directory proxy:*>
        Order deny,allow
        Deny from all
        Allow from .your_domain.com
    </Directory>

    ProxyVia On

      HTTP/1.1 "Via:"헤드처리를 활성화시킬 것인지 비활성화 시킬것인지를 
    지정한다. Off, On, Full, Block중 하나가 올 수 있으며 Full은 서버버전을 
    포함하며, Block은 나가는 모든 것에 대해 Via:헤더를 제거한다.

    CacheRoot "/usr/local/apache/proxy"
    CacheSize 5
    CacheGcInterval 4
    CacheMaxExpire 24
    CacheLastModifiedFactor 0.1
    CacheDefaultExpire 1
    NoCache a_domain.com another_domain.edu joes.garage_sale.com

      이 설정은 캐시기능을 활성화 하기 위한 것이다.

    ### Section 3: 가상호스트 설정

      여러분의 시스템에서 여러개의 도메인이나 호스트네임을 설정하여 
    관리하고자 한다면 <VirtualHost>부분을 설정해 줘야 한다. 가상호스트에 
    대한 정보는 http://www.apache.org/docs/vhosts/를 참조해 보면 좀더 
    자세한 정보를 얻을 수 있다.  '-S'옵션을 사용함으로써 가상호스트의 설정에 
    대한 점검을 할 수 있다.  name-based 가상호스트를 사용하길 원한다면 
    적어도 한 개이상의 IP Address를 정의할 필요가 있다. "4-2절의 내용"과 
    "10장.웹호스팅 서비스를 위한 가상호스트"편에서 자세히 설명되어 있다.

    NameVirtualHost 12.34.56.78:80
    NameVirtualHost 12.34.56.78

    <VirtualHost www.manualand.co.kr>
        ServerAdmin webmaster@manualand.co.kr
        DocumentRoot /home/sspark/public_html
        ServerName www.manualand.co.kr
        ErrorLog /home/sspark/public_html/aw/error_log
        CustomLog /home/sspark/public_html/aw/access_log common
    </VirtualHost>

            ServerAdmin은 해당서버의 관리자 전자우편이며, 
            DocumemtRoot는 해당서버의 홈디렉토리이며, 
            ServerName은 해당서버의 도메인이며, 
            ErrorLog는 해당서버의 에러파일 위치이며
            CustomLog는 로그파일위치와 포맷을 지정한 것이다.

    <VirtualHost _default_:*>
    </VirtualHost>

      Default 가상호스트 설정으로 위에서 설정되지 않은 다른 모든 호스트에 
    대해서 응답을 하고자 할 경우설정해 준다

    posted by 좋은느낌/원철
    2009. 6. 11. 17:42 개발/Linux 계열

    httpd_2.0.55 with mod_ssl PHP 

    2006/05/18 11:21

    복사 http://blog.naver.com/jjy8476/70004318523

    ./apache_install 옵션 추가

    --enable-ssl \
    --with-ssl=/usr/share/ssl/lib (rpm으로 설치된경우)

     

     

     

    ./apache_install

    make

    make install

     

    아파치 설정파일을 수정한다. 
    #: cd /usr/local/apache 
    #: vi conf/httpd.conf

     

    Change the following line: 
     Group #-1 => Group nobody

     

    Default 시작페이지 설정을 수정해 줍니다
    Documentroot "/var/www/html"

    DirectoryIndex index.php index.php3  index.html index.htm

    Section 2의 단락에서 아래 내용을 추가합니다.
    ................................
    # And for PHP 4.x, use:
    AddType application/x-httpd-php .php .php3 .inc .ph .htm
    AddType application/x-httpd-php-source .phps
    .................................

    환경설정 수정후 저장을 합니다.
    $ /usr/local/apache/bin/httpd -t        엔터를 두드리고  다음과 같은 메시지만 있으면 아파치 환경이 잘 설정되었습니다.
    Syntax OK  

     

    아파치 서버를 시작한다.
    #: /usr/local/apache/bin/apachectl start

     

     

    SSL Key and Certificate 만든다. 
    (.key 생성)

    openssl genrsa -des3 1024 > /usr/local/apache/conf/localhost.key

     

    (.csr 생성)

    openssl req -new -key /usr/local/apache/conf/localhost.key > \ 
    /usr/local/apache/conf/localhost.csr

     

    (.crt 생성)

    openssl req -x509 -days 3650 -key \ 
    /usr/local/apache/conf/localhost.key \ 
    -in /usr/local/apache/conf/localhost.csr > \ 
    /usr/local/apache/conf/localhost.crt

     

    vi /usr/local/apache/conf/ssl.conf

    Find the following lines in the ssl.conf file: 
    DocumentRoot "/usr/local/apache/htdocs" 
    ServerName new.host.name:443 
    SSLCertificateFile /usr/local/apache/conf/ssl.crt/server.crt 
    SSLCertificateKeyFile /usr/local/apache/conf/ssl.key/server.key

     

    Change the respective lines so that they are as follows: 
    DocumentRoot "/usr/local/apache/htdocs-secure" 
    ServerName localhost:443 
    SSLCertificateFile /usr/local/apache/conf/localhost.crt 
    SSLCertificateKeyFile /usr/local/apache/conf/localhost.key


    #: mkdir /usr/local/apache2/htdocs-secure

     

    Create a simple home page (e.g. Home, Secure Home) 
    #: vi /usr/local/apache/htdocs-secure/index.html 
    Save index.html and exit vi 
    #: chmod a+rx /usr/local/apache/htdocs-secure/ 
    #: chmod a+r /usr/local/apache/htdocs-secure/index.html

     

    Remove the encryption from the RSA private key 
    #: cd /usr/local/apache/conf 
    #: cp localhost.key server.key.org 
    #: /usr/local/ssl/bin/openssl rsa -in server.key.org -out localhost.key 
    #: chmod 400 localhost.key

     

    Test the Apache https server. 
    #: /usr/local/apache/bin/apachectl stop 
    #: /usr/local/apache/bin/apachectl startssl

     

     

     

     

    php install

    ./php_install

    [출처] httpd_2.0.55 with mod_ssl|작성자 지우맘

    posted by 좋은느낌/원철
    2009. 6. 10. 20:24 개발/Linux 계열

    아파치 웹서버를 운영하는데 있어서 기본이 HTML 서비스를 기본으로 하고 있다. PHP 기반에서 보통 APM을 설치한다. 그외에 자바 서버를 운영하기 위하여 Tomcat을 설치해서 서블릿과 jsp를 활용할 수 있다. 
    그리고 데이터 전송의 보안을 위하여 mod_ssl 기반의 https://를 활용해 보자 




    목차 

    1.PGCC 설치 
    2.MYSQL 설치 
    3.JDK 설치 
    4.Tomcat 설치 
    5.Imap 설치 
    6.GD 설치 
    7.apache 초기 작업 
    8.openssl 설치 
    9.mm 설치 
    10.mod_ssl 설치 
    11.apache & mod_gzip 
    12.SSL 인증서 수동으로 만들기 
    13.Apache+mod_ssl 을 자동시작 하려면 
    14.DSO PHP 설치 
    15.Zend Optimizer 설치 
    16.apache & tomcat 연동 mod_webapp.so 설치 
    17.최종 연동 테스트 
    18.후기 


    _______________________________________________________________________________ 


    1.PGCC 설치 

    [바이너리 화일 다운] 

    http://www.goof.com/pcg/binaries-linux.html 

    [설치] 

    - /usr/local/pgcc 경로로 설치 후 설치되 이름을 pgcc로 변경한다. 

    # 풀면서 특정 경로에 푼다. 
    [root@vm_master PGCC]# tar zxvfp pgcc-2.95.3-linux-x86-glibc2.1.tar.gz -C / 
    ./ 
    ./usr/ 
    ./usr/local/ 
    ./usr/local/pgcc/ 
    ./usr/local/pgcc/bin/ 
    ./usr/local/pgcc/bin/gcov 
    ./usr/local/pgcc/bin/cpp 
    ./usr/local/pgcc/bin/i686-pc-linux-gnu-gcc 
    ./usr/local/pgcc/bin/protoize 
    ./usr/local/pgcc/bin/unprotoize 
    - 중략 - 
    ./usr/local/pgcc/man/ 
    ./usr/local/pgcc/man/man1/ 
    ./usr/local/pgcc/man/man1/gcc.1 
    ./usr/local/pgcc/man/man1/cccp.1 

    # 이름 구별을 위하여 pgcc, pcpp로 변경한다. 
    [root@vm_master bin]# cd /usr/local/pgcc/bin/ 
    [root@vm_master bin]# ls 
    cpp gcc gcov i686-pc-linux-gnu-gcc protoize unprotoize 
    [root@vm_master bin]# mv gcc pgcc 
    [root@vm_master bin]# mv cpp pcpp 
    [root@vm_master bin]# ls 
    gcov i686-pc-linux-gnu-gcc pcpp pgcc protoize unprotoize 


    _______________________________________________________________________________ 

    2.MYSQL 설치 

    [소스 화일 다운] 

    http://www.mysql.com/downloads/mysql.html 

    [최적화 옵션] 

    http://www.mysql.com/doc/C/o/Compile_and_link_options.html 
    http://www.mysql.com/doc/c/o/configure_options.html 
    http://www.mysql.com/doc/M/y/MySQL_binaries.html 
    http://www.mysql.com/doc/W/h/Which_version.html 

    http://tunelinux.pe.kr/mysql/manual/10.txt 
    http://database.sarang.net/database/mysql/tuning/optimize_mysql.html 
    http://www.phpleader.co.kr/study/studycontent.php?study2_seq=47 

    [설치] 

    # 다음과 같은 내용의 스크립트를 작성해서 실행 시킨다. 

    [root@vm_master mysql-3.23.47]# vi pgcc_mysql.sh 
    #!/bin/bash 

    # 옵션 설정 시작 - 펜티엄 최적화 
    CC="/usr/local/pgcc/bin/pgcc" 
    CFLAGS="-O6 -mpentiumpro -mstack-align-double -fomit-frame-pointer -march=pentiumpro" 
    CXX="/usr/local/pgcc/bin/pgcc" 
    CXXFLAGS="-O6 -mpentiumpro -march=pentiumpro -mstack-align-double -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti" 

    # 초기화 설정 - 디렉토리지정, 클라이언트,서버 정적 라이브러화" 
    # - 문자셑지정, 디버깅하지 않음, 트랜잭션사용" 
    ./configure --prefix=/usr/local/mysql --with-client-ldflags=-all-static 
    --with-mysqld-ldflags=-all-static --with-charset=euc_kr --without-debug 
    --enable-assembler --with-innodb 

    #PGCC를 mysql 세팅을 한다. 
    [root@vm_master mysql-3.23.47]# chmod +x pgcc_mysql.sh 
    [root@vm_master mysql-3.23.47]# ./pgcc_mysql.sh 
    - 생략 - 
    # 컴파일 
    make 

    # 설치 
    make install 

    # 데이터 베이스 설치 
    [root@vm_master support-files]#/usr/local/mysql/bin/mysql_install_db 

    # 설치 후에 시스템에 맞추어서 시스템 최적화 옵션 화일을 /etc/ 로 복사한다. 
    # 다음은 128메모리를 사용하는 경우이다. 
    [root@vm_master mysql-3.23.47]# cd support-files 
    [root@vm_master support-files]# cp my_medium.cnf /etc/my.cnf 
    # 512 M 이면 
    [root@vm_master support-files]# cp my-large.cnf /etc/my.cnf 
    # 1G이면 
    [root@vm_master support-files]# cp my-huge.cnf /etc/my.cnf 


    # mysql 계정 및 그룹 생성 및 퍼미션 권한을 변경해준다. 
    [root@vm_master support-files]# groupadd mysql 
    [root@vm_master support-files]# useradd -g mysql mysql 
    [root@vm_master support-files]# chown -R root /usr/local/mysql 
    [root@vm_master support-files]# chown -R mysql /usr/local/mysql/var 
    [root@vm_master support-files]# chgrp -R mysql /usr/local/mysql 


    # 라이브러들을 등록해준다. 
    [root@vm_master lib]# echo /usr/local/mysql/lib/mysql >> /etc/ld.so.conf 
    [root@vm_master lib]# ldconfig 

    #redhat인 경우 데몬 스크립트를 복사를 해준후 링크를 걸어 준다. 
    [root@vm_master support-files]# cd /etc/rc.d/init.d/ 
    [root@vm_master init.d]# vi mysqld 
    #!/bin/sh 

    PATH=/sbin:/usr/sbin:/bin:/usr/bin 
    basedir=/usr/local/mysql 
    bindir=/usr/local/mysql/bin 
    datadir=/usr/local/mysql/var 
    pid_file=/usr/local/mysql/var/mysqld.pid 
    log_file=/usr/local/mysql/var/mysqld.log 
    # Run mysqld as this user. 
    mysql_daemon_user=mysql 
    export PATH 

    mode=$1 

    if test -w / # determine if we should look at the root config file 
    then # or user config file 
    conf=/etc/my.cnf 
    else 
    conf=$HOME/.my.cnf # Using the users config file 
    fi 

    # The following code tries to get the variables safe_mysqld needs from the 
    # config file. This isn't perfect as this ignores groups, but it should 
    # work as the options doesn't conflict with anything else. 

    if test -f "$conf" # Extract those fields we need from config file. 
    then 
    if grep "^datadir" $conf >/dev/null 
    then 
    datadir=`grep "^datadir" $conf | cut -f 2 -d= | tr -d ' '` 
    fi 
    if grep "^user" $conf >/dev/null 
    then 
    mysql_daemon_user=`grep "^user" $conf | cut -f 2 -d= | tr -d ' ' | head -1` 
    fi 
    if grep "^pid-file" $conf >/dev/null 
    then 
    pid_file=`grep "^pid-file" $conf | cut -f 2 -d= | tr -d ' '` 
    else 
    if test -d "$datadir" 
    then 
    pid_file=$datadir/`hostname`.pid 
    fi 
    fi 
    if grep "^basedir" $conf >/dev/null 
    then 
    basedir=`grep "^basedir" $conf | cut -f 2 -d= | tr -d ' '` 
    bindir=$basedir/bin 
    fi 
    if grep "^bindir" $conf >/dev/null 
    then 
    bindir=`grep "^bindir" $conf | cut -f 2 -d= | tr -d ' '` 
    fi 
    if grep "^log[ t]*=" $conf >/dev/null 
    then 
    log_file=`grep "log[ t]*=" $conf | cut -f 2 -d= | tr -d ' '` 
    fi 
    fi 


    # Safeguard (relative paths, core dumps..) 
    cd $basedir 

    case "$mode" in 
    'start') 
    # Start daemon 

    if test -x $bindir/safe_mysqld 
    then 
    # Give extra arguments to mysqld with the my.cnf file. This script may 
    # be overwritten at next upgrade. 
    $bindir/safe_mysqld 
    --log-update=update.log -O max_connections=500 -O max_connect_error=999999999 
    --user=$mysql_daemon_user --datadir=$datadir --pid-file=$pid_file --log=$log_file & 
    else 
    echo "Can't execute $bindir/safe_mysqld" 
    fi 
    ;; 

    'stop') 
    # Stop daemon. We use a signal here to avoid having to know the 
    # root password. 
    if test -f "$pid_file" 
    then 
    mysqld_pid=`cat $pid_file` 
    echo "Killing mysqld with pid $mysqld_pid" 
    kill $mysqld_pid 
    # mysqld should remove the pid_file when it exits, so wait for it. 

    sleep 1 
    while [ -s $pid_file -a "$flags" != aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ] 
    do [ -z "$flags" ] && echo "Wait for mysqld to exitc" || echo ".c" 
    flags=a$flags 
    sleep 1 
    done 
    if [ -s $pid_file ] 
    then echo " gave up waiting!" 
    elif [ -n "$flags" ] 
    then echo " done" 
    fi 
    else 
    echo "No mysqld pid file found. Looked for $pid_file." 
    fi 
    ;; 

    *) 
    # usage 
    echo "usage: $0 start|stop" 
    exit 1 
    ;; 
    esac 


    [root@vm_master init.d]# chmod +x mysqld 

    # 리부팅후 자동으로 시작하세 초기화 스크립트에 링크를 걸어 준다. 
    [root@vm_master init.d]# cd /etc/rc3.d/ 
    [root@vm_master rc3.d]# ln -s ../init.d/mysqld S98mysqld 
    [root@vm_master rc3.d]# cd /etc/rc5.d/ 
    [root@vm_master rc5.d]# ln -s ../init.d/mysqld S98mysqld 

    #데이터 베이스를 시작한다. 
    [root@vm_master init.d]# ./mysqld start 
    [root@vm_master init.d]# Starting mysqld daemon with databases from 
    /usr/local/mysql/var 

    #프로세스를 확인해서 제대로 프로세스가 뜨는지 확인 한다. 
    [root@vm_master init.d]# pstree | grep mysql 
    |-safe_mysqld---mysqld---mysqld---mysqld 

    # 루트 패스워드를 넣는다. 
    [root@vm_master /bin]# mysqladmin -u root password '패스워드' 

    [[ 패스워드 분실시 ]] 

    [root@vm_master /bin]# killall mysqld 
    [root@vm_master /bin]# ./safe_mysqld --skip-grant & 
    [root@vm_master support-files]# mysql 
    mysql> UPDATE user SET Password=PASSWORD('패스워드') WHERE user='root'; 
    mysql> FLUSH PRIVILEGES; 

    _______________________________________________________________________________ 

    3.JDK 설치 


    [프로그램 다운로드] 

    http://java.sun.com/j2se/1.3/download-linux.html 

    [설치] 

    # 리눅스용 화일을 받아서 풀고 디렉토리를 옮긴다. 
    [root@vm_master AJS]# ls -al j2sdk-1_3_1_02-linux-i386.bin 
    -rw-rw-r-- 1 root root 26311391 Jan 7 2002 j2sdk-1_3_1_02-linux-i386.bin 
    [root@vm_master AJS]# chmod +x j2sdk-1_3_1_02-linux-i386.bin 
    [root@vm_master AJS]# ./j2sdk-1_3_1_02-linux-i386.bin 
    - 중 략 - 
    [root@vm_master AJS]# mv jdk1.3.1_02/ /usr/local/jdk 



    # 전체 환경에 자바와 톰켓를 사용할 수 있게 설정을 한다. 
    [root@vm_master root]# vi /etc/profile 
    #JDK & Tomcat Setting 
    export JAVA_HOME="/usr/local/jdk" 
    export CLASSPATH=".:$JAVA_HOME/lib/tools.jar:/usr/local/jakarta-tomcat/lib/servlet.jar:$JAVA_HOME/jre/lib/rt.jar" 
    export PATH="$PATH:$JAVA_HOME/bin" 

    # 새로 로긴후 java 라고 쳐서 테스트 한다. 


    [문제해결] 

    # 다음과 같은 에러는 아래의 패키지를 설치한다. 
    [root@vm_master AJS]# java 
    /usr/local/jdk/bin/i386/native_threads/java: error while loading shared libraries: 
    libstdc++-libc6.1-1.so.2: cannot open shared object file: No such file or directory 

    # CD-ROM 마운트후 다음 패키지를 설치 한다. 
    [root@vm_master AJS]# cd /mnt/cdrom/RedHat/RPMS/ 
    [root@vm_master RPMS]# ls com* 
    compat-libstdc++-6.2-2.9.0.16.i386.rpm 
    [root@vm_master RPMS]# rpm -ivh compat-libstdc++-6.2-2.9.0.16.i386.rpm 
    Preparing... ########################################### [100%] 
    1:compat-libstdc++ ########################################### [100%] 


    # Jaf & JavaMail 설치 

    [다운로드] 
    JavaBeans Activation Framework : http://java.sun.com/beans/glasgow/jaf.html 
    JavaMail : http://java.sun.com/products/javamail/index.html 

    [참고 자료] 
    http://www.javastudy.co.kr/docs/lec_java/javamail/javamail.html 

    [설치] 

    # 압축을 풀고 디렉토리 이름을 바꾼다. 

    [root@vm_master AJS]# cp jaf1_0_1.zip /usr/local/ 
    [root@vm_master AJS]# cp javamail-1_2.zip /usr/local/ 
    [root@vm_master local]# cd /usr/local/ 
    [root@vm_master local]# unzip jaf1_0_1.zip 
    [root@vm_master local]# unzip javamail-1_2.zip 
    [root@vm_master local]# mv jaf-1.0.1/ jaf/ 
    [root@vm_master local]# mv javamail-1.2/ javamail/ 

    # /etc/profile 에 다음을 추가 한다. 
    [root@vm_master root]# vi /etc/profile 
    # jaf & javamail Setting 
    export CLASSPATH="$CLASSPATH:/usr/local/javamail/mail.jar:/usr/local/jaf/activation.jar" 


    _______________________________________________________________________________ 

    4.Tomcat 설치 

    [바이너리 다운로드] 
    http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.0.1/bin/ 

    # 아파치와 연동하기 위하여 webapp_modules를 받어 놓는다. 
    http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.0.1/bin/linux/i386/ 


    [설치] 

    # 화일을 풀고 이름을 바꾼다. 
    [root@vm_master AJS]# tar zxvfp jakarta-tomcat-4.0.1.tar.gz -C /usr/local 
    [root@vm_master AJS]# cd /usr/local/ 
    [root@vm_master local]# mv jakarta-tomcat-4.0.1/ jakarta-tomcat/ 

    _______________________________________________________________________________ 

    5.Imap 설치 

    [소스 다운로드] 
    http://www.planetmirror.com/pub/imap/ 

    [설치] 

    # 패키지 확인 후 없으면 컴파일, 설치하고 필요 라이브러리를 카피한다. 
    [root@vm_master AJS]# rpm -qa | grep imap 
    [root@vm_master AJS]# tar zxvf imap.tar.Z 

    # 디렉토리를 /usr/local/imap으로 이동 시킨다. 
    [root@vm_master AJS]# mv imap-2001a/ /usr/local/imap 
    [root@vm_master AJS]# cd /usr/local/imap 
    [root@vm_master imap]# make slx 
    [root@vm_master imap]# cp ipopd/ipop[23]d /usr/sbin/ 
    [root@vm_master imap]# cp imapd/imapd /usr/sbin/ 

    # 아파치가 imap을 인식하도록 
    [root@vm_master imap]# cp ./c-client/c-client.a /usr/lib/libc-client.a 
    [root@vm_master imap]# cp ./c-client/mail.h /usr/local/include/ 
    [root@vm_master imap]# cp ./c-client/rfc822.h /usr/local/include/ 
    [root@vm_master imap]# cp ./c-client/linkage.h /usr/local/include/ 

    # imap을 서버에서 운영가능하도록 xinetd 설정 화일을 만든다. 
    [root@vm_master xinetd.d]# cat imapd 
    service imap 
    { 
    disable = no 
    socket_type = stream 
    protocol = tcp 
    wait = no 
    user = root 
    server = /usr/sbin/imapd 
    } 

    # 서비스 확인 
    [root@vm_master xinetd.d]# netstat -at 
    Active Internet connections (servers and established) 
    Proto Recv-Q Send-Q Local Address Foreign Address State 
    tcp 0 0 *:imap *:* LISTEN 

    _______________________________________________________________________________ 

    6.GD 설치 

    [소스 다운로드] 
    http://freshmeat.net/projects/gd/homepage/ 

    [설치] 

    # 화일을 풀고 컴파일을 한후 디렉토리를 통으로 옮긴다. 
    [root@vm_master AJS]# tar zxvf gd-1.8.4.tar.gz 
    [root@vm_master AJS]# cd gd-1.8.4 
    [root@vm_master gd-1.8.4]# make 
    [root@ns gd-1.8.4]# cd .. 
    [root@vm_master AJS]# mv gd-1.8.4 /usr/local/gd 

    _______________________________________________________________________________ 

    7.apache 초기 작업 

    [소스 다운로드] 
    http://www.apache.org/dist/httpd/ 

    # 아파치를 간단히 기본 설치 디렉토리를 세팅한다. 
    [root@vm_master apache_1.3.22]# tar zxvf apache_1.3.22.tar.gz 
    [root@vm_master apache_1.3.22]# cd apache_1.3.22.tar.gz 
    [root@vm_master apache_1.3.22]# ./configure --prefix=/usr/local/apache 

    _______________________________________________________________________________ 

    8.openssl 설치 

    [소스 다운로드] 
    http://www.openssl.org/source/ 

    [설치] 

    # 소스 풀고 컴파일 한다. 인스톨은 하지 않는다. 
    [root@vm_master AJS]# tar zxvf openssl-0.9.6b.tar.gz 
    [root@vm_master AJS]# cd openssl-0.9.6b/ 
    [root@vm_master openssl-0.9.6b]# ./config 
    [root@vm_master openssl-0.9.6b]# make;make install 

    _______________________________________________________________________________ 

    9.mm 설치 

    - 공유 메모리 관련 라이브러리 

    [소스 다운로드] 
    http://www.engelschall.com/sw/mm/ 

    [설치] 


    [root@vm_master AJS]# tar zxvf mm-1.1.3.tar.gz 
    [root@vm_master AJS]# cd mm-1.1.3 
    [root@vm_master mm-1.1.3]# ./configure 
    [root@vm_master mm-1.1.3]# make 
    [root@vm_master mm-1.1.3]# make install 
    [root@vm_master mm-1.1.3]# cd .. 
    [root@vm_master AJS]# mv mm-1.1.3 /usr/local/ 

    _______________________________________________________________________________ 

    10.mod_ssl 설치 

    [소스 다운로드] 
    http://www.modssl.org/source/ 

    [설치] 
    [root@vm_master AJS]# tar zxvf mod_ssl-2.8.5-1.3.22.tar.gz 
    [root@vm_master AJS]# cd mod_ssl-2.8.5-1.3.22 
    [root@vm_master mod_ssl-2.8.5-1.3.22]# ./configure 
    > --with-apache=../apache_1.3.22 
    > --with-ssl=/usr/local/ssl --enable-shared=ssl 
    > --with-mm=/usr/local/mm-1.1.3 

    _______________________________________________________________________________ 

    11.apache & mod_gzip 

    [ mod_gzip모듈 다운로드 ] 
    http://www.remotecommunications.com/apache/mod_gzip/ 에서 mod_gzip.c 

    [ mod_gzip 참고 사이트] 
    http://www.apache.kr.net/documents/mod_gzip_kr.html 

    [소스 수정] 

    # 최대 클라이언트 접속수 조정 
    [root@vm_master apache_1.3.22]# vi src/include/httpd.h 

    #ifndef HARD_SERVER_LIMIT 
    #ifdef WIN32 
    #define HARD_SERVER_LIMIT 1024 
    #elif defined(NETWARE) 
    #define HARD_SERVER_LIMIT 2048 
    #else 
    #define HARD_SERVER_LIMIT 256 // 이곳의 숫자값을 512로 변경 
    #endif 
    #endif 

    # 버전 정보를 변경한다. 

    #define SERVER_BASEVENDOR "Apache Group" //적당히 다른 이름으로 
    #define SERVER_BASEPRODUCT "Apache" //다른 이름으로 
    #define SERVER_BASEREVISION "1.3.22" //버전을 적당히 고친다. 

    #mod_gzip.c를 받어서 아파치 디렉토리의 다름 경로로 이동 시킨후 설정 내용에 
    #mod_gzip에 관한 내용을 집어 넣는다. 
    [root@vm_master AJS]# cp mod_gzip.c apache_1.3.22/src/modules/extra/ 
    [root@vm_master AJS]# echo "AddModule modules/extra/mod_gzip.o" >> apache_1.3.22/src/Configuration.tmpl 

    [root@localhost AJS]# cd apache_1.3.22 
    [root@vm_master apache_1.3.22]# EAPI_MM="/usr/local/mm-1.1.3" SSL_BASE="/usr/local/ssl" 

    #만약 php를 DSO방식으로 처리를 하고 싶다면 아파치를 먼저 컴파일 한다. 
    [root@vm_master apache_1.3.22]# ./configure --prefix=/usr/local/apache 
    > --enable-rule=SHARED_CORE --enable-shared=ssl 
    > --enable-module=ssl --enable-module=so --enable-shared=max 

    #만약 php를 DSO로 하지 않는 경우 php를 먼저 컴파일 하고 다음 옵션을 넣는다. 
    [root@vm_master /AJS]#tar zxvf php-4.1.1.tar.gz 
    [root@vm_master /AJS]#cd php-4.1.1 
    [root@vm_master /php-4.1.1]#./configure --prefix=/usr/local/php 
    --with-apache=../apache_1.3.22 
    --with-mysql=/usr/local/mysql 
    --with-imap=/usr/local/imap 
    --with-gd=/usr/local/gd 
    --enable-track-vars 
    --with-language=korean 
    --with-config-file=/usr/local/php/lib 
    --with-charset=euc_kr 
    --disable-debug 
    --with-xml --enable-magic-quotes 
    [root@vm_master /php-4.1.1]#make;make install 

    ## php.ini와 기타 설정은 하단 PHP DSO방식으로 하기 참조 ## 

    #php를 먼저 컴파일 하고 아파치에서 옵션을 넣는다. 
    [root@vm_master apache_1.3.22]# ./configure --prefix=/usr/local/apache 
    --enable-rule=SHARED_CORE --enable-shared=ssl 
    --enable-module=ssl --enable-module=so --enable-shared=max 
    --activate-module=src/modules/php4/libphp4.a 

    [root@vm_master apache_1.3.22]# make 

    # 이과정에서 서버를 묻는다.. 정확히 자신의 https 서버이름을 지정해야 한다. 
    [root@vm_master apache_1.3.22]# make certificate TYPE=custom 

    [root@vm_master apache_1.3.22]# make install 

    #설치후 mod_gzip 설정 화일을 httpd.conf에 넣는다. 참고로 옆에 있는 #있는 주석은 모두 지운다. 


    mod_gzip_on Yes 
    mod_gzip_dechunk Yes 
    mod_gzip_min_http 1000 # 1000 = HTTP/1.0, 1001 = HTTP/1.1 
    mod_gzip_minimum_file_size 300 # 압축할 최소 Size 
    mod_gzip_maximum_file_size 0 
    mod_gzip_maximum_inmem_size 100000 
    mod_gzip_keep_workfiles No 
    mod_gzip_item_include file .html$ # 압축할 파일들 설정 
    mod_gzip_item_include file .htm$ 
    mod_gzip_item_include file .jsp$ 
    mod_gzip_item_include file .php$ 
    mod_gzip_item_include file .pl$ 
    mod_gzip_item_include mime ^text/.* 
    mod_gzip_item_include mime ^text/.html # 설명서에는 이렇게 되있는데 
    # 다음줄을 넣어야 되더군요. 
    mod_gzip_item_include mime ^text/html$ # HTML 형식 모두 압축 
    mod_gzip_item_include mime ^application/x-httpd-php # PHP 스크립트 압축 
    mod_gzip_item_include mime ^httpd/unix-directory$ 
    mod_gzip_item_include handler ^perl-script$ 
    mod_gzip_item_include handler ^server-status$ 
    mod_gzip_item_include handler ^server-info$ 
    mod_gzip_item_exclude file .css$ # 압축 제외 파일들. 
    mod_gzip_item_exclude file .js$ 
    mod_gzip_item_exclude mime ^image/.* 

    mod_gzip_temp_dir /dev/shm # 이것 Linux용이고요 보통 '/tmp'하시면됩니다. 
    LogFormat "%h %l %u %t "%V %r" %>s %b mod_gzip: %{mod_gzip_result}n In:%{mod_gzip_input_size}n Out:%{mod_gzip_output_size}n:%{mod_gzip_compression_ratio}npct." common_with_mod_gzip_info2 
    CustomLog logs/mod_gzip common_with_mod_gzip_info2 




    _______________________________________________________________________________ 

    12. SSL 인증서 수동으로 만들기 

    [아파치에서 make certificate에서 인증서 자동으로 생성된다. 하지만 잘 안되는 경우는 
    다음과 같이 해서 인증서를 만든다. ] 


    # 여러가지 묻는데 "."로 하면 그냥 넘어간다. 혹은 메세지에 맞게 항목을 넣는다. 
    [root@vm_master apache_1.3.22]# cd /usr/local/ssl/bin/ 
    [root@vm_master bin]# ./openssl req -new > new.cert.csr 
    [root@vm_master bin]# ./openssl rsa -in privkey.pem -out new.cert.key 
    [root@vm_master bin]# ./openssl x509 -in new.cert.csr -out new.cert.cert -req -signkey new.cert.key -days 999 

    # 키값을 복사한다. 

    [root@vm_master bin]# cp new.cert.key /usr/local/apache/conf/ssl.key/server.key 
    [root@vm_master bin]# cp new.cert.cert /usr/local/apache/conf/ssl.key/server.crt 

    _______________________________________________________________________________ 

    13. Apache+mod_ssl 을 자동시작 하려면 

    [참고 사이트] 
    http://linux.sarang.net/board/?p=read&table=qa&no=105693&page=3&o[at]=s&o[sc]=a&o[ss]=mod_ssl&o[st]=a 


    'httpd.conf' 파일을 열어서 'SSLPassPharaseDialog'란 부분을 
    찾아서 그 뒷부분에다가 'exec:실행파일명' 형식으로 적어주시고 
    그 '실행파일'을 만들어주심 됩니다. 이 '실행파일'이 하는 일은 
    단순히 SSL Private Key에 대한 패스워드를 Clean Text 형식으로 
    출력해주는 것입니다. 
    아래는 예입니다. (패스워드가 'password'라고 가정함) 

    ------------ httpd.conf 의 부분 ---------------------- 
    SSLPassPhraseDialog exec:/usr/local/sbin/ssl_pass.sh 
    ------------ 이 부분에서 자르세요 -------------------- 

    ------------ ssl_pass.sh ----------------------------- 
    #!/bin/sh 
    echo password 
    ------------ 이 부분에서 자르세요 -------------------- 

    여기서 반드시 주의하실 점은 'ssl_pass.sh'의 권한 설정입니다. 
    절대적으로 root만 읽고 실행할 수 있어야 합니다. 

    # chown root.root ssl_pass.sh 
    # chmod 500 ssl_pass.sh 


    위에서 예를 든 방법 외에 그냥 바로 'httpd.conf' 파일내에 
    패스워드를 적어주는 방법도 있지만, 보안 상 그다지 추천할 
    만한 방법은 아닌 것 같습니다. 
    좀 더 자세한 정보를 얻고 싶으시면, mod_ssl 홈페이지에 
    가셔서 'SSLPassPharaseDialog'란 키워드로 검색을 해보심 
    됩니다. 



    14.DSO PHP 설치 

    [소스 다운로드] 
    http://www.php.net/downloads.php 

    # 소스를 풀고 설정을 한다. 
    [root@vm_master php-4.1.1]# CFLAGS='-O2 -I/usr/local/ssl/include' ./configure 
    --prefix=/usr/local/php 
    --with-apxs=/usr/local/apache/bin/apxs 
    --with-mysql=/usr/local/mysql 
    --with-imap=/usr/local/imap 
    --with-gd=/usr/local/gd 
    --enable-track-vars 
    --enable-magic-quotes 
    --with-openssl=/usr/local/ssl 
    --with-language=korean 
    --with-charset=euc_kr 
    --disable-debug 
    --with-xml 

    # 설치 한다. 
    [root@vm_master php-4.1.1]# make ;make install 

    [root@vm_master php-4.1.1]# cp php.ini-dist /usr/local/php/lib/php.ini 

    # 다음 php 관련 내용이 아파치 설정 화일에 있는지 확인 한다. 
    [root@vm_master conf]# cat httpd.conf | grep php 
    LoadModule php4_module libexec/libphp4.so 
    AddModule mod_php4.c 
    DirectoryIndex index.html index.php 
    # http://www.php.net) will typically use: 
    #AddType application/x-httpd-php3 .php3 
    #AddType application/x-httpd-php3-source .phps 
    AddType application/x-httpd-php .php .phtml .html .htm .ph 
    AddType application/x-httpd-php-source .phps 

    mod_gzip_item_include file .php$ 
    mod_gzip_item_include mime ^application/x-httpd-php 


    _______________________________________________________________________________ 

    15.Zend Optimizer 설치 

    [다운로드] 
    http://www.zend.com/store/products/zend-optimizer.php 

    # 소스를 풀고 디렉토리를 만들고 php.ini를 수정한다. 
    [root@vm_master AJS]# tar zxvf ZendOptimizer-1[1].2.0-PHP_4.1.0-Linux_glibc21-i386.tar.gz 
    [root@vm_master AJS]# mkdir -p /usr/local/Zend 
    [root@vm_master AJS]# mkdir -p /usr/local/Zend/lib 
    [root@vm_master AJS]# cd ZendOptimizer-1.2.0-PHP_4.1.0-Linux_glibc21-i386/data 
    [root@vm_master data]# cp ZendOptimizer.so /usr/local/Zend/lib/ 

    # 다음 라인을 추가한다. 
    [root@vm_master data]# vi /usr/local/php/lib/php.ini 
    [Zend Optimizer] 
    zend_optimizer.optimization_level=7 
    zend_extension="/usr/local/Zend/lib/ZendOptimizer.so" 

    _______________________________________________________________________________ 

    16.apache & tomcat 연동 mod_webapp.so 설치 

    [ 모듈 다운로드 ] 
    http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.0.1/bin/linux/i386/ 

    # 소스를 풀고 모듈을 설치 한다. 
    [root@vm_master AJS]# tar zxvf webapp-module-1.0-tc40-linux-glibc2.2.tar.gz 
    [root@vm_master AJS]# cd webapp-module-1.0-tc40 
    [root@vm_master webapp-module-1.0-tc40]# cp mod_webapp.so /usr/local/apache/libexec/ 

    # 아파치 설정 화일에 다음 라인을 추가 한다. 
    [root@vm_master webapp-module-1.0-tc40]# cat /usr/local/apache/conf/httpd.conf | grep web 
    LoadModule webapp_module libexec/mod_webapp.so 
    AddModule mod_webapp.c 

    # 아파치 설정 화일에서 도규먼트 루트 디렉토리를 톰켓 디렉토리로 변경한다. 
    # 그리고 ssl 가상 호스트 또한 변경을 한다. 

    [root@vm_master webapp-module-1.0-tc40]# cat /usr/local/apache/conf/httpd.conf | grep DocumentRoot 
    # DocumentRoot: The directory out of which you will serve your 
    #DocumentRoot "/usr/local/apache/htdocs" 
    DocumentRoot "/usr/local/jakarta-tomcat/webapps/ROOT" 

    # This should be changed to whatever you set DocumentRoot to. 
    # even if you change the DocumentRoot. Comment it if you don't want to 
    # DocumentRoot /www/docs/dummy-host.example.com 
    #DocumentRoot "/usr/local/apache/htdocs" 
    DocumentRoot "/usr/local/jakarta-tomcat/webapps/ROOT" 


    # 아파치와 톰켓을 연결하는 부분이다. 이부분을 맨 마지막 부분에 넣는다. 
    [root@vm_master bin]# cat /usr/local/apache/conf/httpd.conf | grep WebApp 
    WebAppConnection conn warp localhost:8008 
    WebAppDeploy examples conn /examples 
    WebAppInfo /webapp-info 


    # 최종 테스트 순서 톰켓을 먼저 구동한 다음에 아파치를 구동한다. 

    [root@vm_master bin]# cd /usr/local/jakarta-tomcat/bin/ 
    [root@vm_master bin]# ./startup.sh 
    Guessing CATALINA_HOME from catalina.sh to ./.. 
    Setting CATALINA_HOME to ./.. 
    Using CLASSPATH: ./../bin/bootstrap.jar:/usr/local/jdk/lib/tools.jar 
    Using CATALINA_BASE: ./.. 
    Using CATALINA_HOME: ./.. 
    Using JAVA_HOME: /usr/local/jdk 

    # 아파치 실행 할때 에러 메세지가 난다. 이것은 무시해도 된다. 잘 되네요. 
    [root@vm_master bin]# /usr/local/apache/bin/apachectl start 
    [Thu Jan 17 07:56:38 2002] [warn] Loaded DSO libexec/mod_webapp.so uses plain Apache 1.3 API, 
    this module might crash under EAPI! (please recompile it with -DEAPI) 
    /usr/local/apache/bin/apachectl start: httpd started 

    _______________________________________________________________________________ 

    17.최종 연동 테스트 

    http://hostname/ 
    https://hostname/ 

    두가지가 모두 잘나온다면 성공.. 추카.. ^^; 

    # 아파치 구동시 문제가 있더라도 만약 다음과 에러가 나오더라도 이상 없는 것이다. 
    [Thu Jan 17 07:52:34 2002] [warn] Loaded DSO libexec/mod_webapp.so uses plain Apache 1.3 API, 
    this module might crash under EAPI! (please recompile it with -DEAPI) 
    posted by 좋은느낌/원철
    2009. 5. 27. 19:51 개발/JavaScript
    출처 : http://enzine.tistory.com/entry/50%EA%B0%9C-%EC%9D%B4%EC%83%81%EC%9D%98-Ajax-%EC%98%88%EC%A0%9C%EB%93%A4

    Ajax Forms

    ShoutBox

    Validate a Username AJAX

    Ajax 메신저

    Ajax 탭 컨텐트

    Ajax 장바구니

    Ajax 별점 매기기

    Ajax 인라인 에디트

    Ajax 프로그레스 바

    Ajax 페이징

    Ajax 파일 브라우저 & 관리자

    Ajax 캘린더

    Ajax 사진 관리

    Ajax 이미지 갤러리와 슬라이드쇼

    Ajax 파일 업로드

    Ajax 자동완성

    웹에디터

    투표

    테이블 데이터 관리

    기타


    posted by 좋은느낌/원철
    2009. 5. 21. 20:01 개발/Oracle

    리눅스 환경에서 Oracle JDBC설정

     

    글쓴이: 굿스피드 (2003년 09월 04일 오전 11:44) 읽은수: 495

    JDBC는 자바에서 SQL문을 실행하기 위한 자바 API이다. "Java DataBase Connectivity"의 약자로 간주되기도 하지만 사실상은 상표이름이다. JDBC는 자바로 작성되어진 클래스와 인터페이스들로 구성되어있다. 툴/데이터베이스 개발자들을 위한 표준 API를 제공하고 pure 자바 API를 사용하여 데이터베이스 어플리케이션을 만들게 해준다.

    JDBC를 사용하면, 어떠한 관계 데이터베이스(relational database)로도 SQL문을 전송하기 쉽다. 즉, JDBC API를 사용하면 Sybase, Oracle, Informix에 접근하는 프로그램을 따로 만들 필요가 없다. 단지 하나의 프로그램을 작성하고 그 프로그램에서 SQL 문을 적당한 데이터베이스에 전송할 수 있다. 또한 어플리케이션을 자바로 작성한다면, 어플리케이션을 플랫폼에 따라 다르게 작성하지 않아도 되기 때문에 자바와 JDBC의 결합은 하나의 프로그램이 어디에서나 동작할 수 있게 해준다.

    +환경 설정

    리눅스 환경에서 oracle jdbc를 구동하기 위해서는 먼저 oracle jdbc드라이버가 있어야 된다. 오라클 설치시 기본 권정사항으로 설치했다면 이미 jdbc드라이버가 들어있다. 만약 없다면 아래 링크에서 버전별로 자신의 오라클에 맞는 드라이버를 다운받기 바란다.

    Oracle JDBC Download

    필자는 오라클 8.1.7을 설치했다. 기본 권장 사항 설치를 했을 경우 JDBC드라이버가 지원이 되었었다. 기본 권장 사항 설치시 jdbc드라이버의 경로는 $ORACLE_HOME/product/8.1.7/jdbc/lib이다.

    lib폴더 아래 보면 classes111.zip(9i는 classes12.zip)화일이 있을것이다. jdbc드라이버가 있는것이 확인됐다면 이제 드라이버 환경 설정을 해보자

    [root@localhost]#
    [root@localhost]# unzip classes111.zip
    [root@localhost]# ls
    javax	oracle
    

    먼저 classes111.zip의 압축을 풀어보면 javax oracle폴더가 보일것이다. 이것일 jar로 압축해서 사용을 할 것이다.

    [root@localhost]#
    [root@localhost]# jar cvf classes111.jar javax/ oracle/
    

    위와 같이 jar로 압축을 하면 classes111.jar화일이 생성이 된다. 이제 CLASSPATH설정을 해보자.

    [root@localhost]#
    [root@localhost]# vi /etc/profile
    export CLASSPATH="$CLASSPATH:/oracle/product/8.1.7/jdbc/lib/classes111.jar"
    
    [root@localhost]# set | grep CLASSPATH
    CLASSPATH=.:/usr/local/JSDK/lib/jsdk.tar:/usr/local/tomcat/common/lib/servlet.jar:
    /oracle/product/8.1.7/jdbc/lib/classes111.jar
    

    위와 같이 classes111.jar이 나와야 정상이다. 일단 oracle jdbc가 제대로 설정이 되었나 테스트를 해보자.

    +Oracle JDBC 테스트 #1

    먼저 드라이버가 제대로 설정이 되었는지 테스트 해보자. 우선 아래와 같이 입력한다. JAVA에서 오라클 드라이버의 로딩을 확인해 볼 수 있다.

    [root@localhost]#
    [root@localhost]# javap oracle.jdbc.driver.OracleDriver
    Compiled from OracleDriver.java
    public class oracle.jdbc.driver.OracleDriver extends java.lang.Object 
    implements java.sql.Driver
        /* ACC_SUPER bit NOT set */
    {
        public static final char slash_character;
        public static final char at_sign_character;
        static final java.lang.String oracle_string;
        static final java.lang.String user_string;
        static final java.lang.String password_string;
        static final java.lang.String database_string;
        static final java.lang.String server_string;
        static final java.lang.String access_string;
        public static final java.lang.String protocol_string;
        public static final java.lang.String dll_string;
        --------------중간 생략-----------------------
        public int getMajorVersion();
        public int getMinorVersion();
        public boolean jdbcCompliant();
        public static java.lang.String getCompileTime();
        public oracle.jdbc.driver.OracleDriver();
        static {};
    }
    

    만약 위와 같이 안나온다면 CLASSPATH설정을 확인해 보기 바란다. 설정이 제대로 안되있다면 아래와 같이 에러가 나올 것이다.

    [root@localhost]#
    [root@localhost]# javap oracle.jdbc.driver.OracleDriver 
    Class 'oracle.jdbc.driver.OracleDriver' not found
    

    이제 실제로 java와 jsp테스트를 해보자. 소스가 좀 길다. 하지만 정확한 테스트가 가능하니 꼭 테스트 해보기 바란다.

    [root@localhost]#
    import java.sql.*;
    
    public class Jdbctest {
    public static void main (String args[]) {
    try {
    /* This produces more output then suitible for this article */
    /* Uncomment the next line for more connect information */
    // DriverManager.setLogStream(System.out); 
    /*
    * Set the host port and sid below to 
    * match the entries in the listener.ora
    * Must have a SCOTT/TIGER schema
    */
    String host = "127.0.0.1"; // change,these won\'t work
    String port = "1521";
    String sid = "oracle";
    // or pass on command line all three items
    if ( args.length >= 3 ) {
    host = args[0];
    port = args[1];
    sid = args[2];
    }
    
    String s1 = "jdbc:oracle:thin:@&quot; + 
    host + ":" +
    port + ":" +
    sid ;
    
    if ( args.length == 1 ) {
    s1 = "jdbc:oracle:oci8:@&quot; +
    args[0];
    }
    
    
    if ( args.length == 4 ) {
    s1 = "jdbc:oracle:" + args[3] + ":@&quot; + 
    "(description=(address=(host=" + host+
    ")(protocol=tcp)(port=" + port+ 
    "))(connect_data=(sid=" + sid +
    ")))";
    }
    
    
    System.out.println( "Connecting with: " );
    System.out.println( s1 );
    
    DriverManager.registerDriver(
    new oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection( s1,
    "scott",
    "tiger");
    
    DatabaseMetaData dmd = conn.getMetaData();
    System.out.println("DriverVersion: ["+
    dmd.getDriverVersion()+"]");
    System.out.println("DriverMajorVersion: ["+
    dmd.getDriverMajorVersion()+"]");
    System.out.println("DriverMinorVersion: ["+
    dmd.getDriverMinorVersion()+"]");
    System.out.println("DriverName: ["+
    dmd.getDriverName()+"]");
    
    if ( conn!=null )
    conn.close();
    System.out.println("Done.");
    
    } catch ( SQLException e ) {
    System.out.println ("\\n*** Java Stack Trace ***\\n"); 
    e.printStackTrace();
    
    System.out.println ("\\n*** SQLException caught ***\\n"); 
    while ( e != null ) {
    System.out.println ("SQLState: " + e.getSQLState ()); 
    System.out.println ("Message: " + e.getMessage ()); 
    System.out.println ("Error Code: " + e.getErrorCode ()); 
    e = e.getNextException (); 
    System.out.println (""); 
    } 
    }
    }
    }
    

    테스트는 접속 방식은 thin oci8의 두가지로 테스트를 해본다. 127.0.0.1에는 오라클 리스너에 등록되어있는 포트를 넣어주고 1521은 오라클 기본포트이다. ORCL은 오라클 SID이다. 자신에게 맞는것을 넣어주면 된다.

    [root@localhost]#
    [root@localhost]# javac Jdbctest.java
    [root@localhost]# java Jdbctest 127.0.0.1 1521 ORCL thin(or 
    oci8)
    Connecting with:
    jdbc:oracle:thin:@(description=(address=(host=127.0.0.1)(protocol=tcp)
    (port=1521))(connect_data=(sid=oracle)))
    DriverVersion: [8.1.7.1.0]
    DriverMajorVersion: [8]
    DriverMinorVersion: [1]
    DriverName: [Oracle JDBC driver]
    Done.
    

    위와 같이 나오면 연결에 성공한 것이다. 만약 안된다면 CLASSPATH를 확인하기 바란다.

    +Oracle JDBC 테스트 #3

    이제 jsp환경에서 테스트를 해보자 필자의 jsp환경은 jakarta-tomcat-4.1.18과 apache_1.3.27을 mod_jk로 연동시켰다.

    [root@localhost]#
    [root@localhost]# vi oracle.jsp
    <%@ page language="java" import="java.sql.*" 
    contentType="text/html;charset=KSC5601" %>
    <%
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection Conn =
    DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:SID","scott","tiger");
    Statement stmt = Conn.createStatement();
    ResultSet rs = stmt.executeQuery("select * from tab");
    if (rs==null)
    {
               out.println("none");
    }
    else {
               out.println("oracle jdbc 연결 성공");
    }
    stmt.close();
    Conn.close();
    %>
    

    위와 같이 저장하고 웹브라우저로 확인해 보자. 만약 에러가 난다면 tomcat4가 jdbc드라이버를 제대로 인식을 못하는 것이다.

    +Oracle JDBC 트러블 슈팅

    tomcat 4버전부터 연동하는데 조금 어려움이 있다. 정상적으로 CLASSPATH도 잡혀있고 java와의 연동도 되지만 jsp와의 연동이 잘 안될때가 많았다. 이럴때는 다음과 같이 링크를 걸어주기 바란다.

    [root@localhost]#
    [root@localhost]# ln -s /oracle/product/8.1.7/jdbc/lib/classes111.jar \
    /usr/local/tomcat/common/lib/classes111.jar
    

    이렇게 링크를 걸어주면 tomcat환경에서 jdbc의 연동이 가능할것이다. 마지막으로 oracle과 tomcat + apache와의 연동에서 jdbc연동이 안된다면 apachectl시작 스크립트에 oracle환경 설정이 등록되어있나 확인해 보기 바란다. 물론 리스너쪽 설정도 이상이 없어야 한다.

    오라클 환경 설정은 ORACLE_HOME ORACLE_SID만 설정되어 있으면 된다.


    재 등록일 : 2003년 09월 06일 오후 09:29

     

    원문 : 나소드(http://www.nasord.com/stories.php?story=03/09/04/3444708)

    posted by 좋은느낌/원철
    2009. 5. 19. 20:04 개발/Oracle

    http://radiocom.kunsan.ac.kr
    오라클 리스너(Listener)는 네트워크를 이용하여 클라이언트에서 오라클 서버로 연결하기 위한 오라클 네트워크 관리자이다. 만약 로컬 데이터베이스가 아니고 네트워크로 연결된 원격 데이터베이스 서버에 연결하려면 원격 데이터베이스 서버는 그 리스너를 기동해야 한다. 즉, 서버가 클라이언트의 요청을 들을 수 있도록 그 리스너를 시작하는 것이다. 이러한 리스너의 시작과 종료, 또 그 상태를 확인하는 오라클 데이터베이스 관리 툴이 바로 오라클 리스너(lsnrctl)이다. 
    디폴트 리스너 이름은 LISTENER 이지만, 이 이름은 $ORACLE_HOME/network/admin/listener.ora 파일에서 리스너 이름을 변경할 수 있다.
    【예제】
    $ lsnrctl help
    The following operations are available
    An asterisk (*) denotes a modifier or extended command:
     
    start               stop                status              
    services            version             reload              
    save_config         trace               spawn               
    change_password     quit                exit                
    set*                show*               
     
    $ lsnrctl start
     
    $ lsnrctl stop
     
    $ lsnrctl status
    
    【예제】
    $ ls -l network/admin/listener.ora
    -rw-r--r--   1 oracle   oinstall     599 Jan  7 13:15 network/admin/listener.ora
    $ cat network/admin/listener.ora
    # listener.ora Network Configuration File: /export/home0/oracle/app/oracle/product/10.2.1/network/admin/listener.ora
    # Generated by Oracle configuration tools.
     
    SID_LIST_LISTENER =
      (SID_LIST =
        (SID_DESC =
          (SID_NAME = PLSExtProc)
          (ORACLE_HOME = /export/home0/oracle/app/oracle/product/10.2.1)
          (PROGRAM = extproc)
        )
      )
     
    LISTENER =
      (DESCRIPTION_LIST =
        (DESCRIPTION =
          (ADDRESS_LIST =
            (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
          )
          (ADDRESS_LIST =
            (ADDRESS = (PROTOCOL = TCP)(HOST = jinpo.kunsan.ac.kr)(PORT = 1521))
          )
        )
      )
     
    $ 
    
    또 다른 방법으로 오라클 리스너는 오라클 홈의 bin 디렉토리에 위치하며 리스너를 실행하면, 리슨너 프롬프트인 LSNRCTL>이 출력된다. 이때 도움말이 필요하다면 HELP를 입력하여 도움을 받을 수 있다. 이러한 오라클 리스너의 명령어 중 START는 오라클 리스너를 시작하고, STOP는 오라클 리스너를 종료하는 명령어이다. STATUS는 시작된 오라클 리스너의 상태를 확인하는 명령어이며, SERVICES는 현재 시작된 서비스의 수를 출력하는 명령어이다.
    【예제】
    $ lsnrctl
    LSNRCTL for Solaris: Version 10.2.0.1.0 - Production on 02-SEP-2007 15:47:03
     
    Copyright (c) 1991, 2005, Oracle.  All rights reserved.
     
    Welcome to LSNRCTL, type "help" for information.
     
    LSNRCTL> help
    The following operations are available
    An asterisk (*) denotes a modifier or extended command:
    
    start               stop                status
    services            version             reload
    save_config         trace               spawn
    dbsnmp_start        dbsnmp_stop         dbsnmp_status
    change_password     debug               test
    quit                exit                set*
    show*
    
    오라클 리스너 명령어의 세부 사항은 다음과 같다.
    
    start [listener_name]start listener
    stop [listener_name]stop listener
    status [listener_name]get the status of listener
    service [listener_name]get the service information of the listener
    version [listener_name]get the version information of the listener
    reload [listener_name]reload the parameter files and SIDs
    save_config [listener_name]saves configuration changes to parameter file
    trace OFF | USER | ADMIN [listener_name]set tracing to the specified level
    spawn [listener_name] spawn_alias
    [(ARGUMENTS='arg0, arg1,...')]
    change_password [listener_name]changes the password of the listener
    quit | exitexit LSNRCTL
    오라클 리스너 명령어 중에서 set과 show 명령어의 쓰임새는 다음과 같다. 【예제】 LSNRCTL> help set The following operations are available after set An asterisk (*) denotes a modifier or extended command: password rawmode displaymode trc_file trc_directory trc_level log_file log_directory log_status current_listener connect_timeout startup_waittime use_plugandplay direct_handoff save_config_on_stop LSNRCTL> help show The following operations are available after show An asterisk (*) denotes a modifier or extended command: rawmode displaymode trc_file trc_directory trc_level log_file log_directory log_status current_listener connect_timeout startup_waittime snmp_visible use_plugandplay direct_handoff save_config_on_stop LSNRCTL>
    posted by 좋은느낌/원철
    2009. 5. 18. 19:40 개발/Java
    좋은 링크를 발견해서 그대로 따라 했더니 잘 됐습니다.
    http://news.softpedia.com/news/How-to-Install-Java-in-Fedora-Core-6-39724.shtml
    학교 인터넷이 느린건지 접속이 상당히 느리네요.

    1. 설치할 jdk(or jre) 다운로드
    rpm 버전이 아니라 그냥 self-extracting 파일입니다.
    사용자 삽입 이미지

    2. 설치할 폴더로 파일 이동
    mv jdk-6u1-linux-i586.bin /opt

    3. 설치할 폴더로 이동하여 권한 설정을 변경합니다.
    cd /opt
    chmod +x jdk-6u1-linux-i586.bin

    4. 설치합니다.
    ./jdk jdk-6u1-linux-i586.bin

    5. 다운 받은 파일 제거 합니다.
    rm -rf jdk-6u1-linux-i586.bin

    6. 파이어폭스의 플러그인에서 사용하는 java의 링크를 변경합니다.
    ln -s /opt/jdk1.6.0_01/jre/plugin/i386/ns7/libjavaplugin_oji.so /usr/local/firefox/plugins/libjavaplugin_oji.so
    자세한 경로는 저와 다를 수 있습니다. 각각 자바 설치 폴더와 파이어폭스 설치 폴더로 변경해 주시면 됩니다.

    7. 패스 설정
    vi /etc/profile.d/java.sh
    편집기 열고 다음과 같이 패스를 넣어 줍니다.
    export J2RE_HOME=/opt/jdk1.6.0_01/jre
    export PATH=$J2RE_HOME/bin:$PATH

    8. 위에서 만든 파일을 사용하도록 합니다.
    source /etc/profile.d/java.sh

    9. 패스 설정 확인
    which java
    명령으로 방금 설치한 java 디렉토리가 나오는지 확인합니다.

    10. 시스템에서 사용할 java 변경
    /usr/sbin/alternatives --install /usr/bin/java java /opt/jdk1.6.0_01/jre/bin/java 2
    /usr/sbin/alternatives --config java
    마지막 줄에서 선택 가능한 java가 두 개 나올 것 입니다. 이 때 2 를 입력합니다.

    11. 변경 됐는지 확인
    /usr/sbin/alternatives --display java

    12. 마지막으로 자바 버전 확인
    java -version1
    posted by 좋은느낌/원철
    2009. 5. 13. 17:21 개발/Oracle
    instr(object_name,'abcd')>0

    where 절 밑에  object_name like '%abcd%' 로 검색하는 것보다 

    instr(object_name,'abcd') > 0 로 검색하면 더 빠르다..
    posted by 좋은느낌/원철
    2009. 5. 13. 11:08 개발/Oracle
    SGA - System Global Area

    오라클이 사용하는 글로벌 메모리영역
    쿼리가 발생하면 이 영역에 해당 데이터가 있는지 확인하고 있으면 이 영역에서 읽어간다..
    존재하지 않으면 디스크에서 읽어서 SGA에다가 옮긴 후 SGA에 있는 데이터를 읽어간다..


    System Global Area (SGA) - Overview

    SGA refers to a Shared Global Area. As the term global implies, this area is accessible to all Oracle processes and users. Each instance will have its own SGA. Oracle processes and users must share large amounts of data. If all of the processes had to get the data from the disk, the IO load would soon render response times that would be totally unacceptable. To prevent this, Oracle uses Global Memory areas, that is, CPU memory. This memory is dedicated to use for Oracle alone. The SGA contains data buffer areas, redo log buffers and the shared pool (context areas). Each area is important to the database overall performance. On Oracle8 an additional area the large pool is also configured.

    The Shared pool context areas and Database buffers provide immediate access to data that has been pre-read from either the Data Dictionary tables or the data tables. The Oracle kernel process uses an LRU (Least Recently Used) algorithm to write data back to the disks. Data is never altered on the disks directly, but is altered in memory first.

    The redo buffers contain row change information, transaction commit history and checkpoint history. This data is written into the Redo logs and eventually to the Archive logs. A commit will force a disk write as will the filling of a redo log buffer or the reaching of a pre-defined checkpoint.

    The queue and request areas store data that is being transferred between processes such as servers and other Oracle processes. The shared SQL area stores all SQL statements in a parsed form. When a user or process issues a SQL command, the shared SQL area is checked to see if the command already exists in parsed form, if it does, this shared version is used. If the multi-threaded server option is utilized, some of the user process global area is also placed in the shared pool.

    Large Pool

    Oracle8 added an optional structure called the large pool. The large pool area is used for two main purposes:

    • Contains the User Global Area (UGA) when sessions are connected using MTS
       
    • Buffers for sequential file I/O

    Before Oracle8, Oracle stored MTS user connection information in the UGA structure of the shared pool. As the number of users would increase, it was possible for the SGA to run out of space. This additional memory requirement imposed by the use of MTS would reduce the shared pool memory available for the data dictionary cache and the library cache. Oracle now uses the large pool for the session's UGA if the DBA has configured it. The large pool is protected by the shared pool latch and does not use any LRU (least recently used) algorithm to manage space. Therefore, memory must be allocated and freed by each session. An ORA-4031 message will occur if the large pool runs out of memory. You can see the space usage of the large pool by querying the V$SGASTAT view.

    Another use of the large pool is as a memory buffering area for slaved DB writers. You use the writers to attempt to mimic asynchronous I/O on various systems that do not provide this feature. Check your system's specific documentation to determine if you might benefit from multiple DB writers.

    To configure the large pool in the init.ora, use the LARGE_POOL_SIZE and LARGE_POOL_MIN_ALLOC parameters. The values can be expressed in kilobytes (KB) or megabytes (MB). Keep in mind that in allocating these structures, you are allocating additional memory to the SGA. Be careful that you do not allocate the large pool so that memory starts paging out to disk, because this can have serious performance impacts.

    SGA Structure

    The SGA is divided into the following sections:

    The DC_ parameters are internally controlled and the DBA cannot control how the cache is partitioned. The cache size is determined empirically from the SHARED_POOL_SIZE parameter.

    The Shared pool is a shared resource area that stores the cache information and the parsed images of SQL and PL/SQL procedures, packages and triggers. The cache area can be monitored and if poor hit ratio statistics are shown, increasing the init.ora SHARED_POOL_SIZE parameter will help reduce it. In addition the view V$LIBRARYCACHE helps to monitor the parsed images.

    Multiple Buffer Pools

    The way objects use blocks in the SGA depends on the nature of the object (table, index, and so forth) and the way the object is used (for example, an object may be a small, static, but constantly used lookup table, or a large, static, but rarely used data warehouse table). The different usage characteristics of these objects often demand different types of storage. Some objects should be kept in memory as long as possible and others should be cleared out of memory soon after use. To deal with these types of situations, Oracle8 provides a method of allowing more granular control over the SGA storage of database blocks and how long blocks are maintained in memory. Oracle8 provides three pools for database data block storage:

    • Default buffer cache
       
    • KEEP buffer pool
       
    • RECYCLE buffer pool

    Each of these pools allows you to assign specific database objects to them and to retain the blocks from those objects using different retention criteria. The KEEP buffer pool and the RECYCLE buffer pool segment memory from the default buffer pool, so be careful that you do not leave the default buffer pool short of memory. DBAs may use the V$BUFFER_POOL view to monitor the various buffer pool settings currently in use.

    The Default Buffer Pool

    The default buffer pool (still referred to as the database buffer cache) is always allocated in an Oracle database. To allocate memory to the default buffer pool, set the number of database buffer blocks you want the cache to be and do so by setting the DB_BLOCK_BUFFERS setting in the init.ora parameter file. The total size of this cache then is calculated as DB_BLOCK_BUFFERS * DB_BLOCK_SIZE. The LRU algorithm manages the data blocks in the default buffer pool.

    The KEEP Buffer Pool

    A CACHE option is available on database tables. This option causes database blocks that are read in from a table during a full table scan to be put onto the MRU (most recently used) end of the LRU (least recently used) list, as opposed to the LRU end. Thus, the data blocks associated with that table remain in the database buffer cache for a longer period of time before being aged out. The idea is to allow for as close to a 100 percent cache hit ratio as possible on these often-hit, smaller tables. The KEEP buffer pool gives you a dedicated segment of database buffer cache memory in which to load the blocks of these tables. Typically, these are smaller tables, such as lookup tables.

    You can set the BUFFER_POOL_KEEP parameter in init.ora to reserve part of the database buffer cache for pinned data blocks. Once the KEEP buffer pool is created, you can assign objects to this pool, and if the pool is sized properly, the data blocks from these objects will remain in memory. You must exercise caution when setting up the KEEP buffer pool. Ensure that you allocate only enough memory to store the blocks you wish kept in the buffer pool, and yet not over-allocate to the pool memory that will go unused. You determine how much memory to allocate to the pool by adding up the sizes of all the objects you intend to assign to the pool. Keep in mind that as you allocate memory to the pool, you reduce the amount of memory available in the database buffer cache to the default pool. If you undersize the pool, objects will be aged out using the LRU algorithm, as with the default buffer pool. An example of assigning a table to the KEEP buffer pool is shown below.

    CREATE TABLE small_table
     (pk_id NUMBER NOT NULL PRIMARY KEY,
     table_info VARCHAR2 NOT NULL)
    STORAGE (INITIAL 1M, NEXT 1M, BUFFER_POOL KEEP)

    The RECYCLE Buffer Pool

    The RECYCLE buffer pool's purpose is to store memory blocks that are not likely to be reused again soon. In the case of very large objects, access to individual blocks may be very random and scattered. In these circumstances, you may wish to assign such objects to the RECYCLE buffer pool.

    It is important not to size the RECYCLE buffer pool too small. Doing so may cause blocks to age out of the pool before an application or SQL statement uses them completely. To configure the RECYCLE pool, set the BUFFER_POOL_RECYCLE parameter in the init.ora file.

    If the block is aged out before the transaction is done with it, it needs to be re-read, causing more I/O. You can determine if this is happening by using one of the trace methods (for example, turning on trace and using tkprof to format the output trace file). To do so, compare disk accesses that occur in the default pool to disk access occurring in the RECYCLE buffer pool. In both cases, disk accesses should be the same. If the statement that ran and that was using the RECYCLE buffer pool has more disk accesses, you may conclude that the pool is too small. Another method of monitoring the pool is to monitor the free buffer waits and log file sync statistics. If either of these starts to grow after you allocate the RECYCLE buffer pool, it may mean that you have not allocated enough memory to the pool.

    The following is a guide for determining which objects should fit in the RECYCLE buffer pool:

    • A good candidate for a segment to put into the RECYCLE buffer pool is one that is at least twice the size of the default buffer pool and has incurred at least a few percent of the total I/Os in the system. 
       
    • A good candidate for a segment to put into the KEEP pool is one that is smaller than 10 percent of the size of the default buffer pool and has incurred at least 1 percent of the total I/Os in the system.
       
    • Calculate the ratio of blocks for a segment of the object in question that is used frequently to those used rarely. For that object, count the number of blocks that exist in the hot half of the cache (the MRU end) to the number of blocks in the cold half (the LRU end). If the ratio for a segment is close to 1, the segment may be a good candidate for the RECYCLE cache. If the ratio is high (perhaps 3), the segment might be a good candidate for the KEEP cache.

    An example of assigning a table to the RECYCLE buffer pool is shown below.

    CREATE TABLE small_table
     (pk_id NUMBER NOT NULL PRIMARY KEY,
     table_info VARCHAR2 NOT NULL)
    STORAGE (INITIAL 1M, NEXT 1M, BUFFER_POOL RECYCLE)

    SGA Fixed and Variable Portions

    The fixed portion of the SGA refers to the area unaffected by the INIT{sid}.ORA parameter values. The fixed portion may however vary between Oracle versions because of additional INIT{sid}.ORA parameters in the newer versions. This size can also vary between different Unix platforms due to different alignment Procedures. The fixed component of SGA is not tunable.

    The variable portion of the SGA consists of arrays of variables that are allocated based upon the INIT.ORA parameters.

    The list below states the impact that different INIT.ORA parameters have on the variable portion of the SGA:

    • DB_FILES - The lower the value of this parameter, the less the space needed. If this is set to 10 the gain in the space is about 6240 Bytes.
       
    • DB_FILE_MULTIBLOCK_READ_COUNT - The higher the value for this parameter, the less space needed.
       
    • All Dictionary cache parameters ( i.e. all DC_XXX Paratamers ) - Space needed for additional values of these parameters is not too high.
       
    • DDL_LOCKS - Space needed for additional value of 100 for this parameter is ~ 5.0k.
       
    • DML_LOCKS - Space needed for additional value of 100 for this parameter is ~ 9.76K.
       
    • ENQUEUE_RESOURCES - Space needed for additional value of 10 for this parameter is ~ 0.7k.
       
    • PROCESSES - Space needed for additional value of 10 for this parameter is ~ 19.5k.
       
    • ROW_CACHE_ENQUEUES - Space needed for additional value of 100 for this parameter is ~ 3.5K
       
    • SEQUENCE_CACHE_ENTRIES - Space needed for additional value of 10 for this parameter is ~ 1.17k
       
    • SEQUENCE_CACHE_HASH_BUCKETS - Space needed for additional value of 10 for this parameter is ~ 0.08k
       
    • SESSIONS - Space needed for additional value of 10 for this parameter is ~ 5.3K
       
    • TRANSACTIONS - Space needed for additional value of 10 for this parameter is ~ 0.85K.
       
    • TRANSACTIONS_PER_ROLLBACK_SEGMENT - More space is needed for lower values of this parameter

    Data Block Buffers

    The data block buffers are a cache in the SGA used to hold the data blocks read from the data segments in the database (e.g., tables, indexes, and clusters). The size of the data block buffer cache is determined by the INIT.ORA parameter DB_BLOCK_BUFFERS.

    The data block buffer cache is fixed in size and is usually smaller than the space used by database segments. This means it cannot hold all of the database's segments in memory at one time. The SGA retains the information stored in its cache buffers in accordance with the Least Recently Used (LRU) algorithm. The LRU algorithm determines what objects haven't been used for a given period of time and allows those objects to be over-written as needed to make way for additional data.

    Dictionary Cache

    The dictionary cache is used to store information about the database objects. This includes:

    • User account data
       
    • Datafile names
       
    • Segment names
       
    • Extent locations
       
    • Table descriptions
       
    • Privileges

    When any of this information is needed by the database, that data dictionary tables are read and the data is returned and stored in the SGA (in the dictionary cache).

    The dictionary cache is also managed using the LRU algorithm. The dictionary cache is part of the shared SQL Pool and is managed internally by the database. The size of the cache is set via the init.ora SHARED_POOL_SIZE parameter.

    Care should be given not to define the dictionary cache too small. This will result in the database repeatedly querying the data dictionary tables for the information it requires. These are known as recursive hits and are much slower than queries against the dictionary cache in memory.

    Redo Log Buffer

    Redo log files contain entries that describe the changes that have been made to the database. These entries are used in roll-forward operations during a database recovery. Before the entries are written to the online redo log files, they are first cached in the SGA. This area of the SGA is known as the redo log buffer.

    The size of the redo log buffer is set via the LOG_BUFFER parameter in the init.ora file.

    Click Here for additional information on Redo Log configuration.

    Shared SQL Pool

    The shared SQL pool is used to store the Dictionary Cache as well as information about SQL statements that are being run against the database. This shared SQL information consists of the execution plan and parse tree for the SQL statement. This enables subsequent (identical) SQL statements to reuse the parse information to accelerate its execution.

    SGA Size

    The size of the SGA is controlled by buffer sizes, and the buffer sizes are controlled by the database block size, which is specified at database creation and cannot be changed without rebuilding the database. This usually defaults to 2 KB. We usually suggest at least 4KB, and in most cases 8 KB works best. If in doubt, set the block size to the largest supported on your system.

    The five major components of the SGA are the database buffers, log buffers, large pool, Java pool, and the shared pool The SGA also contains the redo log buffers. The ideal situation would be to size the SGA to hold the entire database in memory. For small systems, this may be a real situation; for most, it is not feasible. Therefore, you must decide how much to allocate. Many times, especially for development databases, this will be a rough guess. For systems already designed with detailed data storage estimates, it may be better defined. A general rule of thumb for a pure Oracle system (no other applications) is 50 percent to 60 percent of available RAM for your SGA. Note that for small databases this may be overkill. In general, we have found that sizing the SGA data block buffers (the product of DB_BLOCK_SIZE and DB_BLOCK_BUFFERS) to 1/50 to 1/100 of the total physical size of the database is a good starting point. Under Oracle8i, new default sizes in the supplied sample initialization file are more realistic, but in general will still be too small for most production databases, so use them with caution.

    Oracle provides tools to analyze buffer performance. Unfortunately, they can only be used once a system is operating and running under a normal load.

    If you have no idea whatsoever, make the buffer area at least 60 to 100 MB or so (you will usually outgrow the Oracle default rather quickly) for a database that is near 1 gigabyte in total physical size, and up to 400 MB for one that is around 20 gigabytes in size. For databases smaller than 1 gigabyte physical size, the Oracle defaults may be usable. Make the shared pool at least 20 to 40 MB (not the 9 MB it will default to).

    If you overspecify the shared memory size on NT or Open-VMS you may get into a situation known as swapping. This is where all or part of your application is swapped out to disk because physical memory just isn't large enough to hold it all. Needless to say, this has a very negative impact on performance. Usually overspecification of the SGA on UNIX will lead to not being able to start the database.


    posted by 좋은느낌/원철