How to Create a New Drupal Site


This page describes how to create a new Drupal site on an existing Drupal server.


  1. Create a database to host the Drupal site. We use MySQL to host the databases.
    1. Create a new database (newer versions of MySQL forbid you from renaming databases):
      mysql> CREATE DATABASE drupal_coord;
      Query OK, 1 row affected (0.04 sec)
    2. Create a database user for the above:
      mysql> CREATE USER 'drupal_coord'@'localhost';
      Query OK, 0 rows affected (0.03 sec)
    3. Grant the database user control over the database:
      mysql> GRANT ALL ON drupal_coord.* TO 'drupal_coord'@'localhost';
      Query OK, 0 rows affected (0.01 sec)
    4. Give the database user a password:
      mysql> SET PASSWORD FOR 'drupal_coord'@'localhost' = PASSWORD('****');
    5. Flush privileges so they'll 'take':
      mysql> FLUSH PRIVILEGES;
      Query OK, 0 rows affected (0.00 sec)
  2. Create a Drupal instance site directory:
    1. Change to the Drupal sites directory:
      [postel] ~% cd /usr/local/www/drupal6/sites/
    2. Copy the default site directory:
      # cp -rp default/
  3. Edit this Drupal instance's settings.php file:
    1. Make settings.php writable
      # chmod 644
    2. Edit settings.php
      $db_url = 'mysqli://drupal_coord:*****@localhost/drupal_coord';
    3. Make settings.php unwritable
      #  chmod 444
  4. Create a symbolic link from the DocumentRoot (/wikis/root) to the drupal directory.
    % cd /wikis/root
    # ln -s /usr/local/www/drupal6/ coord
  5. Load the Template Drupal Database

    We maintain a bare-bones template Drupal site called template_6 to serve as a template for new sites.

    1. Load the Drupal6 template site and run the status report to make sure its components are all up-to-date.
    2. Update whatever needs to be updated. You may need to run the update.php script. You're done when the status report shows no errors.
    3. Dump the template_6 database to a textfile:
      % mysqldump -u readonly_user -p***** drupal_template_6 > drupal_template_6.`date +\%Y\%m\%d`.sql
    4. Populate the new database with the template_6 database textfile:
      % mysql -u root -p drupal_SITENAME < drupal_template_6.20110614.sql
  6. Reindex the drupal site once per hour by adding a crontab entry:
    # crontab -e -u www

    Add an entry:

    3 * * * * /usr/local/bin/wget --no-check-certificate -O - -q
  7. Display the new Drupal site on our departmental website by registering it in our wikis table:
    mysql> use research;            
    Database changed
    mysql> insert into wikis values ('coord', null, 'CSE/CEN Course Coordination', NOW());
    Query OK, 1 row affected (0.00 sec)
    mysql> insert into wiki_owners values ('coord', 'kds', now());
    Query OK, 1 row affected (0.00 sec)
  8. Create local administrators for this wiki. CSE IT Administrative accounts for cwmiller were created when we loaded the template files, above (edit the template file to include other cse-staff members). Now we must create accounts to delegate administration to this wiki's requestors. Administrators should authenticate to the new wiki site they just created. Administrators should then set administrative permission by querying that wiki site's previously created database:
    mysql> select uid from users where name='kpcleary';
    | uid |
    |  14 |
    1 row in set (0.00 sec)
    mysql> insert into users_roles (uid, rid) values (14,3);
    Query OK, 1 row affected (0.00 sec)

    Invite the requestor(s) to login to the new wiki using their UBIT credentials. Then grant them the role of 'Editor'. Assign appropriate permissions to the 'Editor' role.

  9. Set the new Drupal site's title:
    Administer -> Site configuration -> Site information -> Name: = VALUE