mmcache 설치 > PHP

본문 바로가기
사이트 내 전체검색

PHP

mmcache 설치

페이지 정보

profile_image
작성자 최고관리자
댓글 0건 조회 5,960회 작성일 21-02-09 11:45

본문

mmcache 설치 | 낙서장 2005/05/14 09:49 

http://blog.naver.com/guadian/20012664454

관련 주소 1 :
 Turck-MMcache 는 PHP 의 처리 속도를 높여주는 Cache 서버입니다.
나온지는 오래 되었는데 서버 이동하면서 적용해보고 필요하신분 계실까하고 몇자 적어 놓습니다.

주의 : Zend Encoder나 SAfe Gourd등으로 ENcoding된건 사용이 불가능 합니다.

현재는 개발이 Sleep 상태이고, 핵심개발자분인 Zend 사로 스카웃 당했? 다는 것 같더군요.
최종 버전 당시 Zend Performance 보다 높은 성능을 내니.누가 돈내고 Zend Performance를 사겠습니까?

http://turck-mmcache.sourceforge.net/index_old.html

위 링크를 보시면 비교치가 있으니 확인 요망


* 다운로드 *

http://sourceforge.net/project/showfiles.php?group_id=69426

 * 설치 *

일단 다운 받은 파일을 적당한 위치로 옮겨 놓고 압축을 해제 합니다.
현재 필요한 라이브러리는 autoconf, automake, libtool, m4 이 필요합니다.
Linux 이신분은 해당사항이 없으면 , BSD나 SunOS같은 경우 기본 설치가 아니니 따로 설치요망

 압축 해제 한곳으로 이동하여 , PHP가 설치되어 있는 곳의 bin 디렉토리 안의 phpize 를 실행 합니다.



인용 또는 결과 :

 [root@stealth SERVER_SRC]# tar xvzf turck-mmcache-2.4.6.tar.gz 
 [root@stealth SERVER_SRC]# cd turck-mmcache-2.4.6
 [root@stealth turck-mmcache-2.4.6]# 
 [root@stealth turck-mmcache-2.4.6]# /usr/local/php4/bin/phpize <-- AutoConf 를 해준다고 생각 하시면 됩니다.
Configuring for:
  PHP Api Version:  20020918
  Zend Module Api No:  20020429
  Zend Extension Api No:  20021010

 [root@stealth turck-mmcache-2.4.6]# ./configure --enable-mmcache=shared --with-php-config=/usr/local/php4/bin/php-config 
 [root@stealth turck-mmcache-2.4.6]# make

 [root@good /root]$ _


자 위 단계별로 진행하고 ./configure 을 하고 나면 별 에러가 없으실겁니다
 만약에 아래와 같은 에러가 나신다면 버전이 높거나(php5) PHP컴파일시 VERSION관련 부분을 삭제 하셨을경우


 인용 또는 결과 :

 /developer/SERVER_SRC/turck-mmcache-2.4.6/mmcache.c:908:25: operator '>' has no left operand
 make: *** [mmcache.lo] 오류 1

 [root@good /root]$ _


그렇다고 버전을 낮추시거나 하시지는 마십시요.
mmcache.c 파일의 908번 줄 라인에는 아래와 같은 내용이 있는데 그냥 삭제


 인용 또는 결과 :

 #if defined(PHP_MAJOR_VERSION) && defined(PHP_MINOR_VERSION) && \
    ((PHP_MAJOR_VERSION > 4) || (PHP_MAJOR_VERSION == 4 && PHP_MINOR_VERSION > 1))
     
그리고 6550 라인의 아래 내용도 삭제

#endif  /* #ifdef HAVE_MMCACHE */

 [root@good /root]$ _

     
위와 같이 진행하면 설치가 잘됩니다. 약간은 무식한 방법입니다...


