Server optimizations 2
Posted by in Linuxhttp://www.alonon.net/server-optimization-errors/ after this, i found some new things to use server hardware more efficiency.
(I’m using ubuntu so that codes listed below works for only ubuntu servers.)
1. Using a Php Accelerator
I found apc. There are some such as Xcache and eAccelerator. Apc is creating php files cache. Before install it, you can test your apache performanse with ab.
ab -c5 -n100 http://www.yoursite.com/index.php
-c concurrency
Number of multiple requests to perform at a time. Default is one
request at a time.-n requests
Number of requests to perform for the benchmarking session. The
default is to just perform a single request which usually leads
to non-representative benchmarking results.
After testing you can easily install apc with typing:
sudo apt-get install php-apc
sudo service apache2 restart
Than test again.
ab -c5 -n100 http://www.yoursite.com/index.php
You can see the difference. Apc comes with a simple control script in /usr/share/doc/php-apc/apc.php.gz to use it
gunzip /usr/share/doc/php-apc/apc.php.gz
cp /usr/share/doc/php-apc/apc.php /yousites.com/apc.php
2. Enable browser caching with apache2
Firstly to check browser caching, install firebug (ff extension) http://getfirebug.com/. After that open firebug and click network tab (Net). Than refresh your web page. You can see get process for each file in your webpage (js,png,gif,ico). There is a green bar symbolizing connection. If you are using browser caching this green bar should be “0″ after second reload of page. If not
enable expires module of apache2
sudo a2enmod expires
restart apache
sudo service apache2 restart
Add this line to your .htaccess file
ExpiresActive on
ExpiresByType application/javascript “access plus 1 months”
ExpiresByType image/jpg “access plus 1 month”
ExpiresByType image/jpeg “access plus 1 month”
ExpiresByType image/gif “access plus 1 month”
ExpiresByType image/png “access plus 1 month”
ExpiresByType text/css “access plus 1 months”
access plus means access time for each visitor. Also you can use your website .conf file to use it.
You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.
