Installation Wiki

Drupal

From InstallationWiki

Jump to: navigation, search
Drupal
Official Page
Project Documentation
Download
Source Book
Drupal: Creating Blogs, Forums, Portals, and Community Websites
Drupal: Creating Blogs, Forums, Portals, and Community Websites
ISBN 978-1-904811-80-0
Publisher Packt Publishing
Author(s) David Mercer


Contents

[edit] Setting Up the Development Environment

In order to create a workable development environment for Drupal,we need to install APACHE web server, PHP interpreter, and MySQL database.

Now, since we don't want to waste too much time downloading and installing all the different pieces of software we need individually, we are going to use a package installation, which provides us with everything we need using only one installation. The package we will use for the purpose is called Apache2Triad.

[edit] Obtaining and Installing PHP, Apache, and MySQL

To begin with, open http://apache2triad.net/, which is the homepage for the Apache2Triad project and click the Downloads link in the left-hand box towards the bottom of the screen. This will take you to the downloads page on the SourceForge site at: http://sourceforge.net/project/showfiles.php?group_id=93507.

Select the package you wish to use.Here we are using package 1.5.3, but you should feel free to use a later version.Once you have clicked Download for a package you will be presented with a list of download options. Release package 1.5.3 has only one option as shown here:

This is the package we will download and install. In order to do this, simply click the package name .exe file, which will take you to a list of mirror sites from which you can choose one to provide you with the download. A mirror is simply a server that provides all the same facilities at a different geographical location this is done to reduce the load on individual servers and provide faster downloads to people all over the globe. Make your choice and click Download to begin.

Depending on your PC's security settings, you may be given the following warning message:

Simply click Run to continue (or Save if you would like to hold on to a copy).

At some stage during the setup process, the installer will ask you to confirm several settings and you are free to make changes as and when prompted. All the configurable settings have sensible defaults; so you don't really have to bother with this too much. However, you will be asked to enter a password. You will need to use 8 characters or more and preferably use some numerical digits as part of the password.

Once everything has been done, you should receive the following message:

Make sure you save and close whatever important documents you have open before clicking OK. Once your machine has restarted, you will find that you have a whole list of new and exciting options to explore from the Apache2Triad option under All Programs in the Start menu. For example, the following options are made available with the 1.5.3 distribution:

There is quite a lot more than what we really need for our immediate purposes, but just to ensure that everything is going according to plan, click open site root in the Start menu and you should be shown the following web page in your default browser:

This confirms that everything is up and running as expected. Pretty easy so far! One thing to make note of in the previous screenshot is the final link called htdocs. Traditionally in Apache servers, the folder on your file system called htdocs is known as the root folder.

From this we know that we will have to locate the actual folder called htdocs on the file system in order to know where to put Drupal once we have downloaded it. Assuming you have gone with the default setup, you will find htdocs in the following directory (on Windows machines) along with everything else that was installed and created during setup: C:/apache2triad/.

We now have a platform from which we can begin building the Drupal site. Of course, we still need Drupal.

[edit] Obtaining and Installing Drupal

Head on over to http://drupal.org/ and click the Drupal version number you wish to download generally, the latest stable release is what you should go for. Click Download to grab the latest copy and save it to your C: drive, or your My Documents folder (or wherever you want).

