How to make Apache faster for Drupal
If you are reading this blog post you must be striving to improve the performance of your site. When we speak about performance two things should be taken into account essentially.
- Number of requests the site is able to serve (The more, The better)
- Response time per request (The least, The better)
I guess it is not much needed to stress as how essential the response time plays in deciding the success of a website. Apache the prominent Web server plays a key role in this connection.
When configuring Apache for Drupal most of the tutorials recommend changing AllowOverride directive to All, including the official handbook page in drupal.org http://drupal.org/node/36628 , while the default is None.
This is needed to make .htaccess file in Drupal core to override the Apache config as needed. Especially to get clean url working. Besides it let's to set page expiry time, and setting necessary headers for css/js gzip compression if supported.
But this is a performance killer change!
Reason when AllowOverride is set to All. It prompts Apache to look for the existence of .htaccess file in recursive sub-folders as below.
/.htaccess /www/.htaccess /www/htdocs/.htaccess /www/htdocs/example/.htaccess
and goes on...
Eventually the number of I/O calls needed to serve the page request spikes up. Beware, I/O calls are expensive. And it goes further worst depending on the number of modules you have. Especially if you have hosted the site in VPS environments where disk operations are sub-optimal and can't be fully virtualized. The workaround for this problem is to tell Apache explicitly the location as where to look for overriding .htaccess file.
The following config helped us to fix the issue.
# Site example.com <VirtualHost *:80> ServerAdmin email@example.com ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/example.com <Directory /var/www/example.com> Options -Indexes -FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all Include /var/www/example.com/.htaccess </Directory> <Directory /var/www/example.com/sites/default/files> Include /var/www/example.com/sites/default/files/.htaccess </Directory> </VirtualHost>
Additionally apache's module mod_expires and mod_headers could be installed as Drupal's core .htaccess tries to leverage it if they exist.
- Using Drush to administer multisite
- Manual AWS Autoscaling without Elastic Beanstalk
- Enabling HTTP authentication for private Drupal site
- Drupal IBAN Verification using Libraries API
- Setup Default Group & Permissions for new files created under a specific directory [Debian/Ubuntu]
- Quickly setup Mailman mailing list with Exim 4 for a subdomain