Thursday, November 16, 2006

A New Website, Part Three - Installing Drupal

OK, picking up again after lunch.

I have downloaded the Drupal archive from the Drupal website to my home computer. Then, using gftp, I have uploaded the drupal archive from my home computer to the www/drupal directory. Again, if this were just an ordinary web account, with only one domain, I would have simply uploaded it in into the main document directory, www.

So the archive is sitting there. I can see it, it's called drupal-5.0-beta1.tar.gz - you can tell it's an archive because of the .tar.gz extension. This means that it has been both 'tarred' and 'gzipped'. Tarring packages all the files into one archive, then gzip compresses them. What I want to do is to unpack the archive. This will create the full directory structure, putting all the files in the right place.

In Linux, the command to unpack this archive is:

tar -xzf drupal-5.0-beta1.tar.gz

So I open up a terminal window, and then SSH into my website. I then (using the Linux change director command, 'cd') move to the www/drupal directory. Then I type the command to unpack the archive. It doesn't look like anything happened, but if I type 'ls' to view the contents of the directory, I can see the new file structure that has been created.

So I now have a file structure that looks like this:


Now I realize that I would rather have all the files in the drupal directory itself, not some oddly named subdirectory. As the instructions in INSTALL.txt state, "Move the contents of that directory into a directory within your web server's document root or your public HTML directory." Like this:

