Install Drupal 7 on a shared host

There are three tasks:

  1. Put the Drupal files on your server.
  2. Create a database for Drupal to user.
  3. Run the Drupal installation program, and tell Drupal about the database.

1. Put the Drupal files on your server

At the end of this task, all of the files that Drupal needs will be in a directory on your server. That directory will be accessible over the Web, at a URL you know.

Here are the steps in this task:

  • Prepare a place on your server for the Drupal files.
  • Download the latest version of Drupal from Drupal.Org, to your computer.
  • Upload the files to the server, in the place you prepared.

1.a. Prepare a place on your server for the Drupal files

You need to put the Drupal files in a directory on your Web server. The directory should be one that Web browsers can get to.

When you buy hosting, your hosting company will create a directory for you, called your home directory. Usually, the files in your home directory are not accessible over the Web. This lets you keep private files on your server.

The hosting company will create a directory inside your home directory, usually called public_html. This directory is available to the Web. It is the root of your Web site.

Suppose your domain is drupalzombie.com. This maps to the directory public_html on your account. You create a file called cow.html, and put it in public_html. So the path to the file is public_html/cow.html. The URL of the file http://drupalzombie.com/cow.html. Why? Because, in a sense, drupalzombie.com points to your public_html.

Suppose you create a directory in public_html, called emu. Then you create a directory in emu called wombat. You put the file eel.html inside wombat. So the file path on your server is public_html/emu/wombat/eel.html. The URL would be http://drupalzombie.com/emu/wombat/eel.html.

If you want your site to be one single Drupal installation, then you don't need to do anything. public_html is ready. Just put your Drupal files there.

Let's not do that. Let's create a subdomain. This will make it easy to have several Drupal installations on the same account. It's also good for testing things out.

A subdomain is like yellow.drupalzombie.com. There's an extra name on the front of the URL. The name typically maps to a subdirectory like subdomains/yellow.

Tell your server to create a subdomain, using your Web control panel. Click the Subdomains icon in cPanel, and type in the subdomain name:

Make a subdomain

cPanel will suggest that the files be under public_html. Change that to subdomains. It will make backup and other things easier. (I figured out the subdomains thing after this article was published. so some of the screen shots below have the Wrong Stuff. It should be subdomains.)

Note: you may have problems here with some hosting companies' services, like 1&1 and Namecheap. Their tools for creating subdomains are..., well, "different."

Any files you upload into subdomains/yellow will be accessible at http://yellow.drupalzombie.com.

1.b. Download the Drupal files to your computer

Drupal comes in different flavors. Each flavor has a different download URL.

The standard one is at http://drupal.org/download:

Download

The big green button tells me that the latest stable release of Drupal is 7.10 (but it will be higher when you read this). Get whatever version the green button tells you to.

I click the green button, and see:

Versions

Drupal has hundreds of files. They are compressed into a single archive, to make downloading easier. Two archive formats are offered: tar.gz, and zip. I usually use the zip one; it's easier to work with on my Windows PC. I click the zip link, and that downloads the file drupal-7.10.zip to my computer. Woohoo!

If you want a different flavor of Drupal, you download the archive from somewhere else. For example, if you want the amazing CyberCourse, you get it from http://cybercour.se, rather than http://drupal.org. Still, you'll end up with the same type of download: one zip file, containing everything you need.

Now I have the Drupal archive on my computer. I extract all the files from the archive. Here's how, in Windows 7:

Extreact

Extract all... creates a directory called drupal-7.10. Inside that is another directory called drupal-7.10. Inside that are the Drupal files:

Nested directories

This directory nesting is a common source of errors for beginners. We'll see why in a moment.

1.c. Upload the files to the server, in the place you prepared.

Remember that I created the directory subdomains/yellow. That's where the Drupal files go.

Start up favorite FTP client. Connect to your Web server, and navigate to the directory where your Drupal files will go.

Here's what I see:

Unneeded cgi-bin

mathieso is my user name, give to me by my hosting company. Your user name will be different. My home directory is /home/mathieso. /home/mathieso/subdomains/yellow is the root of the subdomain yellow.drupalzombie.com. I created that earlier.

cgi-bin is not needed for Drupal. Delete it.

Now, in your FTP client, navigate to the files on your computer that you want to upload. This is where the nested directories cause trouble. You might have a screen like this:

About to mess up

It would be a mistake to drag drupal-7.10 into subdomains/yellow. That would mean that the Drupal files would actually be in subdomains/yellow/drupal-7.10 on the server. That's not what you want. You want the Drupal files in subdomains/yellow. Open drupal-7.10 on your computer, so you get a screen like this:

Right!

(Remember: when you see public_html in a screenshot, imagine you see subdomains.)

Now drag all of the files to your server directory (hint: Ctrl+A often means "select all files"). You should end up with:

Files uploaded

If you've done this right, you should have a file with the path subdomains/yellow/index.php.

2. Create a database for Drupal to use

Drupal stores most of a site's content in a database. You need to create an empty database for Drupal to use.

I'm going to show you how to do it with cPanel. YMMV.

There are three steps:

  • Create an empty database.
  • Create a user account for the database.
  • Give the user access to the database.

2.a. Create an empty database

On the cPanel home page, do this:

Database tasks

Now:

Creating a database

You'll see:

Database created

Notice the name of the database. You typed "yellow" (or whatever). But the name of the database is [your user name]_yellow. Why? Because other users may also have typed "yellow" into the database name field. How would the server know which one was which?

User names are unique. So adding the user name into the name of the database ensures that the server can tell the difference between your yellow database and everyone else's yellow database.

Record the name of the database. You'll need to tell Drupal about it later.

BTW, the database name need not be the same as the subdomain.

2.b. Create a user for the database

You need to create a new MySQL user account, and give it access to the database. MySQL user accounts have nothing to do with user accounts on your computer or server. MySQL user accounts are just used for MySQL.

On the same page where you created the database:

Created a user

The user doesn't have to have the same name as the database. You can make up your own password, or have one generated for you.

Click Create User, and see:

Created a user

Record this information. You'll need to tell Drupal about it later.

2.c. Give the user access to the database

On the same page where you created the user, find the Add User to Database section. Select the database and the user:

Give user access

Click Add, and cPanel will ask you what privileges you want to to give the user. Grant them all:

All privilages

Click Make Changes. You'll see:

Added

So far, you've:

  • Uploaded the Drupal files to your server
  • Created a database for Drupal to use
 

3. Run the Drupal installation program, and tell Drupal about the database

Almost done!

Point your browser at the root of your new Web site, e. g., http://yellow.drupalzombie.com. The Drupal install program will run.

Choose the installation profile you want. Choose standard, unless you are installing a customized distribution, like CyberCourse. Don't choose minimal. It's for Special Purposes.

Standard installation profile

Choose a language:

Choose language

English is the default, but your can install dozens of other languages.

Tell Drupal about the database you created for it, using the information you saved earlier:

Database

Drupal will activate a bunch of modules:

Installing

Then you'll fill in the site information form:

Site information

The SITE MAINTENANCE ACCOUNT is your super-admin-user-can-do-anything account. Don't forget the username or password. Or you won't be able to do much with your site. Click Save and continue.

Congratulations!

You have a Drupal installation. Have fun!