ONLamp.com    
 Published on ONLamp.com (http://www.onlamp.com/)
 See this if you're having trouble printing code examples


Drupal 6.0: Installation and Basic Usage

by Michael J. Ross
03/18/2008

Organizations of all sizes face the challenge of creating professional-looking web sites with minimal expenditure of time and money. Each organization can have a unique set of desired features for their site, but most of them share some core functionality. This typically includes the capacity for user publication of content on the site, to avoid the problem seen frequently in the early days of corporate Internet and intranet sites, namely, an organization's IT group acting as a bottleneck to site development, by forcing others within the organization to go through the group in order to add or modify the site's contents.

Web sites developed from scratch, using server-side technologies, can provide a custom solution — one that supports user content and any other needed functionality. But such projects typically end up less powerful and secure than planned, and requiring more time and money than anticipated, especially after months or years of debugging.

Overview of CMSs and Drupal

In answer to this need, independent developers and software companies created content management systems (CMSs), which the uninitiated can think of as web site frameworks without the site content. In other words, a CMS is like an empty web site, with all of the scaffolding in place for the site's administrators and (optionally) visitors to fill in with content, such as blog postings, perhaps with accompanying images. The scaffolding typically includes a database for storing content, user sign-up and authentication capabilities, a web feed, a calendar for events, etc. The primary advantage is that the scaffolding does not need to be developed by the administrators. Instead, those individuals can focus on styling the site to match the organization's branding and polishing its contents.

The benefits of using a quality CMS are substantial. As noted earlier, an IT department can quickly roll out a new web site, without reinventing the wheel. Users can contribute web content without any knowledge of HTML, by using a built-in WYSIWYG ("what you see is what you get") editor. Content access can be restricted using multiple levels of user permissions. The user management and security capabilities have usually received years of scrutiny by administrators, security experts, and hackers. Database design and optimization issues have already been worked out, oftentimes by specialists with more knowledge and experience than what a modest organization may have on hand or can afford to bring in house. The look of an entire site can be changed instantly by choosing a different "theme" (the most common term), and all the major CMSs have some built-in themes to choose from, as well as the ability to add third-party themes. These are just some of the many advantages of utilizing a CMS for a new site.

Most of the early CMSs, however, were proprietary, and some were remarkably expensive. Fortunately, the current best-of-breed open source CMSs provide most, if not all, of the functionality of their closed-source brethren. In addition, they are supported by growing communities of enthusiastic developers, who are happy to create and share with others the custom templates and extensions that add new functionality to their respective CMSs, including e-commerce operations for online stores.

Drupal is one of the most popular CMSs and is gaining greater recognition all the time, partly because it encompasses all of the aforementioned features, and partly because programmers adept with PHP (the language in which Drupal was written) can customize the functioning and appearance of seemingly every aspect of Drupal. With the recent release of version 6, Drupal has achieved a noteworthy milestone in its development history and the capabilities that it offers to web site creators. This latest version offers improvements and even brand-new features in a wide range of areas: installation, administration, human language support, theme management, security, performance, and many more.

In this article, we will discuss how to install and configure a brand-new Drupal web site, from scratch. We will also explore the fundamentals of adding content to a Drupal installation.

System Requirements

In order to run Drupal on your computer, several components are needed: 1) a web server, 2) a database server, and 3) a web scripting language, namely, PHP. All three of these components should be installed and verified prior to installing Drupal:

In this article, we will be using the most recent versions of these components, as of this writing: Apache 2.2.8, MySQL 5.0, and PHP 5.2.5 — all on a Windows XP system. The corresponding installation procedures will be the same for other versions of Windows (2000 and Vista) and, to a lesser extent, other operating systems supported by Drupal, including Linux. The procedures for earlier supported versions of Apache, MySQL, and PHP, will likewise be similar if not identical.

Specific instructions for installing and configuring Apache, MySQL, and PHP are available with those products, as well as in developer tutorials that can be found on the Internet. More detailed information on required and recommended PHP configuration settings, can be found on the Drupal system requirements page. It notes that a minimum of 16 megabytes of system memory are required, but most likely your planned Drupal platform has far more available RAM.

Downloading Drupal

The first step in installing Drupal is to download the latest version of the program, which is Drupal 6.0. Click on the "Download Drupal 6.0" link and save the archive file, drupal-6.0.tar.gz, somewhere on your computer. If you have a broadband connection to the Internet, the download process should take just a second or two, because the Drupal installation file is only a bit larger than 1 MB — lean compared to the installation files of some other popular CMSs.

