How to speed up Apache
– Disable modules you don’t use
Every server installed comes with a set of automatically enabled modules. Usually the more modules your server tons, the slower the server can get. That is why it’s generally fantastic idea to find out which modules you truly use for your website(s) and apps and unload those you do not use. A good way to do that is to unload each and every module one at a time to find out if it affects your website or app:
1. Demand /etc/apache2/mods-enabled/ folder to discover which modules are allowed on your server.
2. Make a copy of this list so you know which modules to enable again in the event you wrongfully disable a module (you will get every available mod back the /etc/apache2/mods-available/ folder).
3. Now disable each module one by one using the sudo a2dismod module command word in SSH gain access to where in fact the module should be changed by the name of the module you want to disable.
4. Check your website every time you disable another module. No problems? Leave the module disabled. Problems? Re-enable the module by typing and executing sudo a2enmod module (replace module with name of the module you want to enable).
– Use Apache caching
Caching frequently seen documents and content can increase your server performance. One of the best Apache applications right now for this is Varnish Cache, which is completely free to use. Setting up this application in front of a Apache server can speed up delivery by a stunning 1000 times (going by their own words). Go here to install the latest release on your server and here for the documents on how to use it.
– Tune your MySQL settings for performance
By using a MySQL database there’s a great free little script which may be run in Apache called mysqltuner.pl. It can detect bottlenecks within your MySQL databases. When you run the script from the control series in Apache you can instantly see where in fact the bottlenecks occur and how you have to fix them. Then you can edit the MySQL config file (etc/mysql/my.cnf inside our case) and change the necessary values to fix the bottlenecks. Head to their website to download the script and for more information on how to create it up.
– Use a PHP accelerator
If you are using PHP for your website (which is likely) you should use a PHP caching/accelerating server application. These types of applications store the compiled script bytecode in the distributed memory to have the ability to serve it from the cache whenever website users demand it. The most commonly used right now is ZEND OPcache which is automatically installed with PHP 5.5.0 and later. Go to the website to understand how to create it up to get it working on your server.
– Decrease the amount of functions.
Sometimes, especially on smaller servers with low RAM, the server can get overloaded with way too many procedures at the same time and slows down significantly or even hangs. At these times often to your server, it’s a good idea to limit the quantity of processes to a number your server can handle. This way existing guests will be capable to quickly weight your website. The downside is that whenever the limit amount of processes are reached site visitors will get a mistake and will not be able to weight your site. But, and you’ll probably recognize, this continues to be better than creating a wesite that is incredibly slow or will suspend for an extended period of time. Follow these steps:
1. First find out how much RAM you have been available for Apache procedures. Usually, this amounts to the RAM you have left after you’ve discounted the amount you use for MySQL and other server components you utilize RAM for. As an example, we take 250mb.
2. Now run the very best command word in SSH access. In the list that comes after first find a www-data process. Once you observe one quickly look for its RES column and find out which value they have, for example: 5109 or 19m. The example value 5109 means 5.1mb and 19m for 19mb. This RES value is the quantity of RAM all single process needs.
3. Now we take the amount of RAM we have been available for Apache and we’ll divide it with the total amount every process needs. So let’s separate the example amount of 250mb of free Apache RAM and divide it with the 5.1mb example RES value, quite simply: 250 divided by 5.1 that includes a outcome around 49. This is the amount of processes the example Apache create with 250mb reserved for Apache processes can handle. If you review this limit, the server can get overloaded.
4. Now we know the quantity of processes the example create are designed for we have to change the MaxClients value in the Apache config document. We can do this by editing the /etc/apache2/apache2.conf document in SSH access. We search for the MaxClients value under the mpm_prefork_module section and change it to 49. Now the server has a limit of 49 processes. Every additional process which explains that amount will now be obstructed instead of slowing down the server. Keep in mind, the 49 value is just a good example value. You will need to discover and calculate the fitted amount for your server on your own.