How to build a Drupal site in 10 steps?

posted Jun 20, 2011, 8:36 AM by admin@ revitviet.vn

Drupal 6

Development environment:

  • PHP 5
  • MySQL or PostgreSQL database
  • Apache (or similar for web serving)

Content management systems (CMSs) are nothing new on the web. These systems are supposed to help users create, structure, and automate publishing content. Today, every company is looking to save costs and seems to be shifting attention back to the web (and hopefully to customers). The web is seeing another call to arms on all fronts from basic users to designers and developers. This time people are looking for good, flexible, free content management systems to run their web site.

One of the most popular content management systems available today is Drupal. Programmed in PHP, this powerful software comes from a large open source community who works together on the core. From large social entertainment portals to small local business sites, Drupal is deployed by beginners and professionals for many projects. Sites built on Drupal are notorious for powering social web features such as the Adobe Flex Showcase site, a noteworthy use of Drupal with Flex. The beauty of Drupal is that it does the heavy lifting for you while it adheres to web standards and easily offers social multimedia publishing. This article covers Drupal 6, released in early 2008.

With its core, Drupal allows web professionals to set up a site where all the content is editable and flexible. Adding pages and navigation links is really easy see Step 4 of this article). Secondary content, sometimes known as side content, is painless to arrange (covered in Step 5).

Read on to see how you can set up a Drupal site in just 10 steps. Learn about adding content, altering menus, modules, and themes, and how to get your site ready for search engines and users.

Step 1: Download and install Drupal 6

To begin, download Drupal:

  1. Grab a copy of Drupal 6 from the official Drupal website if you haven't done so already and unpack the compressed file named something like drupal-6-x.tar.gz (which is a file type similar to ZIP files). You should see a folder containing the Drupal 6 files and folders (see Figure 1).

           Figure 1. Drupal 6 core files

Do not alter any of the Drupal folders and files except for the contents of the sites folder (which lets you store your modules and themes).    Altering core files affects updates and maintenance, not to mention your sanity when things go wrong.

  1. Open the sites folder.

    You'll see two subfolders: all and default. The all folder lets you share modules and themes across more than one Drupal site. The default folder is where Drupal retains your site settings and its files. A powerful feature of Drupal is the ability to run multiple websites from the same core files, known as Drupal Multi-sites. This article steps you through setting up a single Drupal 6 site.

  2. Create a duplicate of the default.settings.php file in the /sites/default folder and rename the copy to settings.php (see Figure 2); be sure you allow the settings.php file to be writeable on your server. Drupal will set the file permissions back to read-only once the installation is done.

Figure 2. Sites folder with the sites/default/settings.php file

Installing Drupal

Drupal, like all software, has minimum requirements to run properly. Make sure your web server is running the following:

  • PHP: Version 5 is strongly recommended with at least 64MB of memory for PHP scripts.
  • An empty database (MySQL or PostgreSQL): Create an empty database with its own user name and password.
  • Apache or similar for web serving: Clean URLs is a feature that uses mod_rewrite on the server, so Apache is recommended.

Note: For details on how to set up a PHP server, refer to Setting up a PHP development environment for Dreamweaver.

When your system meets all requirements, you are ready to install Drupal:

  1. Upload or copy the Drupal files to your web server. Make sure you uploaded the (hidden) file .htaccess before you run the installer.

    The .htaccess file is required to enable clean URLs on your website.

  2. When your Drupal files are copied to your web server, and you have a blank database to use, open the install.php page in a web browser.
  3. When you see the blue Drupal install screen, start the install process by clicking Install Drupal in English. Drupal has translation packs so a Drupal site is not limited to just English. Follow the quick installation process below.

    Note: If you visit the install.php page and receive an error, or don't see anything on the page, then copy the files to your web server again and check your web server setup.

  4. Enter the site database info (database name and user). By default Drupal will look on the server localhost for the database, but if your server or host does not use localhost then you will need to enter the hostname or port number pointing to your MySQL server.
  5. Drupal will install the site database and provide you with a form to enter basic site info as well as your main administration account. Again, if you do not upload the .htaccess file that comes with Drupal, then you cannot enable Clean URLs for your site. Clean URLs provide the ability to choose a custom URL for content, so you could have /about and not /about.php appear in the browser address bar (which has become common on the web and offers the advantage of being search engine friendly).

When you arrive at the default screen of a fresh Drupal site, you see some instructions regarding your next steps but you can ignore that text if you wish and continue to Step 2 in this article.

Note: If you prefer editing config files as opposed to an install wizard, then edit settings.php before running install.php. This will skip the database step of the install.

Step 2: Choose site features with modules

Modules are Drupal plug-ins that add features to your site. Some modules enhance administration menus, some help with search engine optimization (SEO, covered shortly), and some provide social community features. Community modules found on drupal.org are licensed under GPL, which means the code is open source and free for you to use, modify, or learn from. jQuery, a popular JavaScript library, is even packaged with Drupal allowing modules to use Ajax.