mv drupal-x.x.x/* drupal-x.x.x/.htaccess /var/www/html

Um, let's unpack that a bit. It's actually two separate commands:

mv drupal-x.x.x/* /var/www/html and
mv drupal-x.x.x/.htaccess /var/www/html

We need two commands, because the asterisk, '*', which means, 'all files and directories', won't move the hidden system file, '.htaccess'. So we need to specify each separately.

The 'drupal-x.x.x' of course means 'drupal-5.0-beta1' for us (they don't feel like retyping the INSTALL.txt file for each new release, I guess - not that it would be that hard to automate). And the destination directory, which they've typed as '/var/www/html' is for us the 'www/drupal' directory.

What I do is go to a higher level directory and do it all from there. So I type 'cd ..' to put myself in the main www directory. Now I'm going to enter my version of the command:

mv drupal/drupal-5.0-beta1/* drupal/drupal-5.0-beta1/.htaccess drupal

This will take all the contents of "drupal/drupal-5.0-beta1" and deposit them one directory up, in "drupal".

So I type the command.... and it fails. Let's try the full directory tree, /home/downes/www/drupal

mv drupal/drupal-5.0-beta1/* drupal/drupal-5.0-beta1/.htaccess /home/downes/www/drupal

It looks like nothing happened. That's usually good, in Linux. So I decide to look inside the drupal directory. This is what I see (I use 'ls -l' to list the directory fully, showing permissions, creation dates, and everything):

downes@resin(~/www/drupal)$ ls -l
total 1756
-rw-r--r-- 1 downes users 27066 Oct 31 09:55 CHANGELOG.txt
-rw-r--r-- 1 downes users 1431 Oct 31 09:55 INSTALL.mysql.txt
-rw-r--r-- 1 downes users 1073 Oct 31 09:55 INSTALL.pgsql.txt
-rw-r--r-- 1 downes users 8758 Oct 31 09:55 INSTALL.txt
-rw-r--r-- 1 downes users 18064 Oct 31 09:55 LICENSE.txt
-rw-r--r-- 1 downes users 1778 Oct 31 09:55 MAINTAINERS.txt
-rw-r--r-- 1 downes users 558 Oct 31 09:55 UPGRADE.txt
-rw-r--r-- 1 downes users 262 Oct 31 09:55 cron.php
drwxr-xr-x 2 downes users 512 Nov 16 13:20 drupal-5.0-beta1
-rw------- 1 downes users 734509 Nov 16 09:02 drupal-5.0-beta1.tar.gz
drwxr-xr-x 2 downes users 1024 Nov 16 13:20 includes
-rw-r--r-- 1 downes users 10 Nov 16 09:33 index.html
-rw-r--r-- 1 downes users 790 Oct 31 09:55 index.php
-rw-r--r-- 1 downes users 20931 Oct 31 09:55 install.php
drwxr-xr-x 3 downes users 1536 Nov 16 13:20 misc
drwxr-xr-x 31 downes users 512 Nov 16 13:20 modules
drwxr-xr-x 3 downes users 512 Nov 16 13:20 profiles
-rw-r--r-- 1 downes users 1605 Oct 31 09:55 robots.txt
drwxr-xr-x 2 downes users 512 Nov 16 13:20 scripts
drwxr-xr-x 3 downes users 512 Nov 16 13:20 sites
drwxr-xr-x 7 downes users 512 Nov 16 13:20 themes
-rw-r--r-- 1 downes users 30229 Oct 31 09:55 update.php
-rw-r--r-- 1 downes users 352 Oct 31 09:57 xmlrpc.php


Next, I need to configure a database. I have decided to use MySQL, not simply because I am most familiar with it, but because Drupal also recommends it (in INSTALL.txt). Another popular choice is the 'Postgre' database.

My hosting service makes MySQL databases available to me (that's one of the reasons I selected this hosting service, recall), so now it will simply be a matter of creating the database for Drupal to use. According to INSTALL.txt I can call the database anything I want. It simply says: "Take note of the username, password, database name and hostname as you create the database. You will enter these items in the install script."

So I go to the CSoft control panel and select the 'MySQL Databases' option.

I create a database called 'drupal'. Now, in order to grant access to that database, I will have to create a database user. So I create the user (I won't tell you the name of the user I created, for security reasons). In creating the user I assign a hosthane 'localhost' and, of course, give the user a secret password.

Now I need to grant the user permissions in the database. INSTALL.txt says "Your database user will need sufficient privileges to run Drupal" and refers me to another file, INSTALL.mysql.txt, which says, "At the MySQL prompt, enter following command: GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON databasename.* TO 'username'@'localhost' IDENTIFIED BY 'password';"

Well, I'm not using the MySQL prompt (why do these instructions always assume the system is being installed by some hacker in his basement? Sheesh). But it's pretty clear from the command which permissions I need to grant. So I can just fill out the form.

[OK, at this point I gave myself a whole lot of grief. I decided I wanted to install phpMyAdmin. So I created a phpMyAdmin subdirectory. But it wouldn't work - I didn't have permission to access it! To make a very long story short, note well: the .htaccess file that ships with Drupal disables access to all subdirectories. gak! So ok, I don't have phpMyAdmin running. I'll come back to that later.]

Once I had done that, I opened up my web browser and accessed my home page. Only it wasn't my home page any more, it was Drupal! (What happens is the .htaccess file makes index.php your new home page). I filled out the form with the information about my database, and clicked submit. A second later and I got the message, 'Drupal is now installed'.

Next step is to create the first account. This will be user number 1, which is the primary administrator. Get this one right, because you can't go back and do it again (well, not without wiping all your directories clean and reinstalling Drupal from scratch). I created the administrator user, and then clicked on the 'administration section' - you will see the link right in front of you.

Right at the top I saw, in red, " One or more problems were detected with your Drupal installation. Check the status report for more information." I clicked on the link they gave me. Cron jobs hadn't run yet. That was because I hadn't set up any cron jobs on this account. I'll save that for later. Also, "The GD library for PHP is missing or outdated." I checked that in Google and determined that it's a dynamic graphics library. Nifty. But not something I need just now, I don't think.

I also saw some warnings. "Operations on Unicode strings are emulated on a best-effort basis. Install the PHP mbstring extension for improved Unicode support." And "Unable to determine your web server type and version. Drupal might not work properly." Drupal might not work properly. Nice. Well - that's what I get for installing a beta version. Live on the edge, I say.

OK, back to the administration. The page is pretty daunting. Let's stop and get our bearings.

When I load the site home page, as administrator I see a list of things to do. Create the admin account. Set up administration options. And so on. But I don't need to worry about all that right away. The main thing to do now is to become familiar - very familiar - with the administration panel. because this is the heart and soul of the Drupal website, at least, from an administrator's point of view.

1 comment:

  1. Thank you for this write-up. Interestingly enough, I've been intending to setup Drupal in a multisite configuration. And I host with Csoft, so this was perfect! I just wrapped up the base install following your instructions and it worked flawlessly. Now it is time for me to start learning Drupal administration myself. I certainly plan on reading through the rest of your series of articles to see what other useful information you have provided.

    After spending some time reading a few of your other articles, I find it quite ironic that I ended up here. Your article "Things You Really Need to Learn" is truly inspiring and I intend to spread it among my friends and family. Lately I have realized just how many of the problems in our modern global, society could be solved by changing "the fundamentals" that are taught by so many education systems. This Drupal install is to allow me to start blogging so I can share what I know with others, something which gives me more joy than any other task I can do.

    So again, thank you so much for sharing!


Your comments will be moderated. Sorry, but it's not a nice world out there.