Linux 및 Windows 환경을 위한 PHP, Oracle 10g Instant Client 설치

PHP 5.1.2 업데이트

저자: Christopher Jones, Consulting Technical Staff, Oracle Corporation
업데이트일: 2006년 1월

Oracle 10g Instant Client (무료로 다운로드가 가능합니다)는 PHP를 원격 오라클 데이터베이스에 연결하기 위한 가장 손쉬운 방법으로, 3 개의 라이브러리만 설치하면 사용이 가능합니다.

PHP에서 Oracle API의 액세스에 사용되는 Instant Client 라이브러리는 OCI8이라는 이름으로 불립니다 (이 이름은 Oracle8 버전에서 최초로 개발되면서 붙여진 것입니다). PHP Oracle 8 함수 를 이용하여 Oracle 8.1.7, 9.x, 10.x를 직접 호출할 수 있고, 또는 PEAR MDB2ADOdb 등의 추상화 클래스(abstraction class)를 함께 이용할 수도 있습니다.

구 버전의 PHP “oracle” 익스텐션을 Instant Client에서 이용하는 것도 가능하지만, 이 경우에는 (오라클에 의해 더 이상 지원되지 않는) 구 버전의 Oracle API가 사용됩니다. 이러한 이유로, PHP 커뮤니티와 오라클은 새로운 개발작업에서 이 익스텐션을 사용하는 것을 권장하지 않고 있습니다.

Apache 환경에서 PHP 4 또는 PHP 5와 함께 Instant Client를 사용하기 위한 방법이 아래에 설명되어 있습니다. (5.1.2와 OCI8 익스텐션에 관련한 상세한 정보는 이 섹션을 참고하시기 바랍니다.) Instant Client에는 오라클 데이터베이스가 포함되어 있지 않으므로, 별도의 데이터베이스 환경이 미리 구축되어 있어야 합니다.

일반적으로 데이터베이스는 다른 머신에서 운영됩니다. 데이터베이스가 로컬에 설치된 경우에는, 필요한 오라클 컴포넌트가 이미 사용 가능하므로, Instant Client를 따로 설치할 필요가 없습니다.

소프트웨어 요구사항:

소프트웨어 참고
Oracle Instant Client "Instant Client Package - Basic"을 다운로드합니다. Linux 환경의 경우, "Instant Client Package - SDK"를 함께 다운로드합니다.
Apache HTTPD Server PHP 커뮤니티는 Apache 1.3을 권장하고 있습니다.
PHP - PHP Hypertext Processor Version 4.3 또는 이후 버전

Windows 환경에서 PHP OCI8 Extension 활성화하기

Instant Client 바이너리는 PHP에 포함된 Windows용 바이너리를 보완하는 역할을 담당하게 됩니다.

  1. (installer build가 아닌) PHP 바이너리 zip 파일과 Apache를 다운로드합니다. PHP 매뉴얼의 Windows 시스템 설치 가이드를 참고하여 설치 작업을 수행합니다. OTN의 오픈 소스 개발자 센터에서 "Oracle, PHP, and Apache on Windows 2000/XP 환경의 Oracle, PHP, Apache 설치,"와 같은 유용한 기술정보를 참고하실 수 있습니다. 이 문서에는 Oracle 10g를 전체 설치하는 방법이 설명되어 있습니다 (Instant Client 설치 시에는 이 작업이 필요하지 않습니다).

    다음 단계로 진행하기 전에 PHP가 제대로 동작하는지 확인합니다. 이 단계에서는 오라클 연동 기능은 지원되지 않습니다.

  2. OTN의 Instant Client 페이지에서 Instant Client Basic package for Windows를 다운로드합니다. zip 파일의 사이즈는 대략 30 MB 정도 됩니다.

  3. 서브디렉토리(예: c:\instantclient10_1)를 생성하고 zip 파일로부터 아래 라이브러리를 복사합니다:

    • oraociei10.dll
    • orannzsbb10.dll
    • oci.dll

    3개 파일의 총 용량은 약 80MB 정도 됩니다.

    PHP의 구 버전 oracle extension을 사용하려는 경우, oci.dll 대신 ociw32.dll을 복사합니다 (이 익스텐션을 활성화하려면 php.ini 파일에서 "extension=php_oracle.dll"로 설정합니다.)

  4. PATH 환경변수를 편집하여 “c:\instantclient10_1”가 다른 오라클 디렉토리의 앞에 위치하게 합니다.

    Windows 2000의 경우, 시작 -> 설정 -> 제어판 -> 시스템 -> 고급 -> 환경 변수로 이동하여 시스템 변수 목록의 PATH를 편집합니다.

    tnsnames.ora 파일을 이용하여 Oracle Net 서비스 네임을 정의한 경우, tnsnames.ora를 c:\instantclient10_1로 복사하고 사용자 환경변수 TNS_ADMIN을 c:\instantclient10_1로 복사합니다. 디폴트 서비스 네임은 사용자 환경변수 LOCAL에 추가로 설정할 수 있습니다.

    NLS_LANG과 같은 Oracle globalization language 환경변수를 필요에 따라 설정합니다. 아무것도 설정되지 않은 경우, 디폴트 로컬 환경이 그대로 사용됩니다. 자세한 정보는 An Overview on Globalizing Oracle PHP Applications 문서를 참고하십시오.

    Unset unnecessary Oracle variables such as ORACLE_HOME and ORACLE_SID.

  5. php.ini를 편집하고 OCI8 익스텐션의 커멘트 기호를 삭제합니다: extension=php_oci8.dll

    extension_dir 항목에 PHP 익스텐션 DLL의 전체 경로를 설정합니다. PHP4의 경우 DLL은 PHP 소프트웨어의 “extensions” 서브디렉토리에 위치합니다. PHP5에서는 “ext” 서브디렉토리에 위치합니다.

  6. Apache를 재시작합니다.

