Example Lesson - Building Websites with Drupal 7

  • Lesson Notes
  • Assignment
  • Playlist
  • Transcript
Lesson Notes

You will need download Filezilla or another FTP program to do this week's lesson. (see the links below) If you have any questions, ask them in the class forum or during this week's live session.

Links from the video

Frequently Asked Questions

Do the lesson videos play on iPads and iPhones?

Yes, they work on both desktop/laptop computers and iOS devices.

How can I ask questions or get help?

You can ask questions about the lesson or get help with your assignment by posting to the class discussion forums and attending the weekly live lab sessions with the instructor. (online via webinar software)

Do I need to have my own website or hosting account to work on?

No, we will provide you with a hosting account to work with for the duration of the class. This way you can do the assignments without messing up your existing website. Working on our hosting system also ensures your experience matches what you see in the lessons and allows us to troubleshoot any hosting-related issues you may have.

Assignment

Over the duration of this course you’re going to be building an example Drupal site. The site will be a simple library catalog, which we’ll then transform into a book store when we get to the e-commerce portion of the class. Your first assignment towards this end is to set up a basic Drupal site.

Here’s an outline of what you need to do:

  • Download Drupal 7.18 and unzip it.
  • Create the settings.php file, and files directory under /sites/default in the Drupal directory.
  • Upload the Drupal files via FTP to the www directory in your hosting account.
  • Login to your hosting account and create a database. (hosting login information can be found on the class page, under the Hosting tab)
  • Go to the URL for you site, and the Drupal installer should be shown.
  • Install Drupal, configure the superadmin username and password.
