Cara Install Drupal 7.7 di Nginx

Berikut adalah cara instalasi Drupal 7.7 pada Nginx di sistem operasi Debian Linux:

Bagian I. Instalasi NGINX

  1. Lakukan langkah-langkah berikut (jika sistem anda belum tersedia Nginx):
  2. Install MySQL 5, dengan perintah apt-get install mysql-server mysql-client
  3. Ubah password MySQL 5!
  4. Install Nginx dengan perintah apt-get install nginx
  5. Jalankan daemon Nginx dengan perintah /etc/init.d/nginx start
  6. Karena default direktori Nginx adalah /var/www, buat dulu jika tidak ada dengan perintah mkdir /var/www dan chown www-data:www-data /var/www
  7. install PHP5 dengan dukungan FastCGI, dengan perintah: apt-get install php5-cgi php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
  8. Edit konfigurasi PHP, dan ubah konfigurasi perbaikan path CGI (Fix Path Info) dengan menghilangkan tanda komentar pada baris cgi.fix_pathinfo=1
  9. Konfigurasi Nginx pada /etc/nginx/nginx.conf. Silakan rujuk pada dokumen berikut: http://wiki.codemongers.com/NginxFullExample atau http://wiki.codemongers.com/NginxFullExample2

Bagian 2. Persiapan Instalasi Drupal

  • Instalasi PHP APC (akselerator dan optimalisator kode PHP tingkat intermediate) sepadan dengan eAccelerator & XCache.
  • Jika anda menggunakan PHP-FPM dan daemon FastCGI, restart PHP5 FPM /etc/init.d/php5-fpm restart
  • Buat sebuah spwan-fcgi yang baru dengan perintah /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid

Bagian 3. Instalasi Drupal

  • Jika default direktori web anda adalah /var/www, dengan domain emka.web.id, maka direktori anda adalah /var/www/emka.web.id. Jika belum ada, silakan buat dengan perintah mkdir -p /var/www/emka.web.id/web
  • Unduh Drupal 7.7 dari http://ftp.drupal.org/files/projects/drupal-7.7.tar.gz kemudian ekstrak dan pindah ke direktori /var/www/emka.web.id/web
  • Buat direktori web anda writable dengan user www-data dan grup www-data
  • Buat database baru untuk Drupal dengan MySQL, mysqladmin -uroot -p create drupal
  • Buat vhost baru dengan nginx, di /etc/nginx/sites-available contoh: /etc/nginx/sites-available/emka.web.id.vhost
server {
       listen 80;
       server_name www.example.com example.com;
       root /var/www/www.example.com/web;

       if ($http_host != "www.example.com") {
                 rewrite ^ http://www.example.com$request_uri permanent;
       }

       index index.php index.html;

       location = /favicon.ico {
                log_not_found off;
                access_log off;
       }

       location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
       }

       # Make sure files with the following extensions do not get loaded by nginx because nginx would display the source code, and these files can contain PASSWORDS!
        location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ {
                deny all;
        }

       # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
       location ~ /\. {
                deny all;
                access_log off;
                log_not_found off;
       }

       location / {
                try_files $uri $uri/ /index.php?$args;
       }

       location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
                expires max;
                log_not_found off;
       }

       location ~ \.php$ {
                include /etc/nginx/fastcgi_params;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       }
}
  • Buat symlink di /etc/nginx/sites-enabled dengan perintah ln -s /etc/nginx/sites-available/emka.web.id.vhost emka.web.id.vhost
  • Reload Nginx, dengan perintah /etc/init.d/nginx reload
  • Instalasi Drupal dengan mengunjungi domain web anda.

Screenshoot Instalasi Drupal