익스텐션이 설정되었음을 확인했다면, 웹 서버에서 접근할 수 있는 위치에 간단한 PHP 스크립트(phpinfo.php)를 생성합니다. <?php phpinfo(); ?>

"http://" URL을 사용하여 브라우저에서 스크립트를 로드합니다. 브라우저 페이지의 "oci8" 섹션에서 "OCI8 Support enabled"라는 문구를 확인할 수 있어야 합니다.

Linux에서 PHP OCI8 Extension 활성화하기

Linux 환경에서 오라클 연결을 추가하려면, 먼저 PHP를 다시 컴파일해야 합니다.

OTN의 오픈 소스 개발자 센터에서 " Linux에서 Oracle, PHP, Apache 설치하기",와 같은 유용한 기술정보를 참고하실 수 있습니다. 이 문서에는 Oracle 10g를 전체 설치하는 방법이 설명되어 있습니다 (Instant Client 설치 시에는 이 작업이 필요하지 않습니다.

  1. Apache를 다운로드하여 설치합니다. 사용자의 홈 디렉토리에 Apache를 설치하는 예가 아래와 같습니다: cd apache_1.3.31 ./configure --enable-module=so --prefix=$HOME/apache --with-port=8888 make make install

    $HOME/apache/conf/httpd.con을 편집하여 아래 항목을 추가합니다:

    AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
  2. PHP를 다운로드하여 tar 압축을 풉니다.
  3. OTN의 Instant Client 페이지에서 Basic/SDK Instant Client Package를 다운로드합니다. 두 RPM의 전체 크기는 약 30MB 가량 됩니다.
  4. root 사용자로 RPM을 설치합니다. rpm -Uvh oracle-instantclient-basic-10.1.0.3-1.i386.rpm rpm -Uvh oracle-instantclient-devel-10.1.0.3-1.i386.rpm

    첫 번째 RPM은 오라클 라이브러리를 /usr/lib/oracle/10.1.0.3/client/lib에 설치하고, 두 번째 RPM은 /usr/include/oracle/10.1.0.3/client에 헤더를 생성합니다.

  5. 백업 후 이 패치를 PHP의 ext/oci8/config.m4에 적용합니다. 패치 라인 넘버는 PHP 4.3.9를 기준으로 하고 있습니다. (PHP 4.3.11와 5.0.4의 경우처럼) PHP bug 31084가 해결되었다면 이 패치를 적용할 필요는 없습니다.

    PHP 4.3.9 또는 4.3.10을 사용하는 경우에는 이 패치를 파일(예: php_oci8ic_buildpatch)에 저장한 후 아래와 같이 설치합니다:

    patch -u config.m4 php_oci8ic_buildpatch

    위 패치를 실행하면 새로운 PHP 설정 매개변수 --with-oci8-instant-client[=DIR]이 생성됩니다. Linux 운영체제는 기본적으로 RPM을 통해 설치된 Instant Client의 최신 버전을 사용합니다. 오라클 라이브러리의 경로를 지정함으로써 다른 버전을 사용하도록 할 수도 있습니다. 어떤 경우든 버전에 맞는 SDK 헤더가 자동적으로 적용됩니다.

    새로운 매개변수는 기존의 --with-oci8 매개변수를 대체합니다.

    참고: Linux 이외의 운영체제에서는, 사용자가 선택한 디렉토리에 Instant Client 패키지의 압축을 풀게 됩니다. --with-oci8-instant-client 매개변수를 사용하려면 이 디렉토리를 명시적으로 지정해 주어야 합니다 (예: --with-oci8-instant-client=/home/instantclient10_1) Instant Client SDK는 Basic Package와 같은 디렉토리에 압축을 풀어야만, 재구성된 configure 스크립트에서 헤더 파일의 서브디렉토리를 정확하게 찾을 수 있습니다.

  6. “configure” 스크립트를 최상위 PHP 디렉토리에서 rebuild 합니다. cd php-4.3.9 rm -rf autom4te.cache config.cache ./buildconf --force
  7. 새로운 옵션을 이용하여 configure를 실행합니다. 홈 디렉토리에 Apache를 설치한 환경에서의 실행 예가 아래와 같습니다. ./configure \ --with-oci8-instant-client \ --prefix=$HOME/php --with-apxs=$HOME/apache/bin/apxs \ --enable-sigchild --with-config-file-path=$HOME/apache/conf
  8. PHP를 rebuild합니다. make make install
  9. php.ini 파일을 --with-config-file-path에서 지정된 위치에 복사합니다. cp php.ini-recommended $HOME/apache/conf/php.ini
  10. LD_LIBRARY_PATH를 /usr/lib/oracle/10.1.0.3/client/lib으로 설정하고 Apache를 재시작합니다.

    tnsnames.ora 파일을 이용하여 Oracle Net 서비스 네임을 정의한 경우, TNS_ADMIN을 파일이 위치한 디렉토리로 설정해 줍니다.

    Apache를 시작하기 전에 모든 오라클 환경 변수를 설정해 주는 것이 중요합니다. 스크립트의 예가 아래와 같습니다:

    #!/bin/sh APACHEHOME=/home/apache LD_LIBRARY_PATH=/usr/lib/oracle/10.1.0.3/client/lib:${LD_LIBRARY_PATH} TNS_ADMIN=/home export LD_LIBRARY_PATH TNS_ADMIN echo Starting Apache $APACHEHOME/apachectl start

익스텐션의 설정을 확인한 후, 웹 서버가 접근할 수 있는 위치에 간단한 PHP 스크립트(phpinfo.php)를 생성합니다.

<?php phpinfo(); ?>

URL("http://localhost:8888/<path>/phpinfo.php”)을 사용하여 스크립트를 브라우저에 로드합니다. 브라우저 페이지의 "oci8" 섹션에서 "OCI8 Support enabled"라는 문구를 확인할 수 있어야 합니다.

오라클로의 연결

오라클 연결을 생성하려면 먼저 오라클 연결 정보를 OCILogon()에 전달해 주어야 합니다. Instant Client와 관련된 모든 툴은 데이터베이스 서버의 “원격”에 위치하며, 따라서 사용자 이름, 암호와 함께 Oracle Net connection identifier가 사용되어야 합니다. 기존에 구성된 오라클 데이터베이스에 대한 연결 정보는 외부에서 “well-known” 정보로 확인이 가능합니다. 새로 구성된 시스템에서는 데이터베이스 셋업 과정에서 오라클 설치 프로그램에 의해 설정됩니다. 인스톨러는 Oracle Net 설정 및 서비스 네임 생성 작업을 수행합니다.

새로운 데이터베이스에서 HR와 같은 샘플 스키마를 사용하려면 unlock 작업을 수행하고 암호를 입력해야 할 수 있습니다. 이를 위해 SQL*Plus에서 SYSTEM 사용자로 연결한 뒤 아래와 같이 실행해 줍니다:

ALTER USER username IDENTIFIED BY new_password ACCOUNT UNLOCK;

연결 정보를 PHP에 전달하는 방법에는 여러 가지가 있습니다. 먼저 Oracle 10g의 Easy Connect 신택스를 이용하여 mymachine에서 실행 중인 the MYDB 데이터베이스 서비스의 HR 스키마에 연결하는 방법이 아래와 같습니다. 이 경우 tnsnames.ora 또는 다른 Oracle Network 파일이 필요하지 않습니다:

$c = OCILogon('hr', 'hr_password', '//mymachine.mydomain/MYDB');

Easy Connect 신택스 관련 오라클 문서(Using the Easy Connect Naming Method)를 참고하시기 바랍니다.

또는, /home/tnsnames.ora에 다음과 같은 내용이 포함된 경우:

MYDB = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = mymachine.mydomain)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = MYDB) ) )