Playlist
Transcript
There are several different ways to install Drupal. Right now I am going to show you the most common way and the way that should work on the most broadly across different types of hosting accounts. And so this way has 5 steps. First we are going to download and unpack the files for Drupal; we are going to set up some configuration files. We are going to upload all those files to the server and then we will create a database on the server and run the install process on the files that are on the server. So the first step is to download the files for Drupal to our local computer. So if you go to Drupal.org, the way to download is go to "Download & Extend" and the most recent version of Drupal should be here under the "Core" section. So at the time that I am recording this, the most recent version of Drupal is 7.18. By the time you watch this it may be different - just choose whichever is here. If you click "Download 7.18", it will take you to another page, where you have to scroll down and you will see that same version listed down here at the bottom in the screen section where it says 7.18. The downloads actually are these two files. If you are on a Windows machine, it's important that you always get the zip file for this because a Windows machine does not understand tar.gz. If you are on a Mac or Linux, you can use either of them. I tend to use the tar.gz because sometimes I am on a Linux server and it also works on my Mac. But if you are on a Windows machine, choose this one (zip), if you are on a Mac, you can choose either. ( zip or tar.gz). They both have the same thing inside of them - it is just the format of the zipped archive. So to download, you click the link for whichever one you want; I will take the tar.gz. And once the file downloads, you will have it in your download folder, wherever if you are on a Windows that may be on the Desktop or in your Download folder. If you go there you will probably need to double click it to unpack it. Again, the exact process may be different on your computer but what you should end up with is a folder that says "Drupal 7.18" or your version. And inside that folder, it should look something like this (showing how it looks like). Now that we have downloaded the files for Drupal, let us take a look inside the Drupal directory and at the file layout and what's inside there. Once you get inside the Drupal directory, you will see a collection of files and folders. There are php files in here, which are the code files; there are text files, which are for the most part information. The only one that is important, actually, for the server, is this robots.txt, but all these others have information in them. And then there are several folders. So I want to point out a few things about these folders. The first is "includes" (folder). In here you have a bunch of code files. In general, you should never be touching anything in here; this is really where the core of the Drupal code system is. So for the most part we don't want to be editing anything in there. "Misc" (folder) has mainly javascript files and a lot of images. Again, you shouldn't be editing anything in here, you shouldn't be touching it. "Modules" (folder) - this is a directory that includes a lot of subdirectories. These are all of the Drupal modules that come with Drupal core. Again, like "includes" and "misc", you should never edit or change anything in these files and you should not be adding modules to this. We are going to see in the future where you are downloading modules and installing them into Drupal, sometimes people think that they should put them here because this folder is called "modules" - don't do that. This one should not be touched, this is for Drupal core modules. "Profiles" - this folder is for something called installation profiles. We're going to see this when we do the installation script in a few minutes. Again, this is part of the core system and you should not be changing it. "Scripts"- for the most part these are some scripts that can be run in the command line. You generally will not need to do this, to use any of those in there. Let's skip "sites" for a second and go to "themes". "Themes" are where the core themes that come with Drupal are stored, so this is similar to the "modules" folder. These are just like you can download modules from Drupal.org, you can download themes and install them but you do not put them here. Do not put them in the "themes" folder, just like you don't put downloaded modules in the "modules" folder. These are for the ones that come with Drupal to begin with, the Drupal core. Okay, so if we go back here, I skipped the "sites" folder. The "sites" folder is actually where you might possibly...this is where you're going to be putting things, this is where you would...as we will see in the future when you add modules and you add themes you do it all under the "sites" folder. Inside of the "sites" folder are two folders: "all" and "default". The reason that these are here is Drupal has a way to run multiple websites out of the same folder of code. We're not going to demonstrate how to do that today but in general what you need to know now is that when you install modules and themes on your site, you are going to put them into "sites" -> "all". You'll see that there are two subfolders here: "modules" and "themes". They're empty right now, they have a "README" in them. But this is where you will put them. If I make that a little bit easier to see. If you have "sites" -> "all" -> "modules"; "sites" -> "all" -> "themes", that's where you're going to be installing modules in the future. The "default" is where we're going to be doing configuration. And we're getting ready to do that in a minute here. But this is where configuration and uploaded files.. so if you have a site where people can upload images or upload PDFs or something to it, those we'll all end up inside of "sites" -> "default" files. The reason for doing this is when you go to update Drupal later, like let's say a new version comes out, a security patch- if you keep all of your changes you'll notice there's actually no Drupal code inside of this "sites" folder. All the Drupal code was in the other folders. If you keep everything you download in "all", in "sites" -> "all", and everything you upload (like files, PDFs), if all those end up in "sites" -> "default", then when you need to update Drupal, you can actually replace all of the other files except for the "sites" folder. We'll do a demonstration of the upgrade process in another lesson. But that's why it's laid out this way. Alright, so, in general don't touch anything outside the "sites" folder. The next step in the installation process is to set up some configuration files. So, we have our files here, under "sites" -> "default". You'll see the default settings.php. You want to take this file and you want to make a copy of it. After you make a copy of it you want to rename it so that it's called settings.php. Must have this exact naming and it needs to be a copy of default settings. This is where we're going to.. this is where settings about your database and other sort of configuration overrides will be. We don't need to edit this right now, it does have code in it if you were to look at it with like a text editor. It does have some code in it but we don't need to edit this by hand. The installation process will actually edit this file for us but we have to create the file. The next step is that we need to create a folder under "sites" -> "default", called "files". This folder will be for uploaded files, so this is the images, the pdfs, everything that you upload end up in "sites" -> "default" files. Once we have those two things created, then we're ready for the next step where we are going to upload the files to the server. So, I'm going to use "FileZilla" for this. You can use any ftp client that you want, any ftp program that you want. "FileZilla" is available for Windows and Mac, and Linux, so I'm going to use it for these demonstrations. But if you have another ftp program that you like, you don't need to change and use "FileZilla". Any ftp program will work. For those of you who haven't used an ftp program before, the purpose of an ftp program is to move files from your computer to the web server or to copy them from the web server back down to your computer. So when you open "FileZilla", the first thing you would want to do is... Let's talk about the layout of this, there are two sort of panes here, two columns let's say in this window. This side (showing) you'll see it says "Local site"-this is your computer. This side (showing the other side) will be the server. We're currently not connected to any server but once we're connected, we'll see files here. And what we do is we move files from this side (left) to this side (right) if we're uploading to the server, which we're going to do here in a moment. You'll probably need to go to your "Downloads" directory, wherever that is. If you are on a Windows machine, it's somewhere under user profile, I'm not sure. On a Mac, I can tell you that it will be under "users" -> your username and "Downloads". Here's my Drupal folder that I created before. Notice it does have my new settings and files, so I've already done that part. Alright, so here I'm inside of the Drupal folder and now I need to connect to the server. So, you should have a server name for your hosting account. And so the host is actually the server's address. The username you should also have and the password. And if you choose to connect. Once you connect you should see something like this (showing). All of the files that are going to end up on the web are under this "www" directory. So if we click here we see that this is a brand new hosting account and its empty except for a "cgi-bin" directory. And if we actually go to the web, we'll see that that's actually parallel. Here it is, it's empty, except for that cgi-bin. So this is what I'm looking at here. Alright, these are the same. So what I want to do is I need to take all of these files and copy them up to the server. So if you click the first one... if you go under the Drupal directory, click the first one and then hold down the Shift key and click the last file on the list, then that will select all of the files. You can then drag and drop these onto the right side which will start the process of uploading. Okay, and this is going to take a couple of minutes to run. A couple of notes while I'm saying this. I've noticed, be careful not to select this double dot folder at the top. I'm not sure on the Mac but on Windows if you select this, you'll have trouble dragging and dropping. We've run into that problem in the past. So make sure to just.. not the double dot but everything after it. Okay, and this is uploading everything, it's going through all the folders, the subfolders... Also, if you are on a Windows machine, make sure that this ".htaccess" file is shown. It should be in FileZilla but occasionally I've noticed that it doesn't show up on Windows. So we'll have to wait just a few minutes for this to upload. [Uploading] Okay, all the files are now uploaded on the server, we can tell there's no more activity here and everything seems to match up. This extra "cgi-bin" won't be a problem; we can actually just leave it. Alright. And our next step is, before we can actually run the installation script, is we need to create a database for Drupal to run on. So we have to do that under the hosting account. So you should have a cPanel URL. The cPanel URL is what you'll use to log into your hosting account. The username and password will be the same as the ftp but it will be a specific URL that you need to go to. So, here's mine. Once you log into your cPanel account, it should look something like this. And the place you want to go to, most of these we can leave alone for right now (showing), but the place you want to go to is you want to create a MySql database. And the easiest way to do that is using the MySQL database wizard. We need to give this database a name. In cPanel, all of the databases will always have your username, underscore, and then the name of the database. You can call it anything you want, but remember what you choose. I'm just going to call it Drupal. Not it's going to ask me to create a database user. Again, you can call this anything you want but make sure to remember what it is. I'm going to call the user "Drupal" as well. You're allowed to do that; you can have a database name and username to be the same. I'm going to give it a password. Again, don't forget what you've chosen. And then choose "create user". When it comes to the privilege screens, I'm going to give it all privileges. And now we are done, so we have now created the database for Drupal. And we're ready to move to the last step which is to run the installation process. So, to run the installation process, go to your URL and add "install.php" to the end. And you should be presented with a Drupal installation script like this (showing). And the first choice that you have to make is whether to choose minimal or standard configuration. This is actually the installation profiles that I showed a few minutes ago when we looked at the file layout, we saw that there was one folder called "profiles". That's where these things are defined. An installation profile decides what modules and configuration will be enabled after you install. So, by default, Drupal comes with two possibilities: standard and minimal. If you choose "Minimal" you'll have almost nothing configured out of the box; it's a very limited set up. And you can turn things on; you're not limited at that point. You can turn whatever you want on, but it won't do very much out of the box. It doesn't have many things set up to manage pages or news articles, whereas the standard installation has some admin options turned on, it has comments turned on, it has a default set up for pages and articles. So, we're going to choose the standard, but in certain cases if you wanted to do everything by hand and wanted to build a whole system from the ground up, you might choose minimal. That's certain situations where you might choose it. So, we're going to leave it set to standard and save and continue. We're going to install in English. If you need to install Drupal in other languages, you can click this link (showing) and it'll tell you your options. Alright, we are going to choose a MySQL database for this and this is where I said you need to remember your database name, username, and password. Remember that if you're using cPanel, it's always your cPanel username, underscore plus whatever you typed. So in this case it's going to be lesson_drupal. My username was also lesson_drupal and then I had my password. The advanced options, we don't necessarily need to use them. These allow you to change information about the database. Since we just created the database, it's brand new, and it's on the same server, we don't need to touch those. Save and continue. Right now what its doing is it's actually loading the database up with a bunch of tables. It's installing those default modules that come with the standard installation profile and it's setting up some default configuration. Right, the last step of the installation process is we need to give our site a name. So I'll call it Drupal Lesson. We need to give it a site e-mail address: this is the e-mail address that is used when the Drupal system sends out e-mails. So, for example, when you forget your password, there's a place where you can have it e-mail you a link that lets you log in without knowing the password so that you can change it. The e-mail from address on those will be whatever you set here. So I'm just going to put my own e-mail address in here. Username.. so, for the site maintenance account. This is what I call the super-admin account. I usually set the username to "admin" but not always. For the purposes here, I thing setting it to "admin" is fine. This user that you're creating right now will be completely unrestricted on the system. They'll be able to change anything on the system. So it's important to choose a good password for this user. And you can also change the e-mail address if you don't want it to be the same as the site e-mail address. So these are fine for me, so I'm going to leave those. Update notifications - regional settings like periods versus commas for numbers, for example and the default time zone. you'll probably want to leave both of these on. What these do is Drupal will run a process once a day, It will run a process where it checks to see if any...if Drupal itself has been updated on Drupal.org, or if any of the modules you've installed have been updated and then it will alert you. If you just have this first one checked (showing), it will alert you with a banner once you log into the site as the administrator. If you have e-mail notifications turned on, it will also send you an e-mail when that happens. So, it's usually good practice to leave both of these on so that you're aware of what's going on your system and whether you need to update things. Alright, so then choose "save and continue" to finish this process. And that's it. We've now installed Drupal. If we click to visit your new site, we're logged in as that administrator user, the super-admin and we're here. Now we have a functional Drupal site ready to go. There's one more thing I want to show you about the installation process here before we continue with configuring Drupal and that's I want to show you the database because a lot of times people will ask me, you know "Where did all that information go? We filled in like an e-mail address and a site name...î And they can see that it's showing up here but where is it actually stored. The same thing is true like when I create a page like we'll see in a few minutes, where's that stored. All that gets stored in the database. And so, you can actually see the database. Now, you should be careful - you should not be editing or changing things in the database directly - you'll really screw up your Drupal site if you do that. But I'm just going to show it to you so that you understand sort of how it works and where that stuff is. So if you go back to your hosting configuration, the cPanel set up, go down to databases and choose "phpMyAdmin". When you open that, it should pop up in a new tab and then over on the left-hand side you should see the name of your database, in this case lesson_drupal is mine. And if you click on that, then you'll see all the tables that are in this database. And you can see there's a bunch: we chose the standard installation profile and so by default, we've got 74 tables. But these tables are where all that information is stored. So a lot of that configuration, some of that settings and things - those tend to be stored in this "variable" table. When we go to things like..when we have pages and when we're creating pages and creating articles, a lot of those will be in the "node" and "node revision" tables. When you have comments, those will be stored in the "comment table". So all that stuff ends up here. Again, I'm not going to click in here and look at any of the data because you should not be changing things in the database directly, but this is where it is. And you'll see, as you install more Drupal modules, a lot of Drupal modules will create additional tables in here so that they can store their own configuration or data. This is where all that stuff is stored. Alright, the only thing that changes about files is when you upload things like images or pdf's, that will change the sort of file structure. Those will all end up in that sites default files that we saw earlier. All those will end up in here (showing). So under the Drupal folder we had "sites"->"default" files. If you upload pdf's or images as we'll see in the future, those end up here. Everything else that you enter into Drupal ends up in the database. But, again, don't edit it there; always edit it through Drupal so that it can make sure that everything is consistent.