Setting up Joomla 3.1.5 with PostgreSQL on Ubuntu 13.04

Installing dependencies

Firstly you need to install webserver, php-related stuff and database server (we use PostgreSQL).

apt-get install -y php5-fpm nginx postgresql php5-pgsql

Now download and install Joomla (currently 3.1.5 is the latest). Please, update following lines with latest version if nescessary:

cd /srv
wget http://joomlacode.org/gf/download/frsrelease/18622/83487/Joomla_3.1.5-Stable-Full_Package.zip
unzip Joomla_3.1.5-Stable-Full_Package.zip -d joomla
chown -R www-data:www-data joomla

Database setup

The only two things you need to do is to create user (joomla in example) and database (joomla in example). To do it under postgres user:

sudo -u postgres -i
createuser joomla --pwprompt --encrypted
createdb joomla
exit

Output should look like:

$ createuser joomla --pwprompt --encrypted
Enter password for new role:
Enter it again:
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) n

nginx setup

Create file joomla with content (you may want to adjust server_name and root):

#vim /etc/nginx/sites-available/joomla
server {
  listen 80;
  server_name joomla.lan;
  access_log /var/log/nginx/localhost.access.log;
  error_log /var/log/nginx/localhost.error.log;
  root /srv/joomla;
  index index.php index.html index.htm default.html default.htm;
  # Support Clean (aka Search Engine Friendly) URLs
  location / {
    try_files $uri $uri/ /index.php?$args;
  }
  # deny running scripts inside writable directories
  location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
    return 403;
    error_page 403 /403_error.html;
  }
  location ~ \.php$ {
    fastcgi_pass  unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include /etc/nginx/fastcgi.conf;
  }
  # caching of files
  location ~* \.(ico|pdf|flv)$ {
    expires 1y;
  }
  location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ {
    expires 14d;
  }
}

Enable site by creating link to config:

ln -s /etc/nginx/sites-available/joomla /etc/nginx/sites-enabled/

And add FastCGI options (create fastcgi.conf file):

# vim /etc/nginx/fastcgi.conf
fastcgi_param   QUERY_STRING            $query_string;
fastcgi_param   REQUEST_METHOD          $request_method;
fastcgi_param   CONTENT_TYPE            $content_type;
fastcgi_param   CONTENT_LENGTH          $content_length;

fastcgi_param   SCRIPT_FILENAME         $document_root$fastcgi_script_name;
fastcgi_param   SCRIPT_NAME             $fastcgi_script_name;
fastcgi_param   PATH_INFO               $fastcgi_path_info;
fastcgi_param   REQUEST_URI             $request_uri;
fastcgi_param   DOCUMENT_URI            $document_uri;
fastcgi_param   DOCUMENT_ROOT           $document_root;
fastcgi_param   SERVER_PROTOCOL         $server_protocol;

fastcgi_param   GATEWAY_INTERFACE       CGI/1.1;
fastcgi_param   SERVER_SOFTWARE         nginx/$nginx_version;

fastcgi_param   REMOTE_ADDR             $remote_addr;
fastcgi_param   REMOTE_PORT             $remote_port;
fastcgi_param   SERVER_ADDR             $server_addr;
fastcgi_param   SERVER_PORT             $server_port;
fastcgi_param   SERVER_NAME             $server_name;

fastcgi_param   HTTPS                   $https;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param   REDIRECT_STATUS         200;

hosts setup

Now you need to point joomla.lan to 127.0.0.1 ip address. To do it, add line to /etc/hosts:

127.0.0.1 joomla.lan

Now restart and go to http://joomla.lan