그리고 TNS_ADMIN 환경변수가 (Apache 시작 이전에) /home으로 설정된 경우, 연결 문자열을 아래와 같이 설정할 수 있습니다: $c = OCILogon('hr', 'hr_password', 'MYDB');

환경변수 LOCAL(Windows) 또는 TWO_TASK(Linux)가 MYDB로 설정된 경우, MYDB로의 연결을 위한 문자열이 다음과 같습니다:

$c = OCILogon('hr', 'hr_password');

Oracle의 사용

기본적인 연결에 성공했다면, 간단한 스크립트(testoci.php)를 테스트해 볼 차례입니다. 사용자의 데이터베이스 환경에 맞게 연결 설정을 수정한 후 브라우저에서 스크립트를 로드합니다. HR 사용자가 소유한 모든 테이블의 목록을 표시하는 스크립트 예가 아래와 같습니다:

<?php $conn = OCILogon("hr", "hr_password", '//mymachine.mydomain:port/MYDB); $query = 'select table_name from user_tables'; $stid = OCIParse($conn, $query); OCIExecute($stid, OCI_DEFAULT); while ($succ = OCIFetchInto($stid, $row)) { foreach ($row as $item) { echo $item." "; } echo "<br>\n"; } OCILogoff($conn); ?>

트러블슈팅

Oracle PHP Troubleshooting FAQ에서 오라클 연결에 관련한 유용한 정보를 확인하실 수 있습니다.

오라클의 SQL*Plus 커맨드라인 툴을 Instant Client 페이지에서 다운로드하여 환경 및 연결 문제를 해결하는데 이용할 수 있습니다. SQL*Plus Instant Client Release Notes를 참고하시기 바랍니다.

SQL*Plus를 이용하여 환경을 점검하는 방법은 phpino.php 스크립트의 예와 동일합니다.

Windows 도움말

phpinfo.php 스크립트를 실행했을 때 “oci8” 섹션에서 "OCI8 Support enabled" 메시지를 확인할 수 없다면, php.ini 파일에서 "extension=php_oci8.dll" 항목의 주석 처리가 해제되었는지 점검합니다.

PATH가 잘못 설정되어 있거나 오라클 라이브러리를 찾을 수 없는 경우, Apache 시작 시 다음과 같은 경고 메시지가 표시됩니다: "The dynamic link library OCI.dll could not be found in the specified path." phpinfo() 페이지의 Environment 섹션에서, PHP에 의해 실제로 사용되는 PATH와 Oracle 변수의 값을 확인할 수 있습니다.

php.ini에 extension_dir 매개변수가 올바르게 설정되지 않은 경우 Apache 시작 시 다음과 같은 경고 메시지가 표시됩니다: "PHP Startup: Unable to load dynamic library php_oci8.dll."

Linux 도움말

config.m4가 올바르게 패치되었는지 확인합니다. “configure”의 실행에 실패한 경우, config.log 파일을 점검합니다. config.m4를 이전 상태로 되돌리고 캐시 파일을 제거한 후 “./buildconf --force and configure”를 실행한 다음, 발생한 문제가 패치 작업과 관련된 것인지 확인합니다.

“configure”의 타임스탬프가 현재 시점으로 설정되어 있는지 확인합니다. 캐시 파일을 모두 제거하고 필요한 경우 rebuild 작업을 수행합니다.

Apache를 시작하는 쉘에서 필요한 모든 Oracle 환경변수를 설정해 줍니다.

PHP 5.1.2 및 이후 버전

“re-factored” OCI8 익스텐션은 Instant Client를 위한 새로운 신택스를 지원합니다. re-factored 익스텐션은 PHP 5.1.2에 처음으로 포함되었으며, 이전 버전의 PHP의 경우pecl.php.net/package/oci8, pecl4win.php.net/ext.php/php_oci8.dll에서 다운로드할 수 있습니다.

Technical Note에 명시된 대로 Instant Client RPM을 설치했다면, PHP를 아래와 같이 설정해 줍니다: ./configure \ --with-oci8=instantclient,/usr/lib/oracle/10.1.0.3/client/lib \ --prefix=$HOME/php --with-apxs=$HOME/apache/bin/a pxs \ --enable-sigchild --with-config-file-path=$HOME/apache/conf

Instant Client Basic, SDK zip 파일을 사용하는 경우, 압축을 푼 디렉토리의 --with-oci8 옵션을 변경해 줍니다. 그 예가 아래와 같습니다:

--with-oci8=instantclient,$HOME/instantclient10_1

re-factored 버전이 올바르게 설치되었는지 점검하려면 phpinfo() 실행 결과를 확인하면 됩니다. “oci8.” 접두어로 시작되는 7가지 매개변수를 확인할 수 있을 것입니다 (이전 버전에서는 이 매개변수가 존재하지 않습니다).

결론

이 문서가 여러분에게 도움이 되었기를 바랍니다. 질문이나 의견은 OTN Instant Client 또는 PHP 포럼에 올려 주시기 바랍니다. 

  • 새 탭에서 링크 열기
  • 다운로드
Posted by 암리타 :

[root@localhost]# whereis php
php: /usr/lib/php /usr/local/bin/php /usr/local/lib/php.ini /usr/local/lib/php
[root@localhost]# crontab -e
*/1 * * * * /usr/local/bin/php -q 실행할 php경로

[root@localhost]# /etc/rc.d/init.d/crond restart
[root@localhost]# crontab -l
[root@localhost]# tail -f /var/log/cron

1. cron이란 :
   일정시간 마다 시스템에서 자동으로 실행 시키는 데몬입니다.
 
 2. cron 데몬의 실행과 종료
   실행 : /etc/rc.d/init.d/crond start
   종료 : /etc/rc.d/init.d/crond stop

 3. crond 설정
  크론(cron)의 설정은 /etc/crontab에서 합니다.
  옵션
  -e : 설정된 파일을 새롭게 편집
  -d : 등록된 내용을 삭제
  -l  : 현재 등록된 내용을 본다

 
 4. crontab 파일 형식
 ----------    ----------  ---------------------------------------------------
  필  드                 의  미           범  위
 ----------    ----------  ---------------------------------------------------
 첫 번째                      분              0-59
 두 번째                      시              0-23
 세 번째                      일              0-31
 네 번째                      월              1-12
 다섯 번째                  요일             0-7 (0 또는 7=일요일, 1=월, 2=화, ...)
 여섯 번째                명령어             실행할 명령을 한줄로 쓴다.
 ----------    ----------  ---------------------------------------------------

 - 모든 엔트리 필드는 공백으로 구분된다.
 - 한 줄당 하나의 명령 (두줄로 나눠서 표시할 수 없음)
 - # 으로 시작하는 줄은 실행하지 않는다.
 - '*'표시는 해당 필드의 모든 시간을 의미한다.
 - 3,5,7와 같이 콤마(,)로 구분하여 여러 시간대를 지정할 수 있다.
 - 2-10와 같이 하이픈(-)으로 시간 범위도 지정할 수 있다.
 - 2-10/3와 같이 하이픈(-)으로 시간 범위를 슬래쉬(/)로 시간 간격을 지정할 수 있다(2~10시까지 3시간 간격으로. 즉, 3, 6, 9시를 의미함).

crontab이란 예약된 작업을 실행하는 파일이다.
 
Posted by 암리타 :

rsync ssh를 이용한 서버 백업

원본서버 : original server
백업 서버 : backup server

기본 원리
ssh 방식으로 접속하기 위해서 백업 서버에서 키를 생성하고 생성된 키를 원본 서버에 복사를 한 다음 rsync를 ssh 방식으로 접속하여 백업을 받는 방법이다.

*주의 : 원본서버에서 키를 생성하는게 아니라 백업서버에서 키를 생성해야 한다.

백업 서버에서 일반계정이나 root로 로그인 후 키를 저장할 디렉토리를 생성한다.

[root@#backup server]# mkdir .ssh
[root@#backup server]# chmod 700 .ssh

백업 서버에서 디렉토리 생성후 키를 생성한다.

[root@#backup server]# ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:

원본 서버에서 일반계정으로 로그인하여 백업서버에서 생성한 키를 저장하기 위해 디렉토리를 생성한다.

[xxxx@#original server]# mkdir .ssh
[xxxx@#original server]# chmod 700 .ssh

다시 백업서버로 이동해서 백업서버에서 생성한 키를 원본 서버에 저장한다.

[root@#backup server]# scp -p /root/.ssh/id_dsa.pub 원본서버의 계정명@원본서버의 IP:/home/원본서버계정명/.ssh/authorized_key2
xxxx@xxx.xxx.xxx.xxx password: 계정암호 입력

이제 준비는 끝났고 백업 서버에서 rsync를 ssh로 연결하여 백업하면 끝.

[root@#backup server]# rsync -avz --delete --rsh="ssh -i /root/.ssh/id_dsa -l 원본서버계정명" 원본서버IP:원본서버의경로 백업서버의 경로
xxxx@xxx.xxx.xxx.xxx password: 원본 서버 계정 암호 입력



rsync 설명
rsync  version 2.6.8  protocol version 29
Copyright (C) 1996-2006 by Andrew Tridgell, Wayne Davison, and others.
<http://rsync.samba.org/>
Capabilities: 64-bit files, socketpairs, hard links, ACLs, xattrs, symlinks, batchfiles,
              inplace, IPv6, 64-bit system inums, 64-bit internal inums
rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.

rsync is a file transfer program capable of efficient remote update
via a fast differencing algorithm.

Usage: rsync [OPTION]... SRC [SRC]... DEST
  or   rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST
  or   rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST
  or   rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST
  or   rsync [OPTION]... [USER@]HOST:SRC [DEST]
  or   rsync [OPTION]... [USER@]HOST::SRC [DEST]
  or   rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]
The ':' usages connect via remote shell, while '::' & 'rsync://' usages connect
to an rsync daemon, and require SRC or DEST to start with a module name.

Options
 -v, --verbose               increase verbosity
 -q, --quiet                 suppress non-error messages
 -c, --checksum              skip based on checksum, not mod-time & size
 -a, --archive               archive mode; same as -rlptgoD (no -H)
     --no-OPTION             turn off an implied OPTION (e.g. --no-D)
 -r, --recursive             recurse into directories
 -R, --relative              use relative path names
     --no-implied-dirs       don't send implied dirs with --relative
 -b, --backup                make backups (see --suffix & --backup-dir)
     --backup-dir=DIR        make backups into hierarchy based in DIR
     --suffix=SUFFIX         set backup suffix (default ~ w/o --backup-dir)
 -u, --update                skip files that are newer on the receiver
     --inplace               update destination files in-place (SEE MAN PAGE)
     --append                append data onto shorter files
 -d, --dirs                  transfer directories without recursing
 -l, --links                 copy symlinks as symlinks
 -L, --copy-links            transform symlink into referent file/dir
     --copy-unsafe-links     only "unsafe" symlinks are transformed
     --safe-links            ignore symlinks that point outside the source tree
 -k, --copy-dirlinks         transform symlink to a dir into referent dir
 -K, --keep-dirlinks         treat symlinked dir on receiver as dir
 -H, --hard-links            preserve hard links
 -p, --perms                 preserve permissions
 -E, --executability         preserve the file's executability
 -A, --acls                  preserve ACLs (implies --perms)
 -X, --xattrs                preserve extended attributes (implies --perms)
     --chmod=CHMOD           change destination permissions
 -o, --owner                 preserve owner (super-user only)
 -g, --group                 preserve group
     --devices               preserve device files (super-user only)
     --specials              preserve special files
 -D                          same as --devices --specials
 -t, --times                 preserve times
 -O, --omit-dir-times        omit directories when preserving times
     --super                 receiver attempts super-user activities
 -S, --sparse                handle sparse files efficiently
 -n, --dry-run               show what would have been transferred
 -W, --whole-file            copy files whole (without rsync algorithm)
 -x, --one-file-system       don't cross filesystem boundaries
 -B, --block-size=SIZE       force a fixed checksum block-size
 -e, --rsh=COMMAND           specify the remote shell to use
     --rsync-path=PROGRAM    specify the rsync to run on the remote machine
     --existing              ignore non-existing files on receiving side
     --ignore-existing       ignore files that already exist on receiving side
     --remove-sent-files     sent files/symlinks are removed from sending side
     --del                   an alias for --delete-during
     --delete                delete files that don't exist on the sending side
     --delete-before         receiver deletes before transfer (default)
     --delete-during         receiver deletes during transfer, not before
     --delete-after          receiver deletes after transfer, not before
     --delete-excluded       also delete excluded files on the receiving side
     --ignore-errors         delete even if there are I/O errors
     --force                 force deletion of directories even if not empty
     --max-delete=NUM        don't delete more than NUM files
     --max-size=SIZE         don't transfer any file larger than SIZE
     --min-size=SIZE         don't transfer any file smaller than SIZE
     --partial               keep partially transferred files
     --partial-dir=DIR       put a partially transferred file into DIR
     --delay-updates         put all updated files into place at transfer's end
 -m, --prune-empty-dirs      prune empty directory chains from the file-list
     --numeric-ids           don't map uid/gid values by user/group name
     --timeout=TIME          set I/O timeout in seconds
 -I, --ignore-times          don't skip files that match in size and mod-time
     --size-only             skip files that match in size
     --modify-window=NUM     compare mod-times with reduced accuracy
 -T, --temp-dir=DIR          create temporary files in directory DIR
 -y, --fuzzy                 find similar file for basis if no dest file
     --compare-dest=DIR      also compare destination files relative to DIR
     --copy-dest=DIR         ... and include copies of unchanged files
     --link-dest=DIR         hardlink to files in DIR when unchanged
 -z, --compress              compress file data during the transfer
     --compress-level=NUM    explicitly set compression level
 -C, --cvs-exclude           auto-ignore files the same way CVS does
 -f, --filter=RULE           add a file-filtering RULE
 -F                          same as --filter='dir-merge /.rsync-filter'
                             repeated: --filter='- .rsync-filter'
     --exclude=PATTERN       exclude files matching PATTERN
     --exclude-from=FILE     read exclude patterns from FILE
     --include=PATTERN       don't exclude files matching PATTERN
     --include-from=FILE     read include patterns from FILE
     --files-from=FILE       read list of source-file names from FILE
 -0, --from0                 all *-from/filter files are delimited by 0s
     --address=ADDRESS       bind address for outgoing socket to daemon
     --port=PORT             specify double-colon alternate port number
     --sockopts=OPTIONS      specify custom TCP options
     --blocking-io           use blocking I/O for the remote shell
     --stats                 give some file-transfer stats
 -8, --8-bit-output          leave high-bit chars unescaped in output
 -h, --human-readable        output numbers in a human-readable format
     --progress              show progress during transfer
 -P                          same as --partial --progress
 -i, --itemize-changes       output a change-summary for all updates
     --log-format=FORMAT     output filenames using the specified format
     --password-file=FILE    read password from FILE
     --list-only             list the files instead of copying them
     --bwlimit=KBPS          limit I/O bandwidth; KBytes per second
     --write-batch=FILE      write a batched update to FILE
     --only-write-batch=FILE like --write-batch but w/o updating destination
     --read-batch=FILE       read a batched update from FILE
     --protocol=NUM          force an older protocol version to be used
 -4, --ipv4                  prefer IPv4
 -6, --ipv6                  prefer IPv6
     --version               print version number
(-h) --help                  show this help (-h works with no other options)

Use "rsync --daemon --help" to see the daemon-mode command-line options.
Please see the rsync(1) and rsyncd.conf(5) man pages for full documentation.
See http://rsync.samba.org/ for updates, bug reports, and answers

Posted by 암리타 :
CentOS 5.1 + APM(apache 2.2.x + php 5.2.x + mysql5.0.x + Zend 3.0.x) 설치

1. 다운로드

rpm으로 설치 mysql, php, httpd를 삭제

[root@localhost]# rpm -qa mysql  <--설치된 mysql이 있는지 확인
mysql-5.0.22-2.2.el5_1.1 <-- 설치되어 있음
[root@localhost]# rpm -qa httpd
[root@localhost]# rpm -qa php

rpm으로 설치된 mysql, php, httpd 가 있다면 삭제

[root@localhost]# rpm -e --nodeps mysql
[root@localhost]# rpm -e --nodeps php
[root@localhost]# rpm -e --nodeps httpd

mysql 다운로드

[root@localhost ~]# wget ftp://ftp.superuser.co.kr/mysql/mysql-5.0.37.tar.gz -P /tmp
--23:25:16--  ftp://ftp.superuser.co.kr/mysql/mysql-5.0.37.tar.gz
           => `/tmp/mysql-5.0.37.tar.gz'
Resolving ftp.superuser.co.kr... 210.127.253.100
Connecting to ftp.superuser.co.kr|210.127.253.100|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD /mysql ... done.
==> SIZE mysql-5.0.37.tar.gz ... 23239518
==> PASV ... done.    ==> RETR mysql-5.0.37.tar.gz ... done.
Length: 23239518 (22M)
100%[====================================================================================>] 23,239,518   421K/s   in 53s   
23:26:10 (425 KB/s) - `/tmp/mysql-5.0.37.tar.gz' saved [23239518]

apache 다운로드

[root@localhost ~]# wget ftp://ftp.superuser.co.kr/apache/httpd-2.2.2.tar.gz -P /tmp
--23:37:00--  ftp://ftp.superuser.co.kr/apache/httpd-2.2.2.tar.gz
           => `/tmp/httpd-2.2.2.tar.gz'
Resolving ftp.superuser.co.kr... 210.127.253.100
Connecting to ftp.superuser.co.kr|210.127.253.100|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD /apache ... done.
==> SIZE httpd-2.2.2.tar.gz ... 6282043
==> PASV ... done.    ==> RETR httpd-2.2.2.tar.gz ... done.
Length: 6282043 (6.0M)
100%[====================================================================================>] 6,282,043    519K/s   in 9.5s  
23:37:11 (642 KB/s) - `/tmp/httpd-2.2.2.tar.gz' saved [6282043]

php 다운로드

[root@localhost ~]# wget ftp://ftp.superuser.co.kr/php/php-5.2.5.tar.gz -P /tmp
--23:38:15--  ftp://ftp.superuser.co.kr/php/php-5.2.5.tar.gz
           => `/tmp/php-5.2.5.tar.gz'
Resolving ftp.superuser.co.kr... 210.127.253.100
Connecting to ftp.superuser.co.kr|210.127.253.100|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD /php ... done.
==> SIZE php-5.2.5.tar.gz ... 9972372
==> PASV ... done.    ==> RETR php-5.2.5.tar.gz ... done.
Length: 9972372 (9.5M)
100%[====================================================================================>] 9,972,372    600K/s   in 17s   
23:38:33 (578 KB/s) - `/tmp/php-5.2.5.tar.gz' saved [9972372]


zendoptimizer 다운로드

[root@localhost ~]# wget ftp://ftp.superuser.co.kr/ZendOptimizer/ZendOptimizer-3.0.1-linux-glibc21-i386.tar.gz -P /tmp
--23:40:46--  ftp://ftp.superuser.co.kr/ZendOptimizer/ZendOptimizer-3.0.1-linux-glibc21-i386.tar.gz
           => `/tmp/ZendOptimizer-3.0.1-linux-glibc21-i386.tar.gz'
Resolving ftp.superuser.co.kr... 210.127.253.100
Connecting to ftp.superuser.co.kr|210.127.253.100|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD /ZendOptimizer ... done.
==> SIZE ZendOptimizer-3.0.1-linux-glibc21-i386.tar.gz ... 6358090
==> PASV ... done.    ==> RETR ZendOptimizer-3.0.1-linux-glibc21-i386.tar.gz ... done.
Length: 6358090 (6.1M)
100%[====================================================================================>] 6,358,090    945K/s   in 6.5s  
23:40:53 (948 KB/s) - `/tmp/ZendOptimizer-3.0.1-linux-glibc21-i386.tar.gz' saved [6358090]


2. 압축풀기

[root@localhost ~]# tar xvf mysql-5.0.37.tar.gz
[root@localhost ~]# tar xvf httpd-2.2.2.tar.gz
[root@localhost ~]# tar xvf php-5.2.5.tar.gz


3. 부가 프로그램 확인 및 설치

[root@localhost ~]# rm qa gcc <-- 설치되어 있는지 확인한후 없으면 설치
yum install gcc
yum install gcc-c++
yum install termcap
yum install libtermcap
yum install libtermcap-devel
yum install gdbm-devel
yum install zlib*
yum install libxml*
yum install freetype*
yum install libpng*
yum install libjpeg*
yum install iconv


4. Mysql 설치

mysql 유저 생성 및 설치

[root@localhot mysql-5.0.37~]# useradd -M -s /bin/false mysql
[root@localhot mysql-5.0.37~]# ./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data --with-charset=utf8 --with-extra-charsets=all --enable-thread-safe-client

--enable-thread-safe-client 는 mysqli를 위한 옵션

[root@localhot mysql-5.0.37~]# make
[root@localhot mysql-5.0.37~]# make install

mysql 설정

[root@localhost mysql-5.0.37]# pwd
/tmp/mysql-5.0.37
[root@localhost mysql-5.0.37]# cp support-files/my-huge.cnf /etc/my.cnf
[root@localhost mysql-5.0.37]# cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql-5.0.37]#
[root@localhost mysql-5.0.37]# chmod 755 /etc/init.d/mysqld
[root@localhost mysql-5.0.37]# chkconfig --add mysqld
[root@localhost mysql-5.0.37]# chkconfig --list mysqld
mysqld          0:해제  1:해제  2:활성  3:활성  4:활성  5:활성  6:해제
[root@localhost mysql-5.0.37]# chkconfig --level 24 mysqld off
[root@localhost mysql-5.0.37]# chkconfig --list mysqld
mysqld          0:해제  1:해제  2:해제  3:활성  4:해제  5:활성  6:해제
[root@localhost mysql-5.0.37]# cd /usr/local/mysql/

[root@localhost mysql]# chown -R mysql .
[root@localhost mysql]# chgrp -R mysql .
[root@localhost mysql]# ./bin/mysql_install_db --user=mysql
Installing all prepared tables
Fill help tables
To start mysqld at boot time you have to copy support-files/mysql.server
to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &
You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests
Please report any problems with the /usr/local/mysql/bin/mysqlbug script!
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com

[root@localhost mysql]# chown -R mysql .
[root@localhost mysql]# chgrp -R mysql .
[root@localhost mysql]# /etc/rc.d/init.d/mysqld start
Starting MySQL[  OK  ]

[root@localhost mysql]# ./bin/mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.37-log Source distribution

mysql >
mysql > exit;

mysql 설치시 이전의 데이타가 남아 있거나, 이미 실행이 되어 있는 경우 아래와 같이 에러가 난다.

[root@localhost mysql]# ./bin/mysql -uroot
./bin/mysql: error while loading shared libraries: libmysqlclient.so.15: cannot open shared object file: No such file or directory

이런 경우에는
mysql 이 실행되어 있다면 모두 종료하고
/etc/ld.so.conf 파일에 /usr/lib/mysql 을 추가하거나, 두 줄인 경우에는 한줄을 삭제하고
/sbin/ldconfig 을 실행한다.

[root@localhost mysql]# ./bin/mysqladmin shutdown
[root@localhost mysql]# vi /etc/ld.so.conf
/usr/lib/mysql
/usr/lib/mysql <--- 삭제
[root@localhost mysql]# /sbin/ldconfig
./bin/mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.37-log Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> exit
Bye

mysql 의 root 암호를 변경한다.

[root@localhost mysql]# ./bin/mysqladmin -u root -h localhost.localdomain password '변경할 패스워드'
[root@localhost mysql]# ./bin/mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.37-log Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> delete from mysql.user where user='';  <-- 2개의 익명 계정 삭제
Query OK, 2 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>exit;
[root@localhost mysql]#


5. Apache 설치
Apache 소스가 있는 곳으로 이동하여 Apache 설치

[root@localhost httpd-2.2.2]# ./configure --prefix=/usr/local/apache --enable-modules=so --enable-so --enable-rewrite
[root@localhost httpd-2.2.2]# make
[root@localhost httpd-2.2.2]# make install

아파치 설정 파일 복사 및 시작

[root@localhost httpd-2.2.2]# cp /usr/local/apache/bin/httpd /etc/rc.d/init.d/apachectl
[root@localhost httpd-2.2.2]# /etc/rc.d/init.d/apachectl start


6. php 설치

php 소스가 있는 곳으로 이동하여 php 설치

[root@localhost php-5.2.5]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --enable-mod-charset --with-config-file-path=/usr/local/apache/conf --enable-safe-mode --enable-sigchild --enable-magic-quotes --with-libxml-dir --with-openssl --with-zlib --with-zlib-dir --with-bz2 --enable-calendar --with-curl --enable-dba --with-gdbm --enable-exif --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-ttf --with-freetype-dir --enable-gd-native-ttf --with-gettext --with-imap --with-imap-ssl --with-kerberos --enable-mbstring --with-mhash --with-mysql=/usr/local/mysql --enable-sockets --with-regex=php --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --enable-zend-multibyte
[root@localhost php-5.2.5]# make
[root@localhost php-5.2.5]# make install
[root@localhost php-5.2.5]# cp php.ini-dist /usr/local/php/lib/php.ini

php 설치시 에러가 발생하면 해당 모듈을 yum을 통해서 설치해 주면 된다.


7. ZendOptimizer 설치

zendOptimizer 소스 경로로 이동하여 설치

[root@localhost ZendOptimizer]# ./install.sh

인스톨 화면에서  안내에 따라 php.ini 파일의 경로를 설정해 주면 자동으로 zendoptimizer가 설치된다.


8. Apache 및 PHP 설정
/usr/local/apache/conf/httpd.conf 파일과 /usr/local/php/lib/php.ini 파일은 사용자에 맞게 수정한다.


개인적인 서버에 설치된 내용이므로 정상적으로 설치가 되지 않을 수 있습니다.

Posted by 암리타 :

텔넷 접속에서 한글이 깨져 보일 경우가 있다.
리눅스에서 한글이 깨질 경우가 있다면 아래와 같이 하면 된다.

아래와 같이 ls -al 을 해 보았을때 합계 부분이 깨져 보인다면

[root@localhost~]# ls -al
?⑷퀎 9792
drwxr-x---  4 root root  4096  6월 28 16:47 .
------------- 이하 생략 ----------

/etc/profile 파일에
export LANG="ko_KR.eucKR" 를 추가하면 됨.

[root@localhost ~]# ls -al
합계 156
drwxr-x---  4 root root  4096  6월 28 16:47 .
------------- 이하 생략 ----------


참고로 /etc/profile 은 시스템 로그인후 제일 먼저 적용되는 파일이며, 시스템에 적용되는 $PATH, $USER, $LOGNAME, HOSTNAME, $MAIL, $HISTSIZE, $INPUTRCE 등의 환경변수들을 설정 할수 있다.

재부팅 없이 실시간으로 변경을 할 경우에는 아래와 같이 한다.

shell> export LANG=ko_KR.eucKR


 

Posted by 암리타 :