Now, the Drupal download is different from the Apache2Triad installer in that we will install Drupal ourselves; it doesn't come with its own installer .exe file. Instead we are asked if we would like to Save (or Open) a .tar.gz file. If you find that your PC doesn't recognize .gz files (this is for Windows users), then you need to download a zip program like WinZip (http://www.winzip.com), or preferably an open-source option like 7-zip (http://www.7-zip.org).

Once you are happy that you can open and decompress the downloaded tar.gz file then extract it to the htdocs folder of your Apache installation. If you now take a look, you will see something like this:

We still need to create a database and populate it with all the necessary tables and structures that Drupal will need in order to function even though, technically speaking, you could try to browse your Drupal pages because they are now within the htdocs folder. There are a number of ways in which this can be done, but let's stick to the most basic in order to make this section applicable to everyone.

  1. Open up a command-line shell. In Windows this can be done by clicking Start, selecting Run and typing in cmd.
  2. Type in the following command at the prompt:
    C:\ mysqladmin -u root -p create drupal
  3. Enter your password when prompted. (This is the one you entered upon setup of Apache2Triad.)
  4. Enter the MySQL command-line prompt by using the following command:
    C:\ mysql -u root p Once again, enter the same password you have been using until now, when prompted.
  5. In order to set a database username and password for Drupal specifically, enter the following command:
    mysql> GRANT ALL PRIVILEGES ON drupal.* TO nobody@localhost IDENTIFIED BY 'password';
  6. Remember to substitute values that are relevant to yourself in place of the bolded sections of this command nobody (your username), and password (your password). After this, you should have a screen that looks something like the following:
  7. Next, type in the following command to ensure these settings take effect immediately:
    mysql> flush privileges;
  8. Type quit to exit the MySQL command-line client, and then load the database by typing in:
    $> mysql -u drupal -p drupal <C:/apache2triad/htdocs/drupal-4.7.0/database/database.4.1.mysql

Remember to enter the correct password you have set for your drupal database user in this case it is ny4thi as shown in the above screenshot. The bolded sections may change depending on the user you defined in a previous step, and the version of Drupal you have obtained.

At this point all of the database setup for Drupal has been performed and we only have a few configuration tasks to deal with in order to complete the installation process. For those of you who are interested in taking a quick peek at what has happened under the hood during this setup process, open up the MySQL command-line prompt using:

$> mysql udrupal p drupal

Enter your password when prompted, and then type the following at the command line:

mysql> show tables;
mysql> select * from <tablename>;

The first command will reel off a list of all the tables that are now present in the drupal database. The next command can be used to look at the information in any of the tables given by substituting one of those present for <tablename>. Looking through the results you should be able to see that quite a lot of work has been done to ensure that everything our website needs has been created.

We can now move on to the configuration settings!

[edit] Configuration Settings

Go to your Drupal installation by navigating to C:\apache2triad\htdocs\drupal-4.7.0\ sites\default obviously your version number can be different. Open up the settings.php file in an editor of your choice and modify the following line that is on or around line 81:

$db_url = 'mysql://username:password@localhost/database';

For example, the demo site's settings are now:

$db_url = 'mysql://drupal:ny4thi@localhost/drupal';

because as you know we created a user called drupal and gave that user the password ny4thi, which allows them access to the drupal database that was created using the SQL script provided in the download. The only other setting we need think about at the moment is the base URL that describes the address of your website it is optional to fill this out; so if you find that there are problems with broken links and so on when you first check out the site, come back to this setting.

Assuming you are not using another server in a network, simply add in the extra folder to the default address and remove the hash (#) symbol from the front of the line, as shown here:

$base_url = 'http://localhost/drupal-4.7.0';

Remember to change the bolded section to the correct Drupal version according to which package you download.

If you have saved your files to some other location, then you will need to make your configuration settings accordingly. Once you are done, save the changes to the file and get ready for the acid test. If everything has gone according to plan, you should be presented with a fresh Drupal website when you navigate to the base URL in your browser, as follows:

If this is what you see, then congratulations, you are now the proud administrator of one default Drupal website. Of course, if you don't feel like typing in drupal‑4.7.0 every time you want to access the site, you are free to change the name of this folder.

Make sure that you make the corresponding change to the $base_url variable in settings.php to reflect any changes to the address otherwise you will end up with a broken site.

Effectively, that is all you need to do in order to install Drupal. Everything else henceforth is configuration and customization.

[edit] Upgrading Drupal

From time to time it becomes necessary to upgrade your installation of Drupal in order to keep your site up to speed and trouble free. Every now and then, for example, a security issue may be identified and it is important that people upgrade in order to avoid falling prey to malicious hacking.

If you are using a theme other than the default, it is possible that your site may break. It may be best to revert to the default theme before performing an upgrade.

For now, this note should not concern you at all because we have not even talked about themes it may be handy to remember at a later date though. Let's continue:

  1. Make a backup of your current database so that you preserve all the information added by users as well as any configuration changes you have implemented.
  2. Back up the old files, especially those that have important settings like your stylesheet or the configuration file contained in the sites/default/directory. This allows you to re-implement any important settings on the new site.
  3. Remove all the old Drupal files from your file system, and assuming you want to run your site from the same location, unpack all the new files into the same folder.
  4. Make the necessary changes to the configuration file based on the settings saved in the old one.
  5. Log in as the site administrator (this has to be user number 1), then navigate to your Drupal homepage and run the update.php script by accessing it from your browser. For example, the demo site's update page would be http://localhost/drupal-4.7.0/update.php. This will bring up a page of notes as follows:
  6. Read through these notes before you click the run the database upgrade script link to ensure that you perform any version-specific tasks that may be required.
  7. Click the link to bring up the following page:
  8. Select an update to perform (only if, for some reason, you are not happy with the automatic choice) and then click Update.

You are now fully updated and can continue as normal. There is another valuable source of information you should look at, whenever you need to make an upgrade, namely the Drupal site itself: http://drupal.org/upgrade/. This page contains useful notes and version-specific issues and instructions that could come in handy.

[edit] A Couple of Important Settings

There are some changes required for the Apache2Triad setup, but if you have gone with anything else (or if you already have everything installed), you might notice slight differences in the way things are laid out. Now, the reason we need to do all this is because we would obviously like any emails that are sent out by Drupal to come from a working email address that we can access, and we need to check that the mail() function, used by Drupal for sending an email, has an SMTP server to work with. As we will end up having to set this somewhere along the line anyway (assuming it's not already set), we may as well do it now.

Open up your php.ini file, which on Windows using Apache2Triad is found in C:\WINDOWS. Search for the lines that read:

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
sendmail_from = admin@localhost

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =

You need to provide PHP with an SMTP server that will work here. If you use Microsoft Outlook on Windows, then you can find which SMTP server you are already using by looking at the servers tab in the Tools | Accounts | Properties menu. As well as this, you will probably want something other than admin@localhost to be set here; so ensure you make these changes accordingly. For the demo site, the following changes were made:

[mail function]
; For Win32 only.

SMTP = smtp.dsl.<myserver>.net

smtp_port = 25

; For Win32 only.
sendmail_from = staff@contechst.com

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =

Obviously, you must have access to a working SMTP server if you don't have a server to work off, then you can't send emails from your site. This is not a massive problem for the meantime, and certainly, your live site will be able to send mails even if you can't from your development machine.

In order for these settings to take effect you must also remember to restart the Apache server.

You can restart Apache by double-clicking the Apache icon in the process tray (bottom right-hand side of your screen) and selecting Restart in the menu. You can also access the server through the Start menu. Once this is done, you can continue with Drupal as per normal.

[edit] Additional References

  • For instructions on Building Drupal themes, click here
  • For instructions on Customizing Drupal Theme, click here

[edit] Source

The source of this content is Chapter 2: Setting Up the Development Environment of [1] by David Mercer (Packt Publishing, 2006.)