How to Tweak the Performance of your LAMP Stack VPS or Dedicated Server


The LAMP Stack is by far the most popular webstack used by small/medium websites. Learn now to improve the performance of your LAMP (Linux, Apache, MySQL, PHP) Stack with these 6 easy to complete optimizations.

What is a LAMP Stack?

The standard LAMP Stack is the most popular and most used architecture on the web. Content management systems (CMS) like WordPress, Joomla and Drupal are written with LAMP in mind.

If you’re using a popular CMS, then you’re probably using a LAMP stack on your VPS or Dedicated Server.

  • LAMP stack is also free
  • Uses open-source software
  • And works on commodity hardware.

But LAMP default settings are not always best…

Servers running a Linux LAMP Stack need fine-tuning to optimize their performance.

How to speed up your LAMP Stack server

1. Use Opcode Cache for PHP

Nobody likes a person that repeats himself over and over again, as it wastes time. The same is true of servers.

Opcode caching, aka  PHP acceleration, caches the results of PHP code compilation. So next time the PHP is called on, it can simply load from a cache, thus speed up processing.

This is probably the easiest way to optimize the performance of any PHP-based application.

Which PHP Caching to use?: Zend Opcache, APC, XCache, Memcache and eAccelerator are all excellent PHP caches which are all supported under our server performance optimisation service.

2. Disable unwanted Apache modules

Apache is popular because it’s stable, well-supported and open source. The robust web server has many features and modules. Apache comes with many of these modules enabled by default. And each of these consumes CPU and memory.

But why waste a resource if you’re not using that feature?

To increase your Apache webserver’s performance remove unwanted modules/features, and reduce unnecessary overhead.

However, keep it in mind that Apache modules can have shared dependencies, and uninstalling those dependencies can have repercussions.

There is no default list for “unneeded modules” and your needs may differ from the next person. So you must be careful!

Don’t just follow a random guide on a blog you found on Google, or your server may quit working! This second step requires research.

3. Use Apache mod_deflate HTTP compression

Want to learn another easy Apache performance tuning tip?

Enable HTML compression using “mod_deflate” to boost page load speed.

This Apache module compresses text, HTML, and XML files by around 70% of their actual size.

All modern-day browsers accept compressed content, and it helps you save server bandwidth.

Note:: Outdated browsers may have trouble with compressed content.

4. Use Apache mod_expires caching

Adding an “expires headers” using “mod_expires” will prevent re-download of non-expired content by site visitors, and load certain data from their local browser cache, thus speeding up load times.

Cacheable files include CSS, JavaScript, and images.

5. PHP.ini performance tuning

A few tweaks to the php.ini file can improve your LAMP Stack’s performance significantly!

The php.ini file is the default configuration file for PHP is is read when PHP starts up. One of the easiest methods to improve PHP performance is to increase the default memory limit specified in your php.ini file.

The parameter “memory_limit” refers to the maximum amount of primary memory (in megabytes) a script is allowed to consume.

Pro Tip: Anything less than or equal to 32 MB is on the lower side for any website with a decent volume of traffic. Increase this to either 64 MB or 128 MB, depending on the amount of physical memory available on the server.

Consider enabling HTML compression and output buffering in the php.ini file. 

Last but not least, disabling “’magic_quotes_” (now deprecated) and “register_globals” may also result in improved performance.

6. Optimize the MySQL database

Optimizing the MySQL database is a very effective performance boost that many server admins overlook! You’ll want to analyze the database queries running on your server, and tweak the MySQL performance to custom match the server needs.

Also, don’t forget about your storage type.

Disclaimer: Charts and data are copyrights of Intel Corporation.

MySQL performance is heavily dependent on storage having a very low latency and high durability under high random read and write IOPS. Below are some rules of thumb when it comes to storage.

Below are a few MySQL performance tuning tips to help you speed up your LAMP stack’s performance.

MySQL Performance Tuning Tips:

  • Use a slow query log to identify slow running queries and find out the bottlenecks.
  • A query cache is a good idea if your queries are repetitive and your data does not change often.
  • Use a Key Cache for caching the database indexes.
  • Consider allocating a minimal value for the “max_connections” parameter. Too many connections can eat memory, and lock up the server.
  • Consider increasing the size of “temp_table_size” and “max_heap_table_size” to prevent disk writes.
  • Archiving old data is a good practice to remove excessive row returns from search queries. By using an ORM (object relational mapper), you can expect to gain certain performance benefits.
  • And the XFS file system can make the database faster compared to default ext3.

Maximizing MySQL Availability with Clustering

And if your MySQL database is super mission-critical, then the ultimate upgrade is to host the database servers and web servers on separate machines.

Backing up databases isn’t enough when you can’t afford to miss even a single transaction. You need clustering.

Segmenting, or clustering, these server roles on different servers is a major boost as you’ll get serious database redundancy.

You can lose one of your MySQL Proxy servers or one or two of your database servers, and still be able to service query loads from your Apache web servers. 

Need help optimizing your Linux LAMP stack? 

Tuning a VPS or dedicated server for optimal performance is worth the effort –  but it’s not always easy to do. And it takes a lot of time and concentration!

So instead of spending your time tweaking the Linux server,  spend your valuable time developing your sites. Let the experienced professional techs at EuroVPS speed up your Linux LAMP stack server and you’ll not only get a faster server but a secure and reliable server too.