If your server has been a little slow lately, and you're using PHP extensively, you should try installing a PHP accelerator before deciding to get yourself some new hardware.
After I installed an accelerator my load went from 10 (peak times) to 0.1. Quite the decrease.
I must say that this will help you most if you are using a complex piece of code on your server; code with lots of includes, and things like that.
There are a few accelerators available, the most popular ones are:
1) eAccelerator: PHP Accelerator, optimizer, dynamic content cache - Trac
2) PECL :: Package :: APC
3) XCache - Trac
4) Zend Platform / Products / Zend.com (commercial)
I myself use eaccelerator, but all of them have a pretty similar performance.
If you don't know if you already have an accelerator, there is a simple test for this. (Especially if you are on a shared host, this might be the case)
Create a new document "acceleratorcheck.php" and type in it "<?php phpinfo(); ?>" Now go to that page and see if you find any mention of eaccelerator, apc, xcache, etc.. Alternatively you could check your php.ini file and see if any of those extensions are loaded, but this amount to the same thing.
How can you install it?
You'll need access to SSH, if you don't have it, get it. If you are on a shared host, ask your provider to install a PHP accelerator.
You could also wait until PHP6 is released, since the PHP developers will then include one by default, though you'll still have to enable it yourself (via a simple setting).
Installation instructions:
eAccelerator: InstallFromSource - eAccelerator: PHP Accelerator, optimizer, dynamic content cache - Trac
Just follow those instructions, it's pretty easy. I would recommend you use the default settings (step 3) and don't change them unless you know what you're doing.
There is one setting in particular: eaccelerator.check_mtime="1" that you have to be careful about. If you disable this, your files will no longer be checked to see if they have been updated. This ofcourse will increase your PHP performance (1 less check per included file) but if you update your site, don't forget to empty the eaccelerator cache. It's best if you leave it at the default value of ="1".
Others:
XCache: InstallFromSource - XCache - Trac
APC: HOW-TO: Install APC Cache (alternative to Turck Mmcache/Eaccelerator) - vBulletin Community Forum
Note: After you have installed this, it's best that you disable the extension before you upgrade to another version of php or apache (if you were to do so), and always check the site to see if they support that newest version of PHP already. If your server fails to respond after the upgrade, it is often the php accelerator that is the reason. To see if it is, simply disable the extension in php.ini (put ';' before all the lines) and restart your server again.
You can normally restart your server with:
/usr/local/apache/bin/apachectl restart and you can test your configuration with /usr/local/apache/bin/apachectl configtest
After I installed an accelerator my load went from 10 (peak times) to 0.1. Quite the decrease.
I must say that this will help you most if you are using a complex piece of code on your server; code with lots of includes, and things like that.
There are a few accelerators available, the most popular ones are:
1) eAccelerator: PHP Accelerator, optimizer, dynamic content cache - Trac
2) PECL :: Package :: APC
3) XCache - Trac
4) Zend Platform / Products / Zend.com (commercial)
I myself use eaccelerator, but all of them have a pretty similar performance.
If you don't know if you already have an accelerator, there is a simple test for this. (Especially if you are on a shared host, this might be the case)
Create a new document "acceleratorcheck.php" and type in it "<?php phpinfo(); ?>" Now go to that page and see if you find any mention of eaccelerator, apc, xcache, etc.. Alternatively you could check your php.ini file and see if any of those extensions are loaded, but this amount to the same thing.
How can you install it?
You'll need access to SSH, if you don't have it, get it. If you are on a shared host, ask your provider to install a PHP accelerator.
You could also wait until PHP6 is released, since the PHP developers will then include one by default, though you'll still have to enable it yourself (via a simple setting).
Installation instructions:
eAccelerator: InstallFromSource - eAccelerator: PHP Accelerator, optimizer, dynamic content cache - Trac
Just follow those instructions, it's pretty easy. I would recommend you use the default settings (step 3) and don't change them unless you know what you're doing.
There is one setting in particular: eaccelerator.check_mtime="1" that you have to be careful about. If you disable this, your files will no longer be checked to see if they have been updated. This ofcourse will increase your PHP performance (1 less check per included file) but if you update your site, don't forget to empty the eaccelerator cache. It's best if you leave it at the default value of ="1".
Others:
XCache: InstallFromSource - XCache - Trac
APC: HOW-TO: Install APC Cache (alternative to Turck Mmcache/Eaccelerator) - vBulletin Community Forum
Note: After you have installed this, it's best that you disable the extension before you upgrade to another version of php or apache (if you were to do so), and always check the site to see if they support that newest version of PHP already. If your server fails to respond after the upgrade, it is often the php accelerator that is the reason. To see if it is, simply disable the extension in php.ini (put ';' before all the lines) and restart your server again.
You can normally restart your server with:
/usr/local/apache/bin/apachectl restart and you can test your configuration with /usr/local/apache/bin/apachectl configtest