Hour 3. Setting Up and Installing Drupal

What You’ll Learn in This Hour:

• What You Need for Your Drupal Site

• Understanding Drupal’s Version Structure

• How to Do the Installation

This hour shows you the process of setting up and installing Drupal. The Drupal site (drupal.org) and the author’s website (www.northcountryconsulting.com) provide additional information about installing specific versions of Drupal and using specific types of servers and hosts.

Did you Know?: Try a Test Installation

For your first Drupal installation, it is a good idea to plan to throw it out when you are finished. That way, you can experiment without worrying that you will live to regret your choices. Having thrown out your first Drupal installation, you will find that your second one is much easier and faster. That is because, if you do make a mistake (or two or three), you can take care not to repeat them when you set up the real site. If your first attempt is going to become your live site, you will have to go back and repair any mistakes. This applies to the most basic installation as well as to taxonomy categories and terminology for the objects you are creating in your Drupal site.

Planning for the Next Installation

Yes, before you take the first steps to install your first Drupal website, start planning the next installation. As the Internet and the software world have changed over the last few years, almost everyone now understands that software (much less websites) are not eternal. They require periodic maintenance and attention.

Vendors of commercial products are increasingly adopting a current-and-one-prior policy with regard to support: The current version and one prior version are actively supported with bug fixes and other forms of support. In addition, special upgrade pricing is usually limited to registered users of one prior version, although this is periodically changed for marketing reasons. Drupal, too, is on the current-and-one-prior schedule, although, of course, upgrade pricing is not an issue with free software.

Some products are revised annually, particularly if they are tied to the calendar (such as tax software). Other products, including operating systems and major productivity tools, are typically revised about every two years. It used to be that changes to operating systems set in motion a cascade of necessary revisions to end-user tools, but the cost and unpopularity of such cascades has made them less common.

Nevertheless, cascades occur. In the open source world, where there is no direct cost for the software, they are less costly than for commercial software, but the need to install new versions of supporting software still exists. For example, with Drupal 7, PHP 5.2 or later is required, although with Drupal 5, PHP 4.3.5 or later is required.

Drupal’s release schedule is published on the Drupal site. In addition, the release plans for the supporting software are well known. As you start to plan your Drupal site, take a moment to check out the schedules. Where you have choices, select the choices that will have the longest life.

Planning for Drupal

Drupal runs on a web server and stores its data in a database. The code for Drupal itself and contributed modules is primarily PHP. Other common web languages and protocols, such as CSS and JavaScript, are also used, but they rarely need to be considered: If you have a web server, it will almost always support them.

You also need an Internet connection if you intend to allow people to visit your site. You can install Drupal on your own computer and allow only people on your network to access it; you can even install it on your own computer and access it yourself from that computer. This is a common testing environment.

Get the full requirements for Drupal installations at drupal.org/requirements. As you install and test Drupal, watch for error messages. If you cannot immediately diagnose the problem, copy the error message and paste it into the search box on drupal.org. Most of the time, you will find several items or comments that report on or solve the problem.

Did you Know?: Repeat as Necessary

You may have to go through this section more than once because the versions of Drupal, database, and PHP are all interrelated.

Setting Up Hosting

Your hosting environment typically includes both the Internet connection and the web server. It frequently includes your database as well. If you already have a website, the easiest choice may be to install Drupal on that host. Just check that the requirements in this section can be met (and try a test installation to see if you encounter any errors).

Your hosting choices are the same as for any website—your own server, a colocated server at a hosting service, or a shared server. If you are using a shared server, make certain that it supports the products and versions that you need. In addition, you need to find out the vendor’s plans for upgrades to new versions. For example, some shared hosting services that provide PHP support took two years to make the transition to PHP 5 from PHP 4. At first, PHP 5 was an option, but then support for PHP 4 was dropped.

If you need a shared hosting vendor, the best choice for many people is to use one that already runs some Drupal sites. You can find a list of Drupal hosts at drupal.org/hosting. The absence of a host from this list is not necessarily an indication that it cannot host Drupal. (For example, Network Solutions provides a number of open source products, including Drupal, with automated installation scripts to its shared hosting accounts, but it is not on the list.)

Setting Up the Software

PHP and the web server are the primary software. PHP 5.2 or higher is required for Drupal 7 and recommended for Drupal 6. If you are using a shared hosting service, the versions they support are important as well as their upgrade policy. In many circumstances, Drupal will need to send email using PHP. Particularly on shared hosting servers, you might need to contact your vendor to enable this. Remember this is email sent from PHP and not the normal email application or web page you can usually access to send and receive email on your web server.