인용 또는 결과 :

 [root@stealth turck-mmcache-2.4.6]# make ; make install

 Build complete.
 (It is safe to ignore warnings about tempnam and tmpnam).
 Installing shared extensions:    /usr/local/php4/lib/php/extensions/no-debug-non-zts-20020429/

 [root@good /root]$ _


위처럼 나오게 됩니다. mmcache의 extention Module이 위 위치에 복사되어 있다는 확인 창입니다.
이제 셋팅.!~

PHP.ini 설치 위치에 아래와 같은 설정 파일을 추가 하시면 됩니다.
단.! Zend Optimize나 Performance 같은 모듈을 주석 처리를 하시거나 지우셔야 서로간의 간섭으로 인한
 에러를 막을수 있습니다.


인용 또는 결과 :

zend_extension="/usr/local/php4/lib/php/extensions/no-debug-non-zts-20020429/mmcache.so"
 mmcache.shm_size="16" <-- 캐쉬데이타를 공유할 공유메모리 MB
 mmcache.cache_dir="/tmp/mmcache" <-- 캐슁 파일을 저장할 위치 , 반드시 웹서버 계정과 그룹이 R,W가 되도록 퍼미션 조절이 되어합
 니다.
mmcache.enable="1" <-- MMCACHE를 쓸것이냐 말것이냐 , 1은 On , 0은 Off
 mmcache.optimizer="1" <-- 최적화 여부입니다. 코드 파싱속도를 빠르게 하기위해 인코딩 과정을 합니다. Cache 디렉토리에 보시면 아실
 겁니다.
mmcache.check_mtime="1" <-- PHP 원본 프로그램의 최종 수정일자를 검사해 바뀌었으면 캐쉬파일을 갱신하도록 한다.
mmcache.debug="0" <-- 디버깅 모드
mmcache.filter="" <-- 특정한 확장자만 Cache하고 싶을때 , *.php *.html *.htm 식으로 넣으시면 됩니다.
mmcache.shm_max="0" <-- 공유 메모리 사용 최대 Byte 단위므로 1M 또는 10K , 1024 식으로 넣으시면 됩니다.
mmcache.shm_ttl="0" <-- 공유 메모리에 캐쉬 파일에 일정 시간이상 접근이 없으면 삭제하게 끔하는역활 0은 Disable
 mmcache.shm_prune_period="0" 
 mmcache.shm_only="0" <-- 0은 하드 디스크에 캐쉬 파일 넣고 , 공유 메모리에 같이 넣어 사용하나 1로 설정하면 공유메모리만 사용
mmcache.compress="1" <-- mod_gzip처럼 압축할것이냐.여부

[root@good /root]$ _


저장후 웹서버를 리로딩하신후

phpinfo(); 를 통해 화면에 보시면
Zend Optimize 설치 할때 확인 하는 부분에


 인용 또는 결과 :

This program makes use of the Zend Scripting Language Engine:
 Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies with Turck MMCache v2.4.6, Copyright (c) 2002-2003 TurckSoft, St. 
 Petersburg, by Dmitry Stogov 

 [root@good /root]$ _


위와 같아 나오면 OK.!

----------자 부수적인것 --------------

Zend사에서도 약간은 움찔 할만한 툴을 추가로 제공합니다.


웹 관리 툴 : mmcache.php

간단하지만 간략하게 캐쉬 정보나 간단한 조작을 할수 있으면 압축 해제한 폴더안레 mmcache.php파일이 그역활을 합니다.
만약에 접근 패스워드를 걸고 싶으면


 인용 또는 결과 :

 [root@stealth turck-mmcache-2.4.6]# /usr/local/php4/bin/php -q mmcache_password.php 
 Changing password for Turck MMCache Web Interface (mmcache.php)

 Enter admin name: admin <-- 아이디
New admin password: 123456 <-- 패스워드
Retype new admin password: 123456 <-- 패스워드

