Setting up Drupal with PostgreSQL on OpenSolaris 2008.05
By rnl on Aug 20, 2008
Drupal is quickly gaining popularity among the many Open Source Content Management Systems (CMS) out there. AFAIK, Drupal is mostly used with MySQL on Linux, so I wanted to find out myself how easy (or hard) it is to get it working with PostgreSQL on OpenSolaris. Below were the steps I followed:
- Install OpenSolaris 2008.05. The installation from the Live CD went very smoothly, much simpler than previous versions of Solaris. Great job to the installer team! If you don't have the CD, you can download it from http://www.opensolaris.com/. Remember, OpenSolaris comes with the bare minimum, so additional software need to be installed from the network repository.
- Install Web Stack (Apache, PHP, MySQL, etc). After the OS installation, I fired up Firefox and just followed the instructions from the Welcome Page, clicked on "the world of OpenSolaris" link and that took me to http://www.opensolaris.com/learn/. From there, I followed these links: "Web Stack Getting Started Guide" > "2. Getting Started" > "Installing Web Stack Components" > "Setting Up Your AMP Development Environment". I decided to install everything using the following command.
- Initialize the Web Stack Environment & Start Apache. To do this, I just followed the Web Stack Getting Started Guide. Clicked on Applications > Developer Tools > Web Stack Getting Start Guide, and did the followings:
Install PostgreSQL. I wanted to install PostgreSQL 8.3 from the network repository, but I found out that 8.3 didn't make it to OpenSolaris 2008.05 which was based on Nevada build 86. To see all the available PostgreSQL packages, run.
# pkg search -r postgres
The output shows a lot of packages, but unfortunately the 8.3 packages are for later builds of Nevada. I did try to install one package, but it didn't work.
I could build Postgres 8.3 myself, by fortunately Sun also provides the binary in tarball format at http://www.postgresql.org/ftp/binary/v8.3.3/solaris/opensolaris/i386/, so I just used this version.
Setup PostgreSQL. I wanted to run Postgres using using the "postgres" user, but it's setup as a role by default, so I did the following to change it to a normal user:
a) As root, run "passwd -d postgres"
b) Edit /etc/user_attr and change the type for "postgres" from role to normal
c) Change the home directory and shell for "postgres" using the usermod command
Now I need to create the Postgres DB cluster. Make sure the directory where Postgres is installed is added to PATH.
postgres$ initdb -D /directory/path/to/data
Install Drupal 6.4. Follow the instructions in INSTALL.txt and copy the files to /var/apache2/2.2/htdocs.
Follow the instructions in INSTALL.pgsql.txt to setup the database. Here's what I did. Make the Postgres is running.
postgres$ createuser --pwprompt --encrypted --no-adduser --no-createdb drupal
Enter password for new role:
Enter it again:
Shall the new role be allowed to create more new roles? (y/n) y
postgres$ createdb --encoding=UNICODE --owner=drupal drupaldb
Configure Drupal. Make sure Apache is running and point the browser to http://localhost, and you should see the Drupal setup page.
# pkg install amp-dev
Initialize the environment: Clicked on Applications > Developer Tools > Web Stack Initialize
(The guide is a bit confusing, so run the following commands first before starting Apache/MySQL; otherwise you'll get errors)
# svccfg import /var/svc/manifest/network/http-apache22.xml
# svccfg import /var/svc/manifest/application/database/mysql.xml
Start Apache & MySQL: Clicked on Applications > Developer Tools > Web Stack Admin > Start Apache2/MySQL servers
Point browser to http://localhost so check that Apache is running.
That's it. Besides a couple of small hiccups, I think the whole process was quite straightforward.