ABHIONLINUX
Site useful for linux administration and web hosting

2009/11/24

How to set quota on /tmp/eaccelerator

You may have tmpwatch on your system. The cron for that is run daily:

vi /etc/cron.daily/tmpwatch

In there, you can set the max amount of hours for keeping an old file. Lowering this, will clear out all your old cache files.

Another way, is to run a command like below in the tmp folder:

find eaccelerator -mtime +30 -exec rm {} \;

It will clear out any eacceletator files older than 30 days. Use that command carefully though

---------------------------------

Then write yourself a script and run it hourly from cron.

#!shell
#
check disk usage of directory
if (usage > a number)
delete files
fi
------------------------------
tmpwatch --mtime --all 336 /tmp/eaccelerator

What is eAccelerator?

eAccelerator is a further development from mmcache PHP Accelerator & Encoder. It increases performance of PHP scripts by caching them in compiled state, so that the overhead of compiling is almost completely eliminated.

Installing eAcceleration in Debian

First you need to download php4-dev package which we need to compile eAccelerator

#apt-get install php4-dev

Download eAccelerator source package from here to /root folder and extract it

#tar jxvf eaccelerator-0.9.4.tar.bz2

#cd eaccelerator-0.9.4

Running phpize creates config file which is needed in make.

#/usr/bin/phpize

#./configure --enable-eaccelerator=shared --with-php-config=/usr/bin/php-config

#make

#make install

After this installation completed.

Edit file /etc/php4/apache2/php.ini and add following lines:

extension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

Create temporary folder to eAccelerator

#mkdir /tmp/eaccelerator

#chmod 0777 /tmp/eaccelerator

Restart apache and you're finished with the eAccelerator configuration

#/etc/init.d/apache2 restart

Testing Your installation

Create test.php file with following lines on it:



If you have eAccelerator info shown on that page, accelerator is working