Add the following lines into your php.ini and restart HTTPD

 mmcache.admin.name="admin"
 mmcache.admin.password="{BODY}$XbBUX97Y$I3wb9dsJnOIIRfzLPGikD/"

 [root@good /root]$ _


위처럼 하신후에


 인용 또는 결과 :

mmcache.admin.name="admin"
 mmcache.admin.password="{BODY}$XbBUX97Y$I3wb9dsJnOIIRfzLPGikD/"

 [root@good /root]$ _


위 두줄을 php.ini에 추가 하면 됩니다.

Encoder : encode.php

 Zend사의 Encoder나 Safe Gaurd 정도로 소스를 감출수 있는 역활을 합니다.


- 단일 소스 파일 인코딩 방법 - 

인용 또는 결과 :

 [root@stealth turck-mmcache-2.4.6]# /usr/local/php4/bin/php -q encoder.php -f 원본소스 -o 인코딩된소스

[root@good /root]$ _


- 디렉토리내 모든 파일 인코딩 방법 -

인용 또는 결과 :

 [root@stealth turck-mmcache-2.4.6]# /usr/local/php4/bin/php -q encoder.php -rcf 원본소스디렉토리 -o 인코딩된소스디렉토리

[root@good /root]$ _


API 등

 모듈이 로딩되면서 몇가지 내장함수를 지원하며 , 상황에 따라 이용하면 좋은 결과를 내실수 있을실것 같습니다.

mmcache_put($key, $value, $ttl=0) 
 puts the $value into shard memory for $ttl seconds.


 mmcache_get($key) 
 returns the value from shared memory which was stored by mmcache_put() or null if it is not exists or was expired.


 mmcache_rm($key) 
 removres the $key from shared memory


 mmcache_gc() 
 removes all expired keys from shared memory


 mmcache_lock($lock) 
 creates a lock with specified name. The lock can be released by function mmcache_unlock() or automatic on the end of request. For Example: 

소스코드 :

 <?php
  mmcache_lock("count");
  mmcache_put("count",mmcache_get("count")+1));
 ?>



 mmcache_unlock($lock) 
 release lock with specified name


 mmcache_set_session_handlers() 
 install the MMCache session handlers. Since PHP 4.2.0 you can install MMCache session handlers in "php.ini" by "session.save_handler=mmcache".


 mmcache_cache_output($key, $eval_code, $ttl=0) 
 caches the output of $eval_code in shared memory for $ttl seconds. Output can be removed from cache by calling mmcach_rm() with the same $key. For Example: 

소스코드 :

 <?php mmcache_cache_output('test', 'echo time(); phpinfo();', 30); ?>



 mmcache_cache_result($key, $eval_code, $ttl=0) 
 caches the result of $eval_code in shared memory for $ttl seconds. Result can be removed from cache by calling mmcach_rm() with the same $key. For Example: 

소스코드 :

 <?php mmcache_cache_output('test', 'time()." Hello";', 30); ?>



 mmcache_cache_page($key, $ttl=0) 
 caches the full page for $ttl seconds. For Example: 

소스코드 :

 <?php 
  mmcache_cache_page($_SERVER['PHP_SELF'].'?GET='.serialize($_GET), 30); 
  echo time();
  phpinfo();
 ?>



 mmcache_rm_page($key) 
 removes the page which was cached by mmcache_cache_page() with the same $key from cache


 mmcache_encode($filename) 
 returns the encoded bytecode of compiled file $filename


 mmcache_load($code) 
 loads <script> which was encoded by mmcache_encode()
 




출처 : http://www.openphp.com/board/board_center?Type=View&tb_name=board_php_tip&id=88&start=0

댓글목록

등록된 댓글이 없습니다.

회원로그인

회원가입

  • 게시물이 없습니다.

접속자집계

오늘
2,109
어제
4,039
최대
6,642
전체
830,624
contact : webmaster@beautipia.co.kr
Copyright © beautipia.co.kr. All rights reserved.