Drupal is a big project in terms of the number of people contributing to its core and modules. Some modules are simple, such as adding bookmark links on pages, or that nice administration menu I mentioned earlier. If you were to take two minutes to read about every module available, it would take you more than a week to go through the entire list. Of course you would never install every module available—your site would slow down if not crash if you were not careful. Remember, your server is processing content through every module in some fashion. There are tons of modules for all your site needs and it is common to hear Drupal community members respond to questions with, "there (probably) is a module for that."

Core modules

By default, Drupal 6 does not turn on every module in its core. Features such as Blogs, file uploading, and custom clean URL paths rely on their modules being turned in the Administer > Modules area (see Figure 3).

Figure 3. The Modules administration screen.

Before downloading any new modules you should enable some optional Core modules. Enable any of the following core modules that appear beneficial for your site:

  • Aggregator: Allows you to bring in any external RSS feeds and their content to your site (for example, "Latest News from CNN" or "iTunes Top 25 Music Downloads").
  • Blog: If you're interested in having a site blog then this is it. (Note: Each user can have a blog or just some users.)
  • Forum: Text conversations; appears in a lot of community sites.
  • OpenID: Open standard for user logins; it is worth turning on.
  • Path: Lets you define custom clean URLs for your content nodes; everyone should consider this module.
  • Ping: Your site can notify services and sites that content has been updated.
  • Upload: Attach file uploads to content nodes.

To enable a module, visit the Modules administration page and select the check box next to the module name you want turned on, and then click Save. Feel free to review the other core modules I did not mention.

With great power comes user permissions. Modules have their own set of configurations and user permissions (see Figure 4). You must visit the Permissions administration page after enabling any new modules on your site (Administer > Permissions). I cover users and roles in Step 7.


Figure 4. A portion of the Permissions screen

Remember: Modules you download or create should only be installed in your sites folder, for example sites/all/modules.

What modules are safe to use?

Knowing what modules are safe to use can be a tough call. Core modules that ship with Drupal are safe whereas any module you introduce beyond that adds not just features but overhead. Each module uses additional server resources such as CPU, memory, and possibly storage. Video and file costs are usually at the top of the chain. To validate a module that is good enough to use requires a little investigating, as well as testing. Each community module page on drupal.org provides links to bug reports and support requests. I advise you to take a peek in each of those areas to get an idea of how active the module support is. The goal is to make sure a module matches a desirable standard and won't conflict with something you may have already installed.

The following list summarizes some free modules that I like to use:

  • CCK: Helps create additional fields for node types.
  • Views: Builds lists of content, allowing quick category pages in a block or page display.
  • Devel: Provides a popup tool for Theme production, and debug features for developers.
  • Admin Menu: Adds a nice top-floating menu for administration purposes.

Acquia, started by the creator of Drupal, spent time and money on assembling a release of Drupal that ships with popular modules. All the modules listed in the Acquia release are available separately for download on drupal.org. Companies looking for a Drupal support channel besides community forums see a download such as Acquia Drupal as a safer bet than grabbing random modules. Microsoft even offers the Acquia Drupal package for download to Windows customers.

Step 3: Choose the site look with themes

Drupal controls the look of your site with a theme, which is usually just a folder full of nice templates, CSS files, and images. You typically choose a site theme to be your front end. A theme controls the display by assembling all the theme parts (templates) while building each page; almost in a sever-side include fashion. Drupal comes with a handful of themes, most of which looked cool a few years ago. Luckily, Drupal allows new themes to be installed. You can create or download a new theme that will change the look of your site entirely and instantly restyle your content.

Free theme choices

You get what you pay for. I am not joking. I've seen free, cheap, moderate, and expensive theme costs. The free themes on drupal.org are mostly decent and if one of those themes works for you, then use it until you get sick of it and then look up a new theme. Swapping themes is like changing clothes, you just put the new style on. Don't expect free themes to be advanced (that is offer a lot of flexibility beyond a 3-column layout with header and footer). A good example of some advanced themes anyone can try out are Acquia Slate and Acquia Marina (used by SpreadFirefox.com), released by Top Notch Themes (in partnership with Acquia). The team at Top Notch Themes produces highly flexible, advanced themes that fit everyone's budget.

Quick theme color choice

Some themes have support for the Color module, which would enable multiple color variations within a single theme. You can change the colors of the default Garland theme in Drupal 6 by choosing Administer > Themes and clicking the Configure link for Garland. You will see a color wheel and a list of color presets (see Figure 5). Choose a preset or your own colors and click Submit to save your new theme colors.


Figure 5. Color module supported in the Garland theme

Step 4: Add content

