Community Documentation

Drupal 6.x on Fedora 9 using PostgreSQL

Last updated February 8, 2012. Created by gpittman on July 20, 2008.
Edited by xjm, figaro, LeeHunter, sepeck. Log in to edit this page.

Installing Drupal on Fedora can be challenging because of the different way in which Fedora installs Drupal and PostgreSQL, so the standard ways that you will find in the generic README files and even on the official websites won't work. Artificially trying to make your installs like you see on the sites is fraught with problems.

At least parts of this tutorial can be found elsewhere, but this page represents one single place for all your needs for Fedora 9 and PostgreSQL.

PostgreSQL on Fedora

  • PostgreSQL installs to /var/lib/pgsql
  • the superuser postgres is created automatically, without a password. Once you su root, you can then su postgres (or another other user) without a password.
  • although root cannot use PostgreSQL, root initializes the database and starts PostgreSQL

Starting PostgreSQL

  1. If you already have PostgreSQL running, skip to step 5.
  2. As root, in a command line, enter service postgresql initdb. (Depending on how you have paths set up, you may have to use /sbin/service for the command.) You should get an OK as feedback when it's done.
  3. Still as root, enter service postgresql start. Once again, wait for the OK.
  4. To have PostgreSQL start up on boot, as root enter chkconfig --level 345 postgresql on. There is also a GUI way of starting/stopping services, but I prefer the command line.
  5. Now you can su postgres to createuser – we'll call it drupal:
    createuser --pwprompt --encrypted --no-adduser --no-createdb drupal
    which leads to a prompt for the password
  6. Create the database (as postgres) – which we'll call drupaldb:
    createdb --encoding=UNICODE --owner=drupal drupaldb

It used to be that you would get some feedback on the command line after createuser and createdb, but that doesn't seem to happen anymore.

Now Edit pg_hba.conf

You will need to do this to allow Drupal to access your database.
As root, use your favorite editor to edit the file /var/lib/pgsql/data/pg_hba.conf
Go down to this section:

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# "local" is for Unix domain socket connections only
local   all         all                               ident sameuser

After this above line enter:
host     drupaldb      all       127.0.0.1/32      md5
Save the file, then, as root, service postgresql restart

Drupal on Fedora

  • Drupal installs to /usr/share/drupal
  • Inside Drupal, the sites links to /etc/drupal, files links to /var/lib/drupal
  • You use httpd to control access to Drupal. This is what keeps visitors from getting access to your system, since httpd forbids going up above allowed directories by default.
  • The base setup of httpd and Drupal is set in /etc/httpd/conf.d/drupal.conf, where you find
    Alias /drupal /usr/share/drupal

    <Directory /usr/share/drupal/>
            Order Deny,Allow
            #Comment the following line and uncomment the next for public use
            Deny from all
            #Allow from all
            #Uncomment the following line for setup
            #Allow from 127.0.0.1
            AllowOverride All
    </Directory>

The first line is the link. On your machine, go to a browser, enter http://localhost/drupal, you will access Drupal, but not with a file like this one – instead you get the 403 Forbidden page. Remove the '#' from the Allow from 127.0.0.1 (this is what uncomment means, add the '#' to comment the line.) Needless to say perhaps, but you need to do this as root, and when you edit this file you have to stop and start httpd again, the quickest way being service httpd restart.

Configuration steps

You will get permissions error messages from Drupal as it tries to establish your site, unless and until you do the following:

  • As root, go to /etc/drupal and chmod 777 default.
  • Enter the default directory, and cp default.settings.php settings.php.
  • chmod 666 settings.php default.settings.php
    It's not quite clear whether you also need to make default.settings.php writable, perhaps 644 is Ok for default.settings.php.
  • You do not need to restart httpd after these steps.

Starting Drupal

At this point, you should be able to enter http://localhost/drupal in your browser, and bring up the forms for starting up your Drupal site, then entering your basic administrator information, after which you're off and running!

The last step, as you will read when you're all done, is to go back to /etc/drupal/ and
chmod 755 default
and inside the default directory,
chmod 644 settings.php default.settings.php

A Final Note about SELinux

It's possible there will not always be problems with SELinux, but for many tasks in Fedora 9, it simply helps to change the enforcing mode of SELinux to Permissive. Ideally, some day there may be some helpful documentation about SELinux to create some targeted policies that work, but for now, this seems to be what many are doing, and not specifically just about Drupal.

Comments

SELinux Mode

It is not necessary (and possibly not recommendable) to turn off Enforcing mode. Just make sure that files have the correct security context - see man httpd_selinux for details. With a few chcon's I have Drupal 6.6 on Fedora 10 running just fine.

php-pgsql is required

I followed this guide on a machine running Fedora 12 while installing Drupal 6.19. Everything went fine until I tried to select the postgresql database on the initial configuration page of Drupal. The option for it was not there. The problem turned out to be that I did not have the php-pgsql package installed. Once I installed this package and restarted apache, I was able to select postgresql.

Otherwise, this guide worked out great. Thanks

RE: Drupal 6.x on Fedora 9 using PostgreSQL

I am unable to connect drupal6.x with fedora.... we are developing iphone mobile application platform for our new iphones..

Mobile Programming LLC
http://www.mobileprogramming.com/

Tutorials and site recipes

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here