Gouge: Drupal Postgres on Centos
Installing Drupal on Centos using Postgres instead of MySQL gets a bit tricky
By Robin Rowe

Drupal powers the Obama White House site whitehouse.gov
HOLLYWOOD, CA (Gosh!TV) 12/22/2009 – Drupal is a popular content publishing program that the White House uses since Obama took office. The standard Drupal installation uses MySQL. Many prefer Postgres because they find it more robust and faster with multiple connections. Drupal supports Postgres (and Sqlite, too). Let’s install on CentOS.
Installing Postgres
- # yum install postgresql postgresql-server php-pgsql php-gd
- # ln -s /var/lib/pgsql/data/pg_log /var/log/pg_log
- Edit /var/lib/pgsql/data/pg_hba.conf to enable password-based connections:
#local all all ident sameuserlocal all all md5# IPv4 local connections:#host all all 127.0.0.1/32 ident sameuserhost all all 127.0.0.1/32 md5
- # /sbin/chkconfig postgresql on
- # /sbin/service postgresql start
- # /sbin/service httpd restart
- # su – postgres
- $ psql -d template1 -U postgres
- /l
- \q
- $ createuser drupal –pwprompt –encrypted
- Answer n to all questions
- $ createdb my_blog_name –owner=drupal
- $ psql -l
- $ exit
Postgres only has UTF8 encoding, that specifying UNICODE as recommended by Drupal will create a UTF8 table anyway. Since UTF8 is the default encoding, it’s not necessary to specify it in createdb. If Drupal says Postgres is not installed, restart apache. If you install any php modules, you’ll have to restart apache for Drupal to detect them. If that doesn’t help, check /etc/php.d. More Postgres notes.
Testing PHP with Postgres
If you need to check that PHP sees Postgres, create and browse this file looking for a pgsql section:
http://www.my_site.com/drupal-6.14/phpinfo.php
<?
phpinfo();
?>
If you don’t get a connection, try this test code:
http://www.my_site.copg_connect.php
<?php
$connection = pg_connect(‘user=drupal password=my_password dbname=goshtv’) or die(‘Could not connect: ‘ . pg_last_error($connection));
echo “Connected!”;
?>
Installing Drupal
- $ cd /var/www/html/
- $ wget http://drupal.org/files/projects/drupal-x.x.tar.gz
- $ tar xvfz drupal-x.x.tar.gz
- $ rm drupal-x.x.tar.gz
- # chown -R apache drupal-x.x
- # chgrp -R apache drupal-x.x
- # mv drupal-x.x my_blog_name
- # cd my_blog_name/sites/default/
- # cp default.settings.php settings.php
- # chown apache settings.php
- # chgrp apache settings.php sites/default/
Configuring Drupal from the Web
- http://www.my_site.com/my_blog_name/
- http://www.goshtv.net/drupal-6.14/
Setting cron
- # vi /etc/crontab
45 * * * * /usr/bin/wget -O – -q -t 1 http://www.goshtv.net/drupal-6.14/crontab.php
The web page you’re reading was published using WordPress. Here it is in Drupal:
http://www.goshtv.net/drupal-6.14/
More configuration is necessary with Drupal to create a rich media site like whitehouse.gov. Unlike WordPress, Drupal won’t embed images without installing plug-ins. However, WordPress is MySQL only, doesn’t support Postgres. All database CMS systems are slow and require caching to perform well. WordPress has SuperCache. Drupal has Boost which may be faster as it’s static pages.
