Every website owner wants fast loading and secure operating of his online business. Some of them have their own custom written CMSs (content-management systems), others – open source CMSs. But one question is a common here – What hosting solution should they use in order to achieve the results they want?
Today we will take a deeper look at how we can configure our Nginx hosting to suits best with one of the most used CMSs worldwide – Drupal, the open source platform that holds around 6% of the open source CMSs market.
Drupal is a free open-source content-management system written in PHP language and distributed under the GNU General Public License. It is well-recognized as a back-end framework for at least 2.1% of all websites worldwide. You can use it to develop any kind of websites and a lot of corporate blogs, political and government sites run on it. It is also used for knowledge business and management. Other interesting facts are:
- Drupal’s installation files size are 11.8 M;
- Drupal core is the standard release of Drupal;
- Drupal has more than 30 000 contributed modules and 2 000 free community-contributed themes;
- Dries Buytaert is the original writer of Drupal and it was just a message board in the beginning;
- Drupal became an open source CMS in 2001;
- Drupal means “drop” in Dutch (“druppel” as in “a water droplet” – the logo speaks best);
- The interest in Drupal got a significant boost in 2003;
After detailed search over the Web, a solution of how to configure your Nginx hosting to work best with Drupal has been found. This Nginx + Drupal configuration works great and it is tested in a separate environment. Those rewrite rules are for Drupal + Nginx using PHP-FPM as php parser in nginx, php-fpm and all the stuff works fine.
server {
…
…
…location / {
# Here no php is touched for static content
try_files $uri @rewrite;
}location @rewrite {
# Some modules enforce no slash (/) at the end of the URL
# Else this rewrite block wouldn’t be needed (GlobalRedirect)
rewrite ^/(.*)$ /index.php?q=$1;
}location ~ .php$ {
fastcgi_split_path_info ^(.+.php)(/.+)$;
#Important note: You should have “cgi.fix_pathinfo = 0;” in php.ini
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
fastcgi_pass unix:/tmp/phpfpm.sock;
}…
…
…
}
Then you paste all the code, you can now restart the nginx by typing this command:
service nginx restart
Now everything should be working fine. If you have questions or suggestions, please contact us.
Resources:
nginxtips.com
wikipedia.org