If you are used to adding pages and sections of content to a site by adding folders and HTML files then you are in for a treat. Drupal does not need pages uploaded to add content. To add pages in Drupal, you just paste the page content into a form that saves the content in the site database. You can save plain text or full HTML content. Luckily, no programming or database knowledge is required to add content to a Drupal site.

Adding pages

Websites are about web pages and that's why Drupal provides this feature by default, so add some common pages. For new sites, I like to add pages such as Contact Us and About Us first. Follow these steps to add pages in Drupal:

  1. In the Navigation block (on the left side by default), click the link Create Content.
  2. You are presented two two choices of content to post: Pages and Story (see Figure 6). Choose Page.



Figure 6. The Create Content screen
  1. Enter the page title.
  2. If you would like this page to be linked to in the Primary or Secondary menus, then toggle open the Menu portion of the form to choose which menu this page will appear in and what the link text should say. Menus are covered in Step 6 of this article.
  3. Enter the body content, which can be HTML or plain text. If you enter custom HTML into the body field, then you should toggle open the Input Filter area and choose Full HTML. If you are missing content after the page is saved, then you may have forgotten to set the correct Input Filter.
  4. Click Save or Preview to see your new page. Preview does not save the content, so don't forget to click Submit after previewing.

You just learned how to add a new page in a Drupal site. If you added values in the Menu fields of the create content form then you should see the link to your new page in a menu near the top.

Pages = nodes

Most site content will be page nodes, a Drupal term used to describe saved content. If all you create are Page nodes for a site, that's fine (that is what they are there for). Nodes can be any piece of saved content, not just page types. Story and Blog posts are also nodes. When you add a Video module, for example, you would see a Video node type added to your site. To create your own node type (for example, Press Releases or News ), go to Content > Content Types > Add Content Type.

Step 5: Choose secondary content with blocks

Blocks are not nodes but do contain content, usually secondary content. A Drupal theme has defined areas on its page template known as Regions where the Blocks appear. Blocks are usually positioned in sidebar regions, however, you can add a Block to the header, content, or footer regions if you want. The more Regions a theme has, the more flexibility there is with Block positioning.

Drupal ships with a dozen or so blocks, including Who's New, Who's Online, Search, and one of my favorites, Syndicate, which adds an RSS icon in any region I like. Modules even add new blocks where necessary, and you can add custom HTML/PHP blocks with a simple form. Most blocks are disabled by default, and there is no limit to how many blocks you can have on a site (enabled or disabled), but administering a long list of blocks may slow down the Blocks administration page and affect site performance.

To help fill up a site adding blocks is a good move. When you add external RSS feeds to Drupal, each feed generates a new block just begging to be placed in some region. Go to the Administer > Blocks page to choose which blocks will appear on your site (see Figure 7).





Figure 7. The Blocks administration screen

Configuring individual blocks

Just like themes and modules, each block has its own configuration settings available, just click the Configure link next to the right of each block name. You can override the default block title and configure it to appear on all pages or just some. For example, the Powered by Drupal block offers color and size options.

Step 6: Set up menus and navigation

Navigation in the Drupal world is controlled by its Menu layer. Menus are lists of links that can have a hierarchy. By default every Drupal site has three menus: a Primary menu, Secondary menu, and Navigation menu. The Navigation menu is populated by default and has links that usually appear for logged-in users by default. Primary and Secondary menus are used for top-level navigation (such as main pages or site sections). You can even create menus from scratch. Any menu can be turned off or on and have an altered appearance. The power of Drupal is not just administering the order of menu items but fully respecting user permissions. For example, if a user doesn't have access to a page, then Drupal will not add the link that exposes that page.

Web standards for Drupal

A long-time feature of Drupal has been its dedication to using web standards markup, such as the use of lists for menus and navigation. Proper use of <ul> and <ol> list tags was one of reasons I began to like Drupal years ago. I felt it build sites similar to me doing so by hand, only quicker. The Drupal community has a large number of web standard advocates and it is uncommon to see non-XHTML markup in your pages. Knowing Drupal builds menus the way I would by hand leaves me to worry only about the type of links I want and what styles I'll render them with.

Step 7: Define user settings, roles, and permissions

One major difference a CMS brings is the ability to control not just content but users in a similar manner. Your site can allow anyone to register as a user, which is on by default, or you can lock people out from public registration and personally accept every user that signs up. These options are listed under Administer > User Settings. You can also edit any e-mail template the system will generate for users; everything from forgot password messages to a welcome e-mail.

Administering users individually is not an ideal way to run a site; instead you would want to administer broad groups of users, known as roles. By default, Drupal comes with two user roles: Anonymous and Authorized. Both roles are locked, which means you cannot delete them. Anonymous users are general visitors who are not logged in. Authorized users are site members who are logged in. You can come up with your own custom roles and assign custom permissions to any role. Custom roles cannot affect anonymous users, only authenticated members. Some people create roles named staff or moderators. To assign a role to users edit any account under Administer > Users and choose each role they need.