Did you Know?: Download a Bundle

If you need the software, you can install all of it in a free open source download. XAMPP is the cross-platform version that contains Apache HTTP Server, MySQL Server, PHP, and Perl. The versions are regularly updated to the current releases. It is available at www.apachefriends.org/en/xampp.html. You can search Wikipedia for a list of AMP Packages to find specific versions for Linux, Windows, Solaris, memory sticks, and more.

As for a web server, Apache 1.3 or Apache 2.x on Mac OS X, Windows, or UNIX/Linux is the recommended choice. Drupal also runs on Microsoft Internet Information Services (IIS) 6 or IIS 7.

The most common modifications needed are enabling the mod_rewrite extension for Apache or the Microsoft URL Rewrite Modules for IIS 7.0 on IIS. If you do not do this, Drupal will still run but will not be able to create clean URLs. See Hour 6, “Managing URLs: Cleaning, Redirects, and Pathauto,” for more on mod_rewrite.

By the Way: Working with Microsoft

Microsoft’s relationship to open source software has evolved over the past few years. It has reached out in a number of ways and has sponsored some Drupal events.

On a shared server, you may or may not have access to the PHP initialization values in php.ini. (If you do not have direct access to it, contact your hosting service; it may either give you access or make the change for you.) One common value on shared servers that might need to be overridden is the memory setting. It is often set to 16MB, but changing it to 32MB or 64MB will prevent some Drupal memory errors. Drupal is designed to be as fast and efficient as possible, but at some points in its processing, memory requirements can spike. The memory issue is a commonly misdiagnosed Drupal problem. It often occurs after you install a new module and then go to the modules administration page to enable it. That is a moment when memory can spike. Removing the module appears to solve the problem. It can then recur when the same module or another one is installed. Instead of blaming the error on the modules, increase the memory limit to handle these spikes.

Other common php.ini settings that may need attention are the following:

register-globals off

session_save_handler user

safe_mode off

Setting Up the Database

Drupal core has a database abstraction layer that makes it possible for it to use many types of databases. At the moment, MySQL and PostgreSQL are supported. Table 3.1 shows the versions that are required.

Table 3.1. Drupal Database Requirements

image

Shared hosting packages often limit the number of databases you can have, and they may also limit the creation of databases so that they are done only through a script on the shared server. In addition, some hosting services that provide scripts to perform an automated install of Drupal and creation of its database may not allow you to access the database features such as optimization and data export. This matters only if you need to extract all the data (as when you move to another host). If you are using a host-provided script to set up the database, make certain that you have access to all the functions that you might need for its maintenance. You may need to contact the hosting service to do this.

You need the following permissions for the account that Drupal uses to access the database: SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, and ALTER. Contributed modules may need CREATE TEMPORARY TABLES, LOCK TABLES, and other permissions (they should be identified in the module documentation). As noted, you need the ability to create a new database whether with the CREATE DATABASE command or by running a host-provided script that executes the CREATE DATABASE command only after checking that you have not used up your quota of databases and any other constraints the hosting vendor may have implemented.

Selecting a Drupal Version

This is the easiest part: Select from the current or the prior version after having checked the release schedule. Also, if you know the modules you want to use, check to see if they are available for the Drupal version you select.

The numbering convention for Drupal has two numbers: a major version and a release. Drupal 6.13 is thus the thirteenth release of Drupal 6. The number might be followed by -dev to indicate that it is in development. In the listings on drupal.org/project/drupal, you will find an indication of the recommended release for each version of Drupal.

Module numbering uses a similar approach. Because modules are specific to versions of Drupal, the module incorporates a Drupal version but not a release in most cases. Thus, the Panels contributed module can be numbered 6.x-3.0-rc1. The first part indicates that it is for Drupal 6; the x shows that no specific release is targeted (this is the common case). Following the hyphen, you find the module’s numbering. This is version 3 of Panels, and this is the first release (zero); -rc1 indicates that it is a release candidate (other common indicators are alpha and beta). Depending on the developer and the complexity of the module, you might see several release candidates as the module’s latest release is frozen and the last bugs are fixed.

Getting Ready

You are now ready to install Drupal. Double-check your hosting settings, create a simple HTML page (such as a Hello World greeting), and upload it to the server. Make certain you can access it from your browser.

