Install requirements (webserver, php5, DB server, DB adapter for php) as root:

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

Create user and database (replace USER with desired username and HOSTNAME_db with database name, we will need this values in Drupal setup later) for future site:

 

sudo -u postgres -i

createuser USER --pwprompt --encrypted

createdb HOSTNAME_db

exit

 

 

Later you can use: su postgres from the console and start psql as "Postgres root" to get access to PostgreSQL's commands. The "root" in PostgreSQL is "posgres"

 

Now configure nginx. First create fastcgi config /etc/nginx/fastcgi.conf:

# 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;

fastcgi_param   REDIRECT_STATUS         200;

 

 

Now create config for site (change HOSTNAME to your site hostname):

#vim /etc/nginx/sites-available/HOSTNAME

 server {

   listen 80;

# here can be defined one or more desirable hostnames divided by space,  
# like: www .HOSTNAME.com HOSTNAME.com, etc. Sometimes it needs
# to give access to site by different names

  server_name HOSTNAME; 

  access_log /var/log/nginx/HOSTNAME.access.log;  error_log /var/log/nginx/HOSTNAME.error.log;  root /srv/HOSTNAME;  index index.php index.html index.htm default.html default.htm;

 # Support Clean (aka Search Engine Friendly) URLs
# Next block needs to be added to protect with password access to catalogs..
# In my case: */default/private 
# .htpasswd can be created with:
# htpasswd -c /srv/siverin.ru/sites/default/private/.htpasswd USERNAME

  location /sites/default/private  { 

  auth_basic "Administrative Zone"; 

 auth_basic_user_file /srv/siverin.ru/sites/default/private/.htpasswd;

 autoindex on; 

 } 

  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; 

 } 

 # by default there are more extensions here, but I've got problem with modules
# and removed these: jpg|jpeg|gif

 location ~* \.(js|css|png|swf|xml|txt)$ { 

 expires 14d;

 } 

 
and enable it:

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


also need to edit /etc/nginx/nginx.conf :

        # Max size of uploaded file (e.g. to upload big images and video)
        client_max_body_size 100m;

 

 Now you need to restart services as root:

 service php5-fpm restart
service nginx restart

 

Download latest Drupal package to /srv/ and unpack it. Rename folder to HOSTNAME (see nginx config for host). Create settings from sample ones and change owner of /srv/HOSTNAME to www-data:www-data.

Remove unnecessary Drupal package archive. All command above must look like (as root): 

 

wget http://ftp.drupal.org/files/projects/drupal-7.31.tar.gz

tar xvf drupal-7.31.tar.gz

mv drupal-7.31 HOSTNAME

rm drupal-7.31.tar.gz

cp HOSTNAME/sites/default/default.settings.php HOSTNAME/sites/default/settings.php

chown -R www-data:www-data HOSTNAME

 

Now complete web install of Drupal using your database name and user.

 

 

Тема на 5 минут. Если сервер настраивался не вами, то бывает сразу сложно разобраться, где лежат файлы БД PostgreSQL, т. к. их расположение может быть настроено отличным, от по-умолчанию, образом.

 

Поможет в этом следующая консольная команда:

 ps auxw | grep postgres | grep -- -D

 в итоге, мы получим:

 postgres 12917  0.0  0.1 118783 60648 ?        S    Jul27   0:01 /usr/pgsql-9/bin/postgres -D /data/postgres-9

 Вот после опции -D и указан каталог, в котором лежат файлы БД (обычно в подпапке base).