Drupal

Setup Nginx as web server and as reverse proxy for Apache with Virtualmin support

We know that Nginx is more faster than Apache and most of us prefer to replace Apache with Nginx as their web server. Nginx is known to serve faster static content and run with less RAM. As of this writing, Virtualmin supports Apache as its web server. To take advantage of Nginx, we will install it as reverse proxy for Apache and continue using Virtualmin to manage your domains (Note: this article will assume that the Nginx and Apache are running on same server).

Build high performance Drupal site without spending much

Drupal

When we install the basic Drupal we get very simple functionality and not so good user experience, we have to dig through 30,000 modules to find the modules we need, install and configure them to achieve the site we actually want. To save the trouble from doing this work, we can take advantage of using Drupal distribution. One of the very good to start with is the Panopoly Drupal distribution it has almost all the modules or functionality that a general website should have.

How to setup Memcache on CentOS 7 for Drupal site

One way to optimize the authenticated users experience in Drupal site is to use Memcache. It works between the database and Drupal. Typically the queries are cached in the database but with Memcache the queries sent from Drupal to database are intercepted by Memcache and it serves them from RAM and this avoid hits to the disk or database. We see often that half of the queries are served by Memcache and we are looking significant improvement in authenticated users hits.

Methods to disable Nginx cache when user is authenticated in Drupal

There are some cases we only need Nginx cache enabled for anonymous users. I can show two ways on how to disable Nginx cache when user is authenticated and enable it for anonymous users in Drupal.

Method 1: Using Cookie

This method invloves Drupal custom module to set an identifier in Cookie that a user is authenticated.

The custom module uses hook_user_login() to set "nocache=1" in Cookie if user is logged in and hook_user_logout() to set "nocache=0" if user is logged out. The codes are as follows (you can download the custom module below this article):

Get Drush to run Drupal cron regularly using crontab

Drush can Drupal cron without the need of accessing http://www.yoursite.com/cron.php?cron_key=<key>. This means we can safely remove or redirect cron.php to 404 Not Found in our .htaccess:

  
RewriteRule cron.php / [R=404,L]
  

To make our crontab script simple, we will use Drush's site aliases. Example if we are running multiple sites in our server: yoursite1.com, yoursite2.com and yoursite3.com we can assign alias @site1, @site2 and @site3 respectively. To do this:

Tags

Adding autocomplete to custom Drupal form using Search API autocomplete module's API

The Search API autocomplete module works well on views page with exposed filter form but we know that views exposed filter form generates less clean URL for its filtered page. Using views contextual filter is the quick way to solve clean URL issue but it requires to develop your own custom search form to pass the query to this views contextual filter. This article will show how to add autocomplete feature to custom Drupal form where data shown in dropdown suggestions are pulled from Search API index using Search API autocomplete module's API.

Setup Drupal 7 Panopoly distribution with mongoDB on CentOS 7

The mongoDB provides high performance, high availability, and easy scalability. Using it with Drupal, will take some load off its SQL database. The read/write SQL procedures in Drupal functions like: session, log entries from watchdog, cache, fields, queue and block can be handled by mongoDB Drupal module. And this will greatly improve the perfomance of your Drupal site.