Also, make certain that you can access your database host. Create a new database and create a single table in it using phpMyAdmin, MySQL Administrator, or MySQL Query Browser. (You can remove this database as soon as you have tested it.)

If you do not regularly use PHP, create a one-line PHP program to check the PHP settings on your server with the following code:

phpinfo();


Save it and place it in your server’s web root (where you successfully placed the Hello World page) and run it from a browser by typing www.myservername.com/phpinfo.php. You should see your server’s PHP settings.

If you cannot create a database and a table, or if you cannot create and run a PHP program, you will not be able to install and run Drupal. Particularly on shared hosting servers, much of the customer support is provided for the initial setup, so don’t be shy about asking.

Creating a Drupal Directory

Now, designate a directory for your Drupal files. It can be the root level of your website, or it can be a subfolder that you create specifically for Drupal. If you want to keep your Drupal files in their own folder, you can place a PHP file at the root level of your account to move to that folder. Particularly with shared hosting, you may already have an index.php file; if you do not, create one with this code:

<?php
   header("Location: http://www.mysite.com/mysubfolder");
   exit();
?>


If you do have an existing index.php file, you can move it to your subfolder or incorporate this code into it.

If you are using localhost to test your Drupal installation, you are done. If you are using a separate server, you may decide to keep a copy of your Drupal site on your own computer for safekeeping. If so, create that directory now.

By the Way: Using Relative Path Names

Within your Drupal folder, the names of files and subfolders are the same whether you are running in localhost on your own computer or in a path to an IP address or a domain name (which in turn may be a subdomain or a folder within the domain). Rather than repeating this throughout the book, files and folders within your Drupal director are identified by relative path names that begin with a dot. Any relative path name that is not otherwise identified is relative to your Drupal folder wherever you may have placed it.

Summary

This hour showed you how to install Drupal. You need a web server to which you have access to upload files. It must support a database for Drupal’s use (MySQL is most commonly used), and it must support PHP, including the mail function. Perhaps the most important point in this chapter is this: Leave plenty of time for your first Drupal installation. After working with it for a while, you might want to start over with a clean install.

Q&A

Q. What are the consequences of not having mod_rewrite installed?

A. The immediate consequence is that you cannot enable clean URLs. For some people, this is just a matter of cosmetics, but the consequences are much deeper. The ImageCache module, which is rapidly gaining a widespread base of Drupal users, requires clean URLs, and that, in turn, requires mod_rewrite functionality. Because the vast majority of Drupal sites are managed by people who turn on mod_rewrite (unless it is already turned on), it is rapidly becoming a de facto requirement. It is so much taken for granted that, for example, if it is not available, ImageCache simply does not work properly. It is worth the effort to turn on clean URLs.

Q. Likewise, what happens if I don’t have mail working from PHP?

A. You can run Drupal without it sending mail. After all, many websites do not send mail themselves. However, your Drupal site will be so limited that such a site is usable mostly for testing. For example, if you use your own computer as localhost for a test installation, the fact that it cannot send mail is not going to be a serious concern for your testing.

Q. If I follow the advice to throw out the first installation, what do I have to do?

A. Drupal stores information in two places: its own PHP files that you download from drupal.org and in the database table that you create for it. You can use a tool, such as My SQL Administrator, to select all of the tables in your Drupal database, and then drop them. The database will be empty. Alternatively, drop the entire database and create a new one. Dropping all the tables seems to have no adverse consequences and is a little faster. You can simply remove all of your downloaded Drupal files and replace them with newly downloaded files. Do not think you can speed things up by reusing settings.php. For a clean install, you want a settings.php created as described in this hour.

Workshop

Quiz

1. What databases work with Drupal?

2. What is the purpose of the Drupal 7 minimal installation?

3. Do you have to set up tables for Drupal?

Answers

1. MySQL and PostgreSQL (pgsql) work with Drupal 6 and Drupal 7. SQLite works with Drupal 7.

2. It is designed for module and theme developers to use during testing.

3. No, you only have to create an empty database.

Activities

Take the time to do a test Drupal installation as soon as you can. This is particularly important if you are running on a shared server or on your own computer. Even if you do not plan on creating your site for weeks or months, getting to the final page of the installation sequence will let you feel confident that your environment, including its database and PHP version (not to mention the Drupal version), are working properly.

Similarly, if you will be running your site on a different server from your test server, install Drupal there as soon as possible. If you will be relying on an administrator of a shared web server to update a version of PHP or to modify your shared settings, it is important to get that process started as soon as possible.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.23.98.106