MRKAVANA (mrkavana@gmail.com) - www.facebook.com/kavanathai
Showing posts with label cache. Show all posts
Showing posts with label cache. Show all posts

Aug 25, 2011

How to install and configure APC Cache on a RedHat/CentOS server?


APC cache is a PHP caching solution which stands for Alternative PHP Cache. It serves PHP pages from a cache thus helping to reduce server load. APC is an open source software and is updated from time to time.
The following are the steps to install APC cache on a CentOS server OR even on a cPanel and Plesk server. All these commands are executed via SSH as a ‘root’ user.
1) Firstly, goto a temporary directory
# cd /usr/local/src
2) Download the latest APC version
# wget http://pecl.php.net/get/APC-3.1.6.tgz
3) Unpack the version and change to the APC directory
# tar -zxf APC-3.1.6.tgz
# cd APC-*
4) Create configuration files
# phpize
5) Search for the “php-config” file since you need to configure APC with it
# which php-config
6) Now, configure APC
./configure --enable-apc --enable-apc-mmap --with-apxs \
--with-php-config=/usr/local/bin/php-config
7) Create the installation files and install APC
# make
# make install
Now that the APC cache is installed on your server, the final step is to activate the APC extension in the php.ini file. Locate the working php.ini file and edit it
# php -i | grep php.ini
Search for “extension_dir” and place the following code under it:
extension="apc.so"
apc.enabled=1
apc.shm_segments=1
apc.shm_size=256
apc.ttl=3600
apc.user_ttl=7200
apc.num_files_hint=1024
apc.mmap_file_mask=/tmp/apc.XXx
apc.enable_cli=1
Save the file and restart the Apache web server. You can tweak the APC settings by editing the above file but make sure you restart the Apache service for the new changes to take affect.
That’s it. To check if APC is activated, execute
# php -i | grep apc
Note: once APC is installed, make sure the ‘apc.so’ file is created under the directory specified at the “extension_dir” in php.ini. If not, look for the exact path of the file and create a symlink under it.

Howto: Check Memory/RAM usage in Linux


How to check Memory (RAM) usage in Linux OR different ways to check RAM usage in Linux?
Memory OR widely known as RAM is known to be one of the important component on the server which make sure the tasks performed on your server are processed fast enough. Higher the availibility of physical memory, more stable is your server during high resource usage processes.
Linux offer various tools to check Memory/RAM usage of your server such as free, top, sar, vmstat etc using which you can deside whether to optimize softwares to use less memory OR whether it’s time to upgrade memory on the server.
1) ‘free’ command: one of the easiest way to check the RAM usage:
free -m
will display physical memory as well as Swap


free -m -t
same as above but it will display the total of physical and swap memory at the bottom.


2) ‘top’ command: The top command displays the real time values of the running system and are continously updated (by default 3 seconds). The two rows “Mem and Swap” displays the total, used and free amount of RAM/Swap. Though the values displayed are in kbs and not human readable, it is just one another way to check the usage.

3) ‘sar’ command: is included in the ‘sysstat’ package and is not installed by default. To install ‘sysstat’ package, execute:
yum install sysstat
Once ‘sysstat’ package is installed, start the service
service sysstat start
sysstat package when installed, provider ‘sar’ command which collects system activity information and saves it in a file before displaying it on a standard output.
sar -r
displays Memory/Buffer/Swap information horizontally.


4) /proc/meminfo file: which displays everything about the RAM on your server.
cat /proc/meminfo

Howto: Increase RAM/Memory for Java.


In order to increase memory limit for Java, perform the following steps, edit the file:
/var/cpanel/tomcat.options
Insert the following 2 lines:
Xmx200M
Xms100M
where, Xmx is the upper limit and Xms is the lower limit. You have to replace the values as per your requirement. Save the file and restart the tomcat service:
root@server [~]#/scripts/restartsrv tomcat

Jul 22, 2011

How to clear memory cache

free -g
sudo sync && sudo sysctl -w vm.drop_caches=3 && sudo sysctl -w vm.drop_caches=0 

Or:
sync; echo 3 > /proc/sys/vm/drop_caches