Drupal 6.0 download page
Figure 1. Drupal 6.0 download page

The previous stable release of Drupal, version 5.7, is available, but not recommended.

Installing Drupal

Open the saved installation file on your computer, which will undoubtedly launch whatever file archiving program you have associated with Gzip files. (If you do not have such a program, there are many excellent ones available, including 7-Zip.)

Installation file contents
Figure 2. Installation file contents

Extract all the contents of the archive file into a new Drupal directory somewhere within your web server's root directory. The contents comprise 465 files in 57 directories, which may seem like a lot to those unfamiliar with CMSs, but is actually a fraction of those found in the installation files of other leading CMSs. Drupal is equally lean in disk space usage compared to its counterparts, filling only 3,295 KB.

Before running the Drupal installation script, create a database on your MySQL server. This can be accomplished using any MySQL database management tool, whether a graphical program such as phpMyAdmin or MySQL's built-in monitor program, as we will do here, at a command line:

mysql --password --user=root

After entering your MySQL server's password, you should see a welcome banner and a command prompt:

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.51a-community-nt MySQL Community Edition (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>

At the prompt, enter the commands to create the database (in this example, imaginatively named "drupal_db") and a user of the database ("drupal_user"), with a password and all privileges within the database:

CREATE DATABASE drupal_db;
GRANT ALL ON drupal_db.* TO drupal_user@localhost IDENTIFIED BY 'password';

(Naturally, the unsecure password used in this example is for illustrative purposes only and should never be used for any Drupal installation on the Internet.)

Within your web browser, go to your Drupal homepage, index.php. For instance, if your chosen Drupal root directory is /_w/Drupal on your D: drive (as I have done), and you have defined within your Apache configuration file an alias /m_d/ pointing to D:/, then your Drupal's URL would be http://localhost/m_d/_w/Drupal/. The index.php detects that Drupal has not been installed, and automatically forwards you to the install page, at http://localhost/m_d/_w/Drupal/install.php?profile=default, shown in the figure below.

Choose language
Figure 3. Choose language

In this Drupal installation, we will elect to use English, after which the installation script presents us with the database configuration options.

Database configuration
Figure 4. Database configuration

In the preceding figure, it is evident, from the checklist on the left, that we have gone from the first step — choosing a language — directly to the third. Presumably, Drupal confirmed that the MySQL server is running and is up-to-date enough to be compatible with Drupal 6.0.

Enter whatever values you had earlier chosen for your database name, username, and password. Click the "Advanced options" link if you wish to change the server name from its default ("localhost"), or set a port number, or assign a table prefix. That last option would be valuable if, for whatever reason, you choose to have your Drupal tables share a database with another application's tables, and you want to distinguish all of the Drupal tables — perhaps for sorting reasons, or more critically if the other application has one or more tables already using the same names as Drupal's tables.

Installing files progress
Figure 5. Installing files progress

If all goes well, the installation of the Drupal files should progress until it is completed. Figures 5 and 6 show screens that may be visible only for a moment, depending upon the speed of your computer.

Installing files completed
Figure 6. Installing files completed

When the file installation is finished, you will be ready to set the initial site configuration.

Configuring Drupal

Configure site
Figure 7. Configure site

The site's web server name will default to whatever value was specified earlier. As explained on the configuration screen, the site email address is the one that will be used to send automated administrative messages, such as user sign-up confirmations. Consequently, be sure to use an address from the web site's domain, e.g., admin@example.com, to reduce the chances of those messages being tagged as spam by the recipients' email services. This is not applicable if the Drupal installation is on a local web server only, perhaps intended for development purposes.

Specify a name, email address, and password for your administrator account. Unlike the aforesaid site email address, the admin address is not displayed to site visitors. The security strength of your chosen password will be displayed to you as you type it in; include mixed case characters and punctuation symbols if you wish to create a strong password, for any publicly accessible Drupal site. The time zone of your new Drupal site will default to that of your computer and thus probably does not need to be changed. By default, clean URLs are disabled, but can be implemented with configuration changes later.

By default, you as the administrator will be notified of updates to Drupal, which can reduce the risks of your site falling prey to recently discovered security holes. However, if your Drupal site is behind a firewall (which is usually essential for safety), then having Drupal constantly checking for product updates will cause its pages to load much more slowly than otherwise — even completely timing out. One solution is to disable automatic update checking, and simply do it manually as part of your administrative routine.

Installation complete
Figure 8. Installation complete

The installation process was successful, despite the warning message displayed in the figure above, which are a result of the local web server not having an email server set up. For a local-only development site, this is not an issue. Clicking the link "your new site" at the bottom of the installation text, returns control to the page index.php, i.e., your new Drupal web site's homepage.

Initial homepage
Figure 9. Initial homepage

The welcome message recommends that you login as the administrator to make any further configuration changes; enable additional functionality through modules; customize your site's design, via themes; and begin adding content. We will explore each of these four areas in more detail.

Administering Drupal

Drupal differs from many other major CMSs in that the administration interface is more tightly coupled to the non-administration interface seen by the anonymous visitor to your site. In the navigation menu (displayed on the left-hand side in the default theme), choose "Administer", which will show you all of the sections in the administration account.

Administration account
Figure 10. Administration account

Within the administration section, you will find six subsections where you will make all of the changes necessary to modify the appearance and functionality of your Drupal site, short of editing PHP code for a new module or CSS code for a new theme:

Content management
View and edit comments, stories, content types, user postings, Web feed, and content "taxonomy" (how stories are tagged, categorized, and classified).
Site building
Work with blocks (regions of pages), menus, modules (Drupal's functionality is organized into separate modules, many of which are built-in, and the rest available online), and themes.
Site configuration
Manage the administrative "plumbing" of your site, including date and time settings, input formats, and error reporting.
User management
Create and manage users, their registration requirements, roles, permissions, and access rules.
Reports
View log events, errors, and a detailed status report on your site.
Help
Quickly access links to the online Drupal handbook, as well as locally installed information on the 11 different aspects of Drupal, from blocks to users.

We won't discuss the details of all six subsections and the 31 subsections within them, but we will perform some common modifications made for a brand-new site.

Simple Site Customization

Most of the default site configuration values do not need to be altered. But you will certainly want to provide a name for your site, and perhaps a site slogan and other customizations. Go to Administer > Site configuration > Site information, and change whatever values you wish. In this example, we change the name of the site from "localhost" to "Drupal Sample Site," and made similar changes for the other values. When you are finished, click the "Save configuration" button at the bottom of the page; this is done for all administrative pages.

To verify that your changes took effect, go to your site's homepage by clicking on the new site name, at the top of the page, or the image to the left of it, which is "Druplicon," PHP's mascot and logo.

As noted earlier, the appearance of your site is determined by whatever "theme" is currently set as the default. Go to Administer > Site building > Themes to view the six initial themes packaged into Drupal 6.0.

Initial themes
Figure 11. Initial themes

You can see that the "Garland" theme is the only one enabled, and is the current theme of your site ("Default"). Change the theme to "Bluemarine" by enabling it and setting it as the Default. Earlier it was noted that the administrative interface in Drupal is wedded to the public-facing interface more than in many other CMSs, and the site theme is no exception. As soon as you saved your choice of Bluemarine, your administrative interface should have changed just as did the homepage, having inherited the homepage's theme. (You can override that via Administer > Site configuration > Administration theme.)

Lastly, we will add some sample content. Go to the menu item "Create content" > Story, and enter a name and some content for a new posting. Beneath the large content code, five expanding menus allow you to set the new story's input format, revision information, comment settings, authoring information, and publishing options.

Go to your site's homepage again, and you should see all of the customizations made above, including the change to the Bluemarine theme, as well as your sample story. In addition, the RSS feed icon will be visible now that your site has content that can be syndicated. Another and much more visible result of the new content, is that the installation welcome message seen earlier is no longer shown, having been replaced by your new story.

Homepage after customizations
Figure 12. Homepage after customizations

Resources

Unlike the majority of open-source CMSs, Drupal has substantial resources available to answer your technical questions and assist you in expanding your knowledge of how to make the most of Drupal. Start at the Drupal Support page, which has links to the extensive online documentation, forums where you can post questions, and the existing bug list, in case you encounter something within Drupal does not appear to be working correctly.

There are currently at least seven books on Drupal, and the number will undoubtedly grow in the future, as more developers discover the capabilities of this extensible content management system and how it can save them considerable time and effort for building web sites.

Michael J. Ross is a freelance web developer, working primarily with Drupal.


Return to ONLamp.

Copyright © 2009 O'Reilly Media, Inc.