Home > AWS, CentOS, Linux, PostgreSQL > Drupal install of commerce_kickstart-7.x-1.8-core at AWS on two PostgreSQL 9.1.4 replicated nodes with Nginx and php-fpm

Drupal install of commerce_kickstart-7.x-1.8-core at AWS on two PostgreSQL 9.1.4 replicated nodes with Nginx and php-fpm

I decided to try Drupal on two PostgreSQL nodes replicated as master and readonly slave.
The usual choice for webserver is nginx

Follow the http://drupal.org/documentation/install and
http://drupal.org/project/commerce_kickstart
http://wiki.nginx.org/Drupal

# get the source and install it at the proper location like /usr/share/nginx/drupal
wget  http://ftp.drupal.org/files/projects/disable_messages-7.x-1.0.tar.gz

#set the proper nginx config 
root@domU-12-31-39-09-D2-CD-node-1:[Sun Jul 22 15:36:27]:[/var/lib/pgsql]$ cat /etc/nginx/conf.d/drupal.conf
server {
        server_name darkstar.gotdns.org;
#        root /var/lib/pgsql9/xfs.data/drupal; 
        root /usr/share/nginx/drupal; ## <-- Your only path reference.
 
        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }
 
        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }
 
        # This matters if you use drush
        location = /backup {
                deny all;
        }
 
        # Very rarely should these ever be accessed outside of your lan
        location ~* \.(txt|log)$ {
                allow 10.210.213.55/32;
                deny all;
        }
 
        location ~ \..*/.*\.php$ {
                return 403;
        }
 
        location / {
                # This is cool because 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_pass   127.0.0.1:9000;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                #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:/var/run/php-fpm.sock;
        	fastcgi_index  index.php;
		fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;

        }
 
        # Fighting with ImageCache? This little gem is amazing.
        location ~ ^/sites/.*/files/imagecache/ {
                try_files $uri @rewrite;
        }
        # Catch image styles for D7 too.
        location ~ ^/sites/.*/files/styles/ {
                try_files $uri @rewrite;
        }
 
        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }
}

#check the nginx config :
root@domU-12-31-39-09-D2-CD-node-1:[Sun Jul 22 15:42:02]:[/var/lib/pgsql]$ nginx -t -c /etc/nginx/nginx.conf
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

# and reload it
root@domU-12-31-39-09-D2-CD-node-1:[Sun Jul 22 15:44:05]:[/var/lib/pgsql]$ service  nginx reload
Reloading nginx:  

# create pgsql user and db and set the pemirssions
root@domU-12-31-39-09-D2-CD-node-1:[Sun Jul 22 11:55:33]:[~]$ createuser -U postgres -h 127.0.0.1 --pwprompt --encrypted --no-createrole --no-createdb drupal 
Enter password for new role: 
Enter it again: 
Shall the new role be a superuser? (y/n) n
root@domU-12-31-39-09-D2-CD-node-1:[Sun Jul 22 12:06:25]:[~]$ createdb -U postgres -h 127.0.0.1 --encoding=UTF8 --owner=drupal drupal

# set the psql user permissions at the slave with same password you set to the drupal user at the master:
root@ip-10-28-82-97-node-2:[Sun Jul 22 16:01:59]:[/var/lib/pgsql/data]$ cat  /var/lib/pgsql/data/pg_hba.conf | grep -i drupal
hostnossl       drupal          drupal             masterIP/32	 password

# ativate the user permissions 
root@ip-10-28-82-97-node-2:[Sun Jul 22 14:23:31]:[/var/lib/pgsql/data]$ service postgresql reload

#check the connection to slave:
root@domU-12-31-39-09-D2-CD-node-1:[Sun Jul 22 16:03:33]:[/usr/share/nginx]$ echo "select version();" | psql -h slaveIP -U drupal drupal
Password for user drupal: 
                                                   version                                                   
-------------------------------------------------------------------------------------------------------------
 PostgreSQL 9.1.4 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 4.4.6 20110731 (Red Hat 4.4.6-3), 64-bit
(1 row)


#start the install process hitting the index.php
#in case you get <strong>Error not found</strong>  change the permissions of the drupal root directory to 0755:   
chmod -R 0755  /usr/share/nginx/drupal

# install some of the php modules requested by the install as gd, dom and mbstring:
yum install php-soap php-mbstring php-xml  -y
#then restart the php-fpm 
root@domU-12-31-39-09-D2-CD-node-1:[Sun Jul 22 15:09:19]:[/var/lib/pgsql]$ service  php-fpm restart
Stopping php-fpm:                                          [  OK  ]
Starting php-fpm:                                          [  OK  ]

if you get an Warning message like this one:
Compilation failed: unknown option bit(s) set at offset 0 in user_validate_name() (line 645 of /usr/share/nginx/drupal/modules/user/user.module).

this is due to php PECL pcre extension update
there will be some more similar errors indicated at
+1606 /usr/share/nginx/drupal/includes/bootstrap.inc
+3726 /usr/share/nginx/drupal/includes/common.inc
+645 /usr/share/nginx/drupal/modules/user/user.module

the fastest way to fix it at AWS is to do yum update of pcre.x86_64

in general with AWS is better to do just yum update

then, everything works as expected,

do not forget to set the permissions of ./sites/default/settings.php to 0755 after the install

how to set the drupal to use the slave :
thank to padraig o’sullivan who posted
The settings.php file for the Drupal site needs to be updated to know about this slave database.

end of the story, now we have possible web cluster as the second node could be used for second web server, just some db connection settings have to be adjusted. and NFS with CacheFS for the web writable part of the drupal.

The drupal admin is owned by my daughter now … she is about to create the online store.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: