Jump to content

How to Install Drupal

+ 1
  Angela Byron's Photo
Posted Oct 29 2009 10:15 PM

The first step to using Drupal, of course, is to actually get the software and install it. Drupal comes with an installation script that will walk you through a few screens to gather information and then set up your database and create your site settings file for you. We'll look at everything you need to make that process run smoothly; you'll find that installing Drupal is quick and painless once some basic requirements are in place.

Before You Begin Installation

Prior to installing Drupal, it's important to make sure that you can actually do so, and understand a bit about how Drupal is structured. This section provides a checklist of Drupal's requirements, and also highlights important things in the Drupal file structure that are worth knowing before diving into the installation process.

Gathering Requirements

It's important to have a few things ready prior to installing Drupal. A full list of requirements is available at http://drupal.org/requirements. Use the following as a basic checklist prior to installing Drupal:

  • Ensure access to a web host or local development environment with the following:
    • A web server, such as Apache (http://httpd.apache.org), which handles serving up Drupal's pages to the browser. Having access to Apache's mod rewrite extension also allows you to use Drupal's "Clean URLs" feature, which transforms URLs like http://www.example.c...x.php?q=contact to http://www.example.com/contact.

    • PHP (http://php.net), the dynamic scripting language that powers Drupal. Drupal 6 requires at least PHP version 4.3.5, although PHP 5.2 or higher is recommended. The requirements page at Drupal.org has more information on required and recommended PHP extensions, most of which are enabled in PHP by default.

    • A database server, such as MySQL (http://mysql.com), where Drupal will store all of the content, data, and settings that it needs in order to function.

      Note: We assume that you are using Apache and MySQL. For additional help and support with other web and database servers, see http://drupal.org/ge...arted/6/install


  • Write down the following information from your web host:

    • Your (S)FTP or SSH username and password, so you can put Drupal's files into place.
    • Your database server's details, including username, password, and database name, so that Drupal can connect to the database. Some web hosts also require additional information to access the database, such as specifying a remote hostname or a specific database port.


  • Before you start installing Drupal, you also need a database to which it can be installed; Drupal doesn't create the database for you, as this normally requires "elevated" permissions on a server. Drupal can be installed either in its own separate database, or alongside other applications in a single database using table prefixes, but it's generally better if it has its own dedicated database. Check with your hosting provider or system administrator if you need information on how to create a new database, and jot down its name for later. Also, make sure you have the database username and password handy too.

    Note: For development purposes, you may find it easier to have your web environment installed locally to make your changes prior to uploading them to their final locations. There are several free programs that are more or less a "drop in and go" solution, including XAMPP) on Windows and Linux, WampServer on Windows, or MAMP on Macintosh.


Once you have checked to make sure you have everything, you're ready to begin.

Downloading Drupal

The first step before installation is to actually acquire the Drupal code. You can use the Drupal source code provided at http://usingdrupal.com/source_code, or you can download it directly from Drupal.org. Here are the steps to get it from Drupal.org:

Download links on the Drupal.org website

Posted Image

  • Go to http://drupal.org and you will see several links to download Drupal. They are all marked in the image above. Click on the Download tab in the upper-right corner of the screen.

  • The following page lists all of the types of projects you can download: modules, themes, translations, and so on. Click the "Drupal project" link to get to the Drupal core's page.

  • The release table, shown in the figure below, "Drupal versions listed on the download page", lists the available versions in order from newest to oldest. Unless you are helping with development, you only want to download those versions that are marked as Recommended. These are referred to as "stable releases." To use the examples in this book, click the Download link for the version listed as "Recommended for 6.x."

  • Drupal files are packaged using the tar program and compressed with gzip. This gives the file an extension of tar.gz. These files behave similarly to "zipped" files. Save the file and then extract the files using your favorite extraction application.

  • Place the extracted files on your web server using an (S)FTP program, or by logging in via shell access and downloading and extracting the files directly on the server.


Drupal versions listed on the download page

Posted Image

Drupal's Files and Directories

Now that you have downloaded Drupal, you should take a few moments to open it up and take a look around. Getting familiar with the basic structure and locating important files and directories can take some of the mystery out of how all of this works. When you open up the Drupal folder, you will see the files structured as shown below.

Posted Image

The important pieces that we'll be covering here are the installation files, along with the sites directory. The install.php and update.php files are the two scripts that actually do the work according to their respective names. Because they are located in the top-level folder, also called the Drupal root directory, you can access them directly in your browser's address bar by typing in something like http://example.com/install.php. In addition to the scripts themselves, there are also two text files, one for each operation: INSTALL.txt and UPGRADE.txt. These files contain instructions on how to use the scripts.

Most first-time Drupal administrators will take a look at the directories in the image above and place contributed and custom modules and themes respectively into the modules and themes directories in the Drupal root. That is where Drupal keeps the core modules and themes, so it only makes sense, right? Placing your files there will work, and Drupal will recognize them; however, this becomes a problem when you first attempt to update to the next security release - overwriting these directories with the new core versions will destroy any modifications that you have made. The best practice is to keep all of a site's contributed and custom code inside the sites directory. Unless you are running a complex multisite installation, this means that you should create new modules and themes directories inside of the sites/all directory, and place your contributed and custom code there, as in the image below, "Contributed modules and themes go under the sites/all directory". This way, all of the files that are particular to your site are in one tidy location rather than all mixed up together with the core files. This makes it much easier to work with when performing upgrades.

Contributed modules and themes go under the sites/all directory

Posted Image

Multiple Sites from One Drupal Installation

For more advanced setups, one of Drupal's most powerful features is the ability to run multiple Drupal websites off of the same single set of files. This is referred to as Drupal's multisite capability. The example websites at http://www.usingdrupal.com use this feature in order to run off of the very same source code files that readers can use on their own computers.

How does it work? On the Apache side of things, a virtual host entry is set up in httpd.conf for each subdomain to point to the same set of Drupal files, like so:

<VirtualHost *>
  ServerName usingdrupal.com
  ServerAlias *.usingdrupal.com www.usingdrupal.com
  DocumentRoot /home/www/public_html
</VirtualHost>


Then, on the Drupal side of things, we create a new folder within the sites directory for each subsite, each with its own settings.php file and files directory. You would end up with the settings being located at sites/jumpstart.usingdrupal.com/settings.php. When a browser hits a URL like http://jumpstart.usingdrupal.com, Drupal searches through the sites folder for the entry that matches best, then loads its settings file.

The multisite feature is not limited to just subsite relationships like this, however. Completely different websites can also be shared, each with modules and themes specific to it. You can even do trickier setups like sharing database tables among the various sites to have a single sign-on or searching across content on all websites.

For more information about Drupal's multisite feature, consult the documentation on Drupal.org at http://drupal.org/node/43816.

Installing Drupal

Once you have met all of the requirements and gathered the information you need, you can get down to the installation. These instructions assume that you have already created your database, downloaded Drupal, and placed the extracted files on your web server:

  • Set Drupal up to create your settings for you. Within Drupal, copy sites/default/default.settings.php to sites/default/settings.php - that is, without the default. at the beginning of the filename. You will also need to make sure that the new settings.php file is writable, such as with the command chmod 666 or chmod a+w sites/default/settings.php. Your web host should have more information on how to make files writable in their environment. Also see the documentation in the Drupal handbook under http://drupal.org/node/202483.

    Warning: Make sure that you copy the file, not simply rename it. Drupal needs both files to exist in order to create your settings file for you properly.

  • Now you can navigate to http://www.example.com/install.php to begin the installation process.

  • The first page of the installation allows you to choose a language, as shown in the image below, "Language selection for installing Drupal". By default, the only language available is English. However, you may also download other translations and install Drupal in your language of choice. Go ahead and click the Install Drupal in English link.

    Note: The next screen will initially check for correct permissions before letting you proceed. You may need to change permissions on the parent sites directory, depending on your host configuration. View the help pages referenced in the installer error messages for more details.

    Language selection for installing Drupal

    Posted Image

    Providing all went as expected, you should see a screen asking for your database credentials, as pictured in the image below, "Database configuration during the Drupal installation"

    Database configuration during the Drupal installation

    Posted Image

  • Remember earlier when you wrote down the details of your database connection, including username and password? Now it's time to use them. At a minimum, you need the name of the database, the database username, and the database password. If your web host requires additional information such as hostname or database port, expand the "Advanced options" fieldset to enter these options. Once you have entered all of the database information, click the "Save and continue" button.

  • The next page, as shown in the image below, "Configuring settings during the Drupal installation", contains a list of initial settings that should be configured on any site.

    Configuring settings during the Drupal installation

    Posted Image

  • First you should fill out the "Site information" fieldset. This deals with important global site settings:

    Site name
    This is the name that will be displayed in the title bar on all pages, as well as in the upper-left corner of all pages, by default.

    Site e-mail address

    All system emails will be sent from this address; for example, new user registration emails.

  • The next step is configuring the Administrator account. The Administrator account (also referred to as "User 1") is a "superuser" account that is exempt from all permission checking and has full powers to do everything on the site. You should therefore create a very strong password for this account (fortunately, Drupal will try and help you out by verifying the strength of the password as you type). Use this account sparingly, and only for administrative tasks. For day-to-day usage, create a second user account with fewer privileges.

  • The Server settings section can normally be left at the defaults selected. These options include:

    Default time zone
    Unless a user otherwise specifies her time zone in her account settings, all posts on the site will show up in the site time zone selected here. By default, Drupal will select the time zone of the browser during installation in an effort to guess what you'd like.

    Clean URLs
    Clean URLs allow you to have URLs such as http://example.com/about rather than http://example.com/?q=about. A test will be performed here to see whether the web server is correctly configured for Clean URLs, and if so, you will be able to enable this feature.

    Note: If you are having problems enabling Clean URLs, it may help to know that these are normally caused by one of the following:

    • Your web server does not have mod_rewrite (or an equivalent) installed.
    • Your web server is not properly reading the .htaccess file that comes with Drupal.


    Ask your server administrator to investigate whether one or both of these applies for you. For more information, you can read the Clean URLs section of the online handbook at http://drupal.org/node/15365.

    Update notifications
    Drupal 6 comes with a new feature to check for updates of new modules, themes, and Drupal core automatically, and will inform you when updates are available. This option (checked by default) is highly recommended, as it helps ensure that your site is up-to-date on security releases.

  • Once you have all of your settings entered, click the "Save and continue" button.

  • The final screen informs you that the installation is complete and you're ready to proceed with configuring your new website. Click the "your new site" link to begin your Drupal adventure! The image below "A newly installed Drupal site" shows the initial Drupal screen when it's first installed.


A newly installed Drupal site

Posted Image

It's important to keep Drupal updated once it's installed.

Using Drupal

Learn more about this topic from Using Drupal.

With the recipes in this book, you can take full advantage of the vast collection of community-contributed modules that make the Drupal web framework useful and unique. You'll get the information you need about how to combine modules in interesting ways (with a minimum of code-wrangling) to develop a variety of community-driven websites -- including a wiki, publishing workflow site, photo gallery, product review site, online store, user group site, and more.

See what you'll learn


Tags:
0 Subscribe


0 Replies