Drupal - Install OpenAcademy distribution with Nginx, php5-fpm, and MariaDB in Ubuntu12.04

OpenAcademy is a Drupal distribution which is used for higher education (or whatever you want :D). This blog post is about installing and setting up the full stack (including nginx, php5-fpm, mariadb, drupal, openacademy) to make a working website:

1. Install MariaDB, create a database for drupal:
Go to https://downloads.mariadb.org/mariadb/repositories, and select the appropriate mirror for your mariadb installation. In my case, I install the dbms in Ubuntu 12.04, mariadb 5.5, so the installation procedure is as following

$ sudo apt-get install python-software-properties
$ sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
$ sudo add-apt-repository 'deb http://ftp.kaist.ac.kr/mariadb/repo/5.5/ubuntu precise main'
$ sudo apt-get update
$ sudo apt-get install mariadb-server

2. Install and  config php5-fpm:

* Install php5-fpm:

$ sudo apt-get install php5-fpm php5-mysql

* Open php config file:

$ sudo nano /etc/php5/fpm/php.ini

change the following line:

* Open the php5-fpm config file:

$ sudo nano /etc/php5/fpm/pool.d/www.conf

listen =

listen = /var/run/php5-fpm.sock

* Restart php5-fpm:

$ sudo service php5-fpm restart

3. Install and config nginx:

* Install nginx:

$ sudo apt-get install nginx-full

* Creat configuration for drupal site:

$ sudo nano /etc/nginx/sites-available/drupal

server {
        listen   80;

        root /path/mydrupal;
        index index.php index.html index.htm;

        server_name locahost;

        location / {
                try_files $uri $uri/ /index.html;

        error_page 404 /404.html;

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
              root /usr/share/nginx/www;

        # pass the PHP scripts to FastCGI server listening on
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;


* Enable drupal site:

$ sudo ln -s /etc/nginx/sites-available/drupal /etc/nginx/sites-enable/drupal

* Restart nginx:

$ sudo service nginx restart

4. Download and install OpenAcademy distribution:

* Download OpenAcademy:

$ cd /path/
$ wget http://ftp.drupal.org/files/projects/openacademy-7.x-1.0-rc3-core.tar.gz
$ tar -xzvf openacademy-7.x-1.0-rc3-core.tar.gz
$ mv openacademy-7.x-1.0-rc3-core mydrupal

* Open web browser and start the installation

5. Troubleshoot:

* Error when installing Mariadb: you may need to specify the mariadb version:

$ sudo apt-get install mariadb-server-5.5="5.5.34+maria-1~precise" mariadb-client-5.5="5.5.34+maria-1~precise" libmysqlclient18="5.5.34+maria-1~precise" mysql-common="5.5.34+maria-1~precise"

* Enable php extensions needed by Drupal:

$ sudo apt-get install php5-gd php-db php5-mysql

* Increase php memory_limit to 196M:

$ sudo nano /etc/php5/fpm/php.ini

memory_limit = 196M

or you can just disable php memory_limit by add this line to drupal's settings file (after installed):

$ sudo nano /path/sites/default/settings.php

ini_set('memory_limit', '-1');

Restart php5-fpm after making any change:

$ sudo service php5-fpm restart


'/path/' is wherever you want, somewhere like '/var/' or '/srv/'

[0] https://drupal.org/node/207036
[1] https://drupal.org/node/1225756
[2] https://www.digitalocean.com/community/articles/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-12-04
[3] https://drupal.org/project/openacademy