Chapter 2. Setting Up the Development Environment

What on earth is a development environment and why do I need it? It is fairly widely accepted that during the process of building your website, you should not make it available for people to use over the Internet. Making your site live, while you are still making changes and breaking and fixing things, means that it is possible for people to find your site, attempt to use it, and form an exceedingly bad opinion of your web development skills. You might, in the worst case, find that you have even inadvertently allowed malicious users to gain access to sensitive information due to improperly implemented security settings, among other things.

Rather than allow the public access to your work in progress, it is far better to set up a PHP‑enabled web server on your home or office PC. This server, along with PHP and your database, can then be used to design and build everything just as you want it, before transferring the final product over to the live site. A development environment is precisely that machine, along with its attendant development tools and technologies, where you can build your site. This chapter therefore will ensure that you set yours up correctly and efficiently so that you can begin working on Drupal directly in the chapters that follow.

Specifically, we will discuss the following important topics:

  • A brief introduction to the technologies involved
  • Obtaining and installing Apache, MySQL, and PHP
  • Obtaining and installing Drupal
  • Upgrading Drupal
  • Troubleshooting common problems
  • A short tour of Drupal

Installation and setup for Apache, MySQL, and PHP will only be covered for Windows because we trust that Linux hacks will have everything installed already (or will know how it is done). On the off chance that you don't have everything installed, a quick glance over the instructions given on the software-in-question's site should suffice to get you on your feet. The installation procedure for Drupal is much the same for Windows and Linux; so people using either can follow along with the Obtaining and Installing Drupal section.

Before we begin, however, there is one crucial bit of advice to be given:

Note

Ensure that you have access to a good, preferably lightning fast, Internet connection, as you will be downloading a fair amount of software.

For those users who have already installed various bits of software, you might find it convenient to skip whatever sections you do not need, going over only those that are of interest. As well as providing information on installation, this chapter will also have a troubleshooting section addressing some of the most common errors associated with the setup process for Drupal.

It should also be noted that because Drupal has been developed with flexibility in mind, it is possible to use it off IIS as an alternative web server, as well as utilizing PostgreSQL as an alternative database because support for these are actively being developed. Rather than show how to set each and every one up, we will focus on the most popular combination of Apache, MySQL, and PHP.

The Drupal Environment

I know most of you will be eager to get going at the moment, and might well prefer to dive straight into making modifications to your Drupal site. Before we do so, it will be of real benefit for you to take a few moments to read over this section to gain an appreciation of how everything is put together behind the scenes. Having a basic knowledge of how the various technologies co-operate in order to provide you with a working Drupal site, will help you immeasurably in the long run.

The best thing to do to begin with is take a look at each of the individual underlying technologies we will be using:

  • PHP: PHP, or PHP Hypertext Preprocessor, is the language in which Drupal is written. Recently it has received a major upgrade and is now more or less a fully functional Object Oriented Language, with some very powerful features. PHP is widely used on the Internet for a multitude of different projects and is renowned for its ease of use. The current version of PHP is PHP 5, which is what we will use in this book for our demonstration since the latest version of Drupal is PHP 5 friendly. However, you are welcome to use version 4 because this is what most internet service providers use at present. The good news is that we will not have to delve deeply into programming code in order to build our site—Drupal handles most, if not all, of the complex programming issues.
  • Apache: This is the web server we will use to serve web pages during the development phase. Apache is the most popular web server on the Internet, with millions of live sites using it every day. In fact, as the Apache website says: It is more widely used than all the other web servers combined.
  • MySQL: This is the database software that we will use to store all the information required to keep the website running. Everything from customer details to product information and a host of other things will be stored in the MySQL database. Keeping with the trend of popularity, MySQL is also the world's most popular bit of database software with over six million active installations worldwide.

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 purposes of this book is called Apache2Triad.

Now that we know what we are using, it is important to take a quick look at how we are going to be using it. The following diagram shows a simplified view of how everything works, with the shaded section denoting the Apache2Triad package containing the Apache web server, PHP interpreter, and MySQL database, with Drupal installed on the system:

The Drupal Environment

So, whenever a user does anything with your Drupal site (hopefully like contributing meaningfully), here's what happens:

  1. The relevant information is bundled off to the server in the form of an HTTP (HyperText Transfer Protocol) request. An HTTP request comes in two forms—either a GET or a POST. For our purposes, it is not important to understand how GET and POST work, as long as you understand that information can be captured from the user and sent to the server for processing using these requests.
  2. The server receives the HTTP request and says, Ah! This is a PHP page that has been requested. I need to send it off for processing by the PHP engine. The PHP page then gets processed and executed appropriately, and any actions that are required as a result of the user's request are performed.
  3. Once that is done, an appropriate response is returned by the server to the user's browser, and the cycle continues.

There are quite a few methods of providing dynamic web content that don't rely on PHP server requests. Instead, processing is done on the client side of the application (in other words, on the web browser). We will take a look at how to enhance your web pages with JavaScript much later on, in Chapter 9, but what you have been shown here is fundamentally how everything works, even if there are exceptions to the rule.

While this section has been a bit of a whirlwind tour of the underlying technologies associated with Drupal, the information contained in here should prove to be invaluable at some stage. For example, knowing how everything fits together will often help you isolate the cause of any problems you encounter, allowing you to resolve them quicker.

Don't worry if this all seems a little daunting at the moment. Bear in mind that Drupal itself handles most, if not all, of the complexity associated with ensuring everything runs smoothly. As you will see, our job becomes one of customization rather than actual software development. With that behind us, let's get on with the installation process.

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

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