Tuesday, June 17, 2008

Install Turck MMCache

Turck MMCache is a free open source PHP accelerator, optimizer, encoder and dynamic content cache for PHP. It increases performance of PHP scripts by caching them in compiled state, so that the overhead of compiling is almost completely eliminated. Also it uses some optimizations to speed up execution of PHP scripts. Turck MMCache typically reduces server load and increases the speed of your PHP code by 1-10 times.

Following are the steps to install Turck MMCache on Linux Machine

1. Login to your server as root via SSH

2. Type: cd /

3. Type: mkdir mmcache

4. Type: cd mmcache

5. Download Turck MMCache tar from http://tinyurl.com/5c32sq using wget

6. Type: tar -xvzf turck-mmcache-.tar.gz

7. Type: cd turck-mmcache-

8. Type: export PHP_PREFIX="/usr"
OR
export PHP_PREFIX="/usr/local"
This depends on where PHP is installed


9. Type: $PHP_PREFIX/bin/phpize

10. Type: ./configure --enable-mmcache=shared --with-php-config=$PHP_PREFIX/bin/php-config

11. Type: make

12. Type: make install

13. Edit PHP.INI File (One of the below will work - if one is emtpy then use the other file)
Type: pico -w /etc/php.ini
or
Type: pico -w /usr/local/lib/php.ini

14. Find this:

;Windows Extensions

Above this line comment out the PHPA or the ZEND lines if they are there.
Replace them with the following:

For ZEND:
zend_extension="/mmcache/turck-mmcache-2.4.6/modules/mmcache.so"
mmcache.shm_size="16"
#^-This is the folder limit (16mb), you can make it larger if you wish.
mmcache.cache_dir="/home/mmcache"
mmcache.enable="1"
mmcache.optimizer="1"
mmcache.check_mtime="1"
mmcache.debug="0"
mmcache.filter=""
mmcache.shm_max="0"
mmcache.shm_ttl="0"
mmcache.shm_prune_period="0"
mmcache.shm_only="0"
mmcache.compress="1"

OR for PHP Extensions
extension="/mmcache/turck-mmcache-2.4.6/modules/mmcache.so"
mmcache.shm_size="16"
mmcache.cache_dir="/home/mmcache"
mmcache.enable="1"
mmcache.optimizer="1"
mmcache.check_mtime="1"

mmcache.debug="0"
mmcache.filter=""
mmcache.shm_max="0"
mmcache.shm_ttl="0"
mmcache.shm_prune_period="0"
mmcache.shm_only="0"
mmcache.compress="1"

15. Now we need to create a cache directory.

16. Type: mkdir /home/mmcache

17. Type: chmod 0777 /home/mmcache

18. Restart Apache
Type: service httpd restart

19. Done - A list of supported scripts.
MMCache support enabled
Caching Enabled true
Optimizer Enabled true
Memory Size 33,554,392 Bytes
Memory Available 23,737,176 Bytes
Memory Allocated 9,817,216 Bytes
Cached Scripts 110
Removed Scripts 0
Cached Keys 0

NOTE:When you upgrade PHP you need to completely re-install MMCache. You need to delete the whole directory, and re-install.

0 comments: