The standard LAMP 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 on your VPS. LAMP 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.

Here’s 6 ways to supercharge your LAMP Stack

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 a 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 resource if you’re not using that feature?

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

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 that 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. Optimizing the php.ini file

A few tweaks to the php.ini file can improve the server performance significantly!

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 decent volume of traffic. Increase this to either 64 MB or 128 MB, depending on the amount of physical memory available in 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 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.

    MySQL Optimisation 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.

The storage type can also affect database performance:

Maximising 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. 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. 

Advanced DBA Support Do you demand a lot from your databases? We can help!

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 techsat EuroVPS speed up your Linux LAMP stack server and you’ll not only get a faster server, but a secure and reliable server.

Use the LAMP Stack?

Get full LAMP Stack management at no extra cost with all our hosting products.

Learn More