Each module and feature in a Drupal site has a set of permissions that needs to be tied to roles. Every module you enable should have at least one permission check box on the Administer > Permissions page. This page is where you will choose permissions per user role, so it is best to come to this page when you have completed adding roles and installing your modules, so you can set the permissions up in one move. Set some permissions for both anonymous and authenticated users, plus any role (or roles) you added.

As the site administrator (user #1) you have permission to everything already, and do not grant permissions to everything on the site to just any role. Be sure to think about what you are activating and for who.

Step 8: Get ready for search engine optimization

Learning how to optimize your site for search engines takes a lot of reading, planning, testing, and reporting, and the process never ends. When it comes to SEO, you need to start with the basics: Content markup should always use <h1>, <h2>, and <h3> tags for headings and <p> tags for body text; Drupal can help with these through Input Filters mentioned before.

Standard elements you need in place to do some real SEO tilling include meta tags, site maps, and clean URLs. The list of modules and next steps are thankfully packaged in a community module known as the SEO Checklist module. This helper module provides a list of tasks, modules, and services that help your site get spidered well. Not every task is required, but you should complete a majority of the tasks recommended by the module, especially adding meta tags and installing the XML Sitemap module.

Step 9: Optimize performance

Each module takes up resources on your server, but not every site needs a super beefy server to broadcast its pages. Drupal ships with some basic performance optimizing features that affect your entire site in a positive way with an internal caching feature and the ability to compress all CSS and JavaScript files.

Page cache

The internal page cache feature of Drupal 6 is decent for most sites to start with. Drupal broadcasts stored compressed cached pages to anonymous users, resulting in faster internal page assembly. Essentially, Drupal would not have to rebuild a page each time it is viewed until the cache reloads. This useful feature is on the Administer > Performance page. To activate it: click the Normal radio button and choose at least 1 minute under the minimum cache lifetime. I recommend enabling the Page and Block cache options as well.

Compressing CSS and JS files

Now that Drupal can internally cache pages you will see processing of requests faster for new users, but you continue optimizing by compressing all the external styles and script files that load for each module. Each module adds a new <link> tag for its CSS in your <head> code, the same goes for each JavaScript file needed by a module. To help speed up page loads even more, Drupal can compress all these styles and scripts into a single set of files (one for every CSS style, and one for every JS file on a page). This will speed up page delivery and rendering.

You can enable CSS and JS compression in the Bandwidth Optimizations area of the Performance page. Pages really load fast when this setting is turned on, but be warned: if you're changing a theme file and leave this feature on, your changes will not appear until the cache clears on its own or you click the Clear cached data button at the bottom of the Performance administration page.

Step 10: Prepare for automation and backups

This step is necessary to maintain the success of running your Drupal site. Two things you need to do now are update site content and back up your site! Don't risk loosing all your work only because you forgot to back up—automate backups and content updating. You can have the site update its content and feeds, submit updated site maps, flush old caches, and back up the entire database without you needing to be there.

Automated webmaster cron

Out of the box your Drupal site cannot update itself without your help, or help from someone else; how about a robot? Your web server is a robot you can program to run what are known as cron jobs or cron tasks, which are scripts that run at certain intervals. Drupal needs a cron setup (pointing to cron.php every hour or so). This allows Drupal to run any automation tasks you set up, such as backups, updating RSS feed or blocks, and indexing new content properly.

Read the official Drupal handbook page on cron.php and cron tasks. If your server does not allow you to add cron tasks, then I recommend a module called Poormanscron that will work fine for getting started.

Back up! Back up! Back up!

Backing up is a necessary task for every site. You should back up before updating modules, updating Drupal, or even before adding any new modules to your site. This is an easy precaution to take. There will be a time you will need to update your site modules or core. The Drupal handbooks offer detailed instructions on how to perform an update to your site and modules, so I ask you read those details while I offer a quick, painless way of backing up that is cost effective and takes just one click.

All hail the Backup and Migrate module for Drupal! This module does a lot of tasks in just one click by backing up your Drupal database properly and compressing the backup into a tiny file that you can download or save in a files directory on your site. You can even automate the backups.

Where to go from here

This concludes the first article in my series covering Drupal 6. By now you should be familiar with the various Drupal terms and administration areas of your Drupal site. Your work doesn't stop here. The responsibility of a CMS is that you need to use it. In fact, records have shown that migrating to a CMS slows during the adoption phase, which is when people are supposed to be using the system. Basically people are hesitant to learn a new system or are not properly trained. Do not let that happen to you or your company.

In my next Drupal article, Working with Drupal in Dreamweaver CS5 (coming soon), I will be covering themes and what designers need to know to assemble their own.




Comments