eaccelerator°²×°ÅaÖÃPHP¼ÓËÙ
eAccelerator¼o½e
eAcceleratorÊÇÒ»¸oµÄÃaÑ¡¢¿ªÔ´µÄPHPÄ£¿e£¬ËuÄܹ»ÎªÌa¹(C)PHP¼ÓËÙ¡¢ÓÅ»¯¡¢¼ÓÂe¡¢ºÍ¶¯Ì¬ÄÚÈÝ»º´ae¹¦ÄÜ¡£Ëuͨ¹ý´ae´¢PHP½Å±¾±aÒeºoµÄ״̬¶ø¼Ó¿iÖ´ÐÐPHP½Å±¾µÄËٶȣ¬¶ø²»ÐeҪƵ±µÄ±aÒeÕa¸oPHP½Å±¾¡£¶øÇÒËuÄÜÓÅ»¯PHP½Å±¾£¬ÒÔÌa¸ßÖ´ÐÐPHPµÄËٶȡ£eAcceleratorÌØÉ«ÊǼoÉÙÁËþÎñÆ÷¸ºÔØ¡¢Ê¹PHP½Å±¾¼ÓËÙ1-10±¶¡£
ÏÂÔصØÖ£ºhttp://sourceforge.net/projects/eaccelerator/
½aѹÐÞ¸ÄÔ´´uÂe£¨½a¾o³oÏÖopen_basedirµÈ±¨´i£(C)
# tar jxvf eaccelerator-0.9.6.tar.bz2
# cd eaccelerator-0.9.6/
# vi eaccelerator.c
ÕÒµ½ÒÔÏ£º
if (PG(open_basedir) && php_check_open_basedir(realname TSRMLS_CC)) {
¸ÄΪ
if (PG(open_basedir) && php_check_open_basedir(file_handle->filename TSRMLS_CC)) {
±aÒe°²×°À(C)Õ¹eaccelerator
# /usr/local/php-5.2.14/bin/phpize # ¶ÔÓ¦Äa×Ô¼ºµÄphpize,Ò»¶¨ÒªÔÚeaccelerator-0.9.6Ŀ¼ִÐÐ
# ./configure
¨Cenable-eaccelerator \
¨Cwith-php-config=/usr/local/php-5.2.14/bin/php-config
# make
# make install # »aÌaʾÄaÀ(C)Õ¹×°µ½ÁËÄĸoĿ¼£¬ÎÒÕa±ßÊÇ/usr/local/php-5.2.14/lib/php/extensions/no-debug-non-zts-20060613/
ÅaÖÃphp.ini
Èç¹u±¾»u֮ǰÓмӹýÀ(C)Õ¹,Ö±½ÓÌøµ½ÏÂÒ»²½¡°Ìi¼ÓeaccleratorÀ(C)Õ¹¡±
Vi /usr/local/php-5.2.14/etc/php.ini
½«
extension_dir = ./
Ìae»»³É
extension_dir=/usr/local/php-5.2.14/lib/php/extensions/no-debug-non-zts-20060613/
Ìi¼ÓeaccleratorÀ(C)Õ¹
# vi /usr/local/php-5.2.14/etc/php.ini
Ôo¼ÓÈçÏÂÄÚÈÝ
[eaccelerator]
extension=eaccelerator.so
eaccelerator.shm_size=¡±16¡a
eaccelerator.cache_dir=¡±/tmp/eaccelerator¡±
eaccelerator.enable=¡±1¡a
eaccelerator.optimizer=¡±1¡a
eaccelerator.check_mtime=¡±1¡a
eaccelerator.debug=¡±0¡a
eaccelerator.filter=¡±¡±
eaccelerator.shm_max=¡±0¡a
eaccelerator.shm_ttl=¡±0¡a
eaccelerator.shm_prune_period=¡±0¡a
eaccelerator.shm_only=¡±0¡a
eaccelerator.compress=¡±1¡a
eaccelerator.compress_level=¡±9¡a
´´½¨eacceleratorĿ¼
# mkdir /tmp /eaccelerator
# chmod 777 /tmp/eaccelerator
ÖØÆo²aÊÔ
ÖØÆoapache»oÕßnginx£¬²¢ÇÒ²e¿´Ð§¹u£¬Èç¹u/tmp/eacceleratorÏÂÓÐĿ¼,˵Ã÷°²×°³É¹¦ÁË¡£
ÅaÖòÎÊýÏe½a(eaccelerator)
eaccelerator.shm_size=¡±8¡a
eAccelerator ¿ÉÒÔʹÓõĹ²ÏiÄÚ´aeµÄÊýÁ¿ (ÒÔÕ×Ϊµ¥Î») . ¡°0¡± ÊÇÖ¸²Ù×÷ϵͳµÄĬÈÏÖµ. ĬÈÏÖµÊÇ ¡°0¡±.¿É¸u¾Ý*þÎñÆ÷µÄʵ¼ÊÇe¿oÀ´µ÷Õu£¬8£¬16£¬32£¬64£¬128¶¼ÊÇ¿ÉÒԵġ£
eaccelerator.cache_dir=¡±/tmp/eaccelerator ¡±
Õa¸oĿ¼ÊǸø´ÅÅÌ»º´aeʹÓÃ. eAccelerator ÔÚÕaÀi´¢´aeÔ¤ÏȱaÒeºÃµÄ´uÂe, ½ø³ÌÊý¾Ý, ÄÚÈÝÒÔ¼°Óû§µÄ×Ô¶¨ÒaÄÚÈÝ. ͬÑuµÄÊý¾ÝÒ²Äܱ»´¢´aeÔÚ¹²ÏiÄÚ´aeÖÐ (ÕaÑu¿ÉÒÔÌa¸ß*ÃÎÊËÙ¶È). ĬÈϵÄÉeÖÃÊÇ ¡°/tmp/eaccelerator¡±.
eaccelerator.enable=¡±1¡a
¿ªÆo»o¹Ø±Õ eAccelerator¡£¡°1¡± Ϊ¿ªÆo£¬¡°0¡± Ϊ¹Ø±Õ¡£Ä¬ÈÏֵΪ ¡°1¡±¡£
eaccelerator.optimizer=¡±1¡a
Æo»o¹Ø±ÕÄÚ²¿ÓÅ»¯Æ÷£¬¿ÉÒÔÌaÉý´uÂeÖ´ÐÐËٶȡ£¡°1¡± Ϊ¿ªÆo£¬¡°0¡± Ϊ¹Ø±Õ¡£Ä¬ÈÏֵΪ ¡°1¡±¡£
eaccelerator.check_mtime=¡±1¡a
´o¿ª»oÕß¹Ø±Õ PHP µÄÎļþÐ޸ļi²e. ¡°1¡± ÊÇÖ¸´o¿ª, ¡°0¡± ÊÇÖ¸¹Ø±Õ. Èç¹uÄuÔÚÐÞ¸ÄÒÔºoÖØбaÒe PHP µÄÎļþ,ÄÇôÄuÓ¦µ±ÉeÖÃΪ ¡°1¡±. ĬÈÏÖµÊÇ ¡°1¡±.
eaccelerator.debug=¡±0¡a
¿ªÆo»o¹Ø±Õµ÷ÊÔÈÕÖ¾¼Ç¼¡£¡°1¡± Ϊ¿ªÆo£¬¡°0¡± Ϊ¹Ø±Õ¡£Ä¬ÈÏֵΪ ¡°0¡±¡£»a½«»º´aeÃuÖеüǼдÈeÈÕÖ¾¡£
eaccelerator.filter=¡±¡±
ÅжÏÄÄÐ(C) PHP Îļþ±ØÐe»º´ae¡£Äu¿ÉÒÔÖ¸¶¨»º´aeºÍ²»»º´aeµÄÎļþÀaÐÍ£¨Èç ¡°.php .phtml¡±µÈ£(C),Èç¹u²ÎÊýÒÔ ¡°!¡± ¿ªÍ*£¬ÔoÆ¥ÅaÕaÐ(C)²ÎÊýµÄÎļþ±»ºoÂÔ»º´ae¡£Ä¬ÈÏֵΪ ¡°¡±£¬¼´£¬ËuÓÐ PHP Îļþ¶¼½«±»»º´ae¡£
eaccelerator.shm_max=¡±0¡a
µ±Ê¹Óà ¡± eaccelerator_put() ¡± º¯Êýʱ½uÖ¹ÆaÏo¹²ÏiÄÚ´aeÖдae´¢¹ý´oµÄÎļþ¡£¸Ã²ÎÊýÖ¸¶¨ÔÊÐi´ae´¢µÄ×i´oÖµ£¬µ¥Î»£º×Ö½Ú (10240, 10K, 1M)¡£¡°0¡± Ϊ²»ÏÞÖÆ¡£Ä¬ÈÏֵΪ ¡°0¡±¡£
eaccelerator.shm_ttl=¡±0¡a
µ±eAccelerator »ñȡнű¾µÄ¹²ÏiÄÚ´ae´oСʧ°Üʱ£¬Ëu½«´Ó¹²ÏiÄÚ´aeÖÐɾ³ýËuÓÐÔÚ×iºo ¡°shm_ttl¡± ÃeÄÚûÓдaeÈ¡µÄ½Å±¾»º´ae¡£Ä¬ÈÏֵΪ ¡°0¡±£¬¼´£º²»´Ó¹²ÏiÄÚ´ºÖÐɾ³ýÈκλº´aeÎļþ¡£
eaccelerator.shm_prune_period=¡±0¡a
µ±eAccelerator »ñȡнű¾µÄ¹²ÏiÄÚ´ae´oСʧ°Üʱ£¬Ëu½«ÊÔͼ´Ó¹²ÏiÄÚ´aeÖÐɾ³ýÔçÓÚ¡°shm_prune_period¡± ÃeµÄ»º´ae½Å±¾¡£Ä¬ÈÏֵΪ ¡°0¡±£¬¼´£º²»´Ó¹²ÏiÄÚ´ºÖÐɾ³ýÈκλº´aeÎļþ¡£
eaccelerator.shm_only=¡±0¡a
ÔÊÐi»o½uÖ¹½«ÒѱaÒe½Å±¾»º´aeÔÚ´ÅÅÌÉÏ¡£¸ÃÑ¡Ïi¶Ô session Êý¾ÝºÍÄÚÈÝ»º´aeÎÞЧ¡£Ä¬ÈÏֵΪ ¡°0¡±£¬¼´£ºÊ¹ÓôÅÅ̺͹²ÏiÄÚ´ae½øÐлº´ae¡£
eaccelerator.compress=¡±1¡a
ÔÊÐi»o½uֹѹËoÄÚÈÝ»º´ae¡£Ä¬ÈÏֵΪ ¡°1¡±£¬¼´£ºÔÊÐiѹËo¡£
eaccelerator.compress_level=¡±9¡a
Ö¸¶¨ÄÚÈÝ»º´aeµÄѹËoµÈ¼¶¡£Ä¬ÈÏֵΪ ¡°9¡±£¬Îª×i¸ßµÈ¼¶¡£
eaccelerator.keys = ¡°disk_only¡±
eaccelerator.session = ¡°disk_only¡±
eaccelerator.content = ¡°disk_only¡±
ÉeÖÃÄÚÈÝ»º´aeµÄ´aeŵĵؽ£¬¿ÉÒÔÉeÖÃΪ£º
PHPÀ(C)Õ¹xcache°²×°
xcacheÄ£¿e¿ÉÒÔ»º´aephpÔËÐÐʱ±aÒeÉu³ÉµÄopcode¿ÉÒÔ¼ÓËÙphp³ÌÐoµÄЧÂÊ£¬°²×°xcacheºÍ°²×°memcache½¨ÀaËÆ£¬¶¼ÊÇÒÔÀ(C)Õ¹µÄ½Ê½°²×°£¬PHPÈκÎÀ(C)Õ¹½*¨»u±¾É϶¼ÊÇÈçÏ£¬ËuÒÔ²»ÐeÒªÌØÒaÈ¥ÕÒxxxÀ(C)Õ¹µÄÎĵµ.
°²×°PHPÀ(C)Õ¹xcache
# wget http://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz
# tar -xvf xcache-3.2.0.tar.gz
# cd xcache-3.2.0
# ./configure ¨Cwith-php-config=/usr/local/php/bin/php-config ¨Cenable-xcache
# make && make install
»aÉu³ÉÀaËÆÈçÏÂÐÅÏ¢
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
ËuÓеÄÄ£¿e¶¼»aÉu³Éµ½Õa¸oĿ¼ÏÂ
±a¼phpÅaÖÃÎļþ
# vim /usr/local/php/etc/php.ini
extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/xcache.so
ÖØÔØPHP
# service php-fpm reload
Èç¹uÊÇÄaApache+PHPģʽ£¬ÄÇôÖØÆoApache¼´¿É.
# service httpd restart
»oÕß
# /usr/local/apache-2.2.27/bin/apachectl restart
²aÊÔ½a¹u