Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Building a site using Drush

From: Drupal 7 Advanced Training

Video: Building a site using Drush

In the previous video you saw how a single Drush command can take the place of a dozen clicks when installing a new site. That economy of effort continues as you build and maintain the site as Drush includes commands to install modules, clear caches, manipulate the site database. That is, to pretty near any kind of big site modifications. This video shows you a few common steps in building a site using Drush as well showing off some of its limitations. First, let's take a look around our site. As I mentioned before we were able to name it when you first installed it using Drush as Drush example site, but other than that there's no content, no special content types, or anything like that. It's basically just a stock installation.

Building a site using Drush

In the previous video you saw how a single Drush command can take the place of a dozen clicks when installing a new site. That economy of effort continues as you build and maintain the site as Drush includes commands to install modules, clear caches, manipulate the site database. That is, to pretty near any kind of big site modifications. This video shows you a few common steps in building a site using Drush as well showing off some of its limitations. First, let's take a look around our site. As I mentioned before we were able to name it when you first installed it using Drush as Drush example site, but other than that there's no content, no special content types, or anything like that. It's basically just a stock installation.

One thing I am going to do is I am going to open another window here with drush.org. This is so I can keep the reference behind the other screen and make sure that you click on the correct tab here. I'm using version 5. All right, now we are ready to get going. The first thing we are going to do is grab some modules. Two I use in most sites are Token and Pathauto. I'm already logged into my site and in that directory as you can see. The command that we want is drush pm- download and then the name of the module we want to download.

That takes a minute and then gives us a report back. One interesting thing is I use this pm- download, that's actually the same as dl. Some of these commands have aliases so you can use either the short form or the long form. In this case, pm stand for package manager, which is a common thing in the UNIX world. We will do the same thing with the Pathauto module. Just to prove that they are there in a familiar interface I am going to go back to the web site and click Modules.

Close up the core group and there they are, Pathauto and Token. We could continue here by clicking, but let's go back to our Terminal and enable them there. I do drush pm-enable and then the name of the module. Now Pathauto requires Token, but I'm going to do the same thing that I usually do in the graphical interface. I am going to just say Pathauto and see if it will actually force the dependencies to be enabled as well. And indeed it does. Yup, I want to continue. And we are done.

If we go back to the web interface, we see exactly what we expected, they've been enabled. This screen that lists all of the modules actually exists in Drush as well. It's drush pm-info, but be warned it's a lot of information. As you see it gives information about all the modules and themes that are installed along with their versions and all sorts of other stuff. If you want to cut that down, you can do it with drush pm-info and then the name of the package you want, like let's say Pathauto.

There, much easier. Another thing you can do is drush pm-info and then pipe it; that's the vertical line on your keyboard, through more. That means it'll take that information and put it through the more program in UNIX. Now we can page through it just by pressing the spacebar or escape from it by pressing Q. I will clear the screen to keep this clean. That's an example of a Drush command that doesn't actually change anything, but rather just displays information.

Two more you should know about are drush core-requirements and drush core-status. Interestingly, the second one, core-status, nothing exists exactly like this in the web interface. Now we can combine that ability to look at information and change information using drush. I will give you an example. First, I will clear the screen and then say drush field-info and then say would like to take a look at the fields.

And it tells me all of the fields that are in my site. We can then create a field with drush field-create article. It asks us for a variety of things in an interactive manner. I will just call it twitter_promo. We want it to be a text field so that's number 13, and we have only one option really, Cancel or add a Text field, so yes. Now it doesn't go through all of the options, because there are so many. Instead it gives you this URL, which you would then copy, but there is something to watch out for.

Be careful that the domain is what it should be. In this case, Drush doesn't exactly know what domain it's on. So I'm going to have to go there myself. It's drush.tomgeller.com, but everything else should be correct. Let's see. Yup, and in fact I can now put in all the other options that I couldn't do very easily with Drush. As you might imagine, Drush cannot only download modules but also themes. I will do that very quickly. First, let's decide on what theme we want to get. I am going to go to drupal.org/project/ themes, and let's see marinelli I think is the one that I want. Yup, there it is! So we know that we want to download marinelli, but there's something to watch out for.

What we see here at the top in the title is what's called the human readable name of the theme or module we want. As you might remember Drupal has both a human readable name and a machine name, and what we need is the machine name. Pretty much always it's going to be the end of this URL, project/marinelli. Another way you can find out the name is by downloading the file itself as I'll do here. Then go back to finder and see what the name is, and yup, there it is, marinelli all lowercase. But I'm not actually going to use those.

Instead, I will go back into my Terminal and download them from that using Drush, once again, and there we go. One interesting thing I want to point out is that when it downloaded the module, it put it into sites > all > modules. In this case, it knew that it was a theme and put it into sites > all > themes. We could find that out by going through the directory, but of course you can also do that on your own time. Let's move on and enable it with drush pm-enable marinelli.

It says, do we really want to do that. Yes, we do. All right, now let's go back to our site and see what happened. Go home and see if we are in the marinelli theme. We are not. Why is that? Well, the thing is you might remember that themes have both enablement and then setting as default, and it didn't actually set as default. All that it did was it took it out of this Disabled Themes area. There is no direct Drush command to set a theme as the default, but Drush can change the value of any variable on your site.

Which means it can effectively check any box or change any setting as you would do the web interface. The trick is in knowing the variable name. Sussing those out is beyond the scope of this video. So I will just show you how to turn this on using the Theme Default variable, which happens to be theme_default. I will go back to my Terminal. First, I will clear the screen and then drush variable-set theme_default, that's the variable name, and marinelli.

Supposedly, it worked, let's go back to our site and make sure. And as you can see, it did. Finally, I want to show you an incredibly useful Drush command that takes the place of pretty much everything that you'll see in the video of about backing up with the Backup and Migrate module. It's called Archive Dump. I go into Terminal and it's simply drush archive-dump. That takes a minute and then it tells us where it put that file. Now you will notice it put it outside of our web apps directory.

It's actually in my home directory/ drush-backups, which it just created. That's good, because you don't want to put it inside with your Drupal site installation. If it did that and then you deleted that by accident you'd have no backup. There is also, by the way, drush archive-restore, which works pretty much exactly as you'd expect. The good thing about the way that Drush does this is it saves both the files and the database, which the Backup and Migrate module doesn't do for example. Well, that sure was a lot, wasn't it? And it should be clear that it's only the tip of the iceberg.

Drush is unbelievably deep and it gets deeper as you install other modules, as many of them include hooks to Drush. You can see some of that by going to Drush.org and clicking Resources. Once there scroll down and you see this Contributed modules with drush integration and once again there are many, many more than that. Drush opens the door to a whole new world of Drupal site management and learning it is a big step to becoming a Drupal professional or just someone with pro-level skills.

Show transcript

This video is part of

Image for Drupal 7 Advanced Training
Drupal 7 Advanced Training

72 video lessons · 10928 viewers

Tom Geller
Author

 
Expand all | Collapse all
  1. 4m 51s
    1. Welcome
      1m 7s
    2. Planning your Drupal career
      3m 44s
  2. 25m 46s
    1. Comparing development and production environments
      6m 22s
    2. Configuring your settings.php file
      7m 10s
    3. Running multiple sites from one Drupal installation
      7m 32s
    4. Troubleshooting common issues
      4m 42s
  3. 51m 20s
    1. Understanding your Drupal site's place on the web
      2m 44s
    2. Selecting a web host
      7m 20s
    3. Using Unix's command-line interface
      8m 23s
    4. Working with your web host's access restrictions
      4m 51s
    5. Using cPanel and other graphical web host interfaces
      3m 40s
    6. Transferring files to and from your web host
      5m 49s
    7. Moving databases using phpMyAdmin
      6m 34s
    8. Moving databases using Unix commands
      6m 8s
    9. Modifying server configuration files
      5m 51s
  4. 27m 10s
    1. Learning from case studies
      3m 13s
    2. Planning your site
      4m 18s
    3. Populating your site with Devel Generate
      3m 42s
    4. Managing URL paths
      3m 20s
    5. Restricting access to downloadable files
      5m 55s
    6. Reusing site components with the Features module
      6m 42s
  5. 21m 53s
    1. Understanding and installing Drush
      5m 23s
    2. Installing Drupal using Drush
      7m 24s
    3. Building a site using Drush
      9m 6s
  6. 31m 59s
    1. Backing up with the Backup and Migrate module
      8m 17s
    2. Moderating comment spam
      6m 47s
    3. Migrating from Drupal 6
      4m 28s
    4. Migrating to Drupal 7
      12m 27s
  7. 22m 24s
    1. Letting users log in through OpenID
      5m 10s
    2. Letting users log in through Facebook, Twitter, and other services
      9m 43s
    3. Republishing posts on Facebook and Twitter
      7m 31s
  8. 1h 5m
    1. Understanding Drupal's base themes
      5m 55s
    2. Introducing base themes: Zen and subtheming
      11m 35s
    3. Introducing base themes: Fusion and extensibility
      10m 44s
    4. Introducing base themes: AdaptiveTheme and responsive design
      7m 25s
    5. Introducing base themes: Omega and mobile devices
      7m 9s
    6. Using Firebug and other theming tools
      7m 20s
    7. Modifying themes with Sweaver
      6m 59s
    8. Modifying themes with Livethemer
      8m 45s
  9. 49m 35s
    1. Understanding the Rules module
      6m 48s
    2. Demonstrating how Rules works in Drupal Commerce
      3m 53s
    3. Creating practical rules
      6m 37s
    4. Improving rules
      9m 10s
    5. Defining conditions with the Context module
      7m 51s
    6. Varying layout with the Context and Delta modules
      5m 0s
    7. Varying layout with the Panels module
      10m 16s
  10. 52m 46s
    1. Enabling social features
      9m 46s
    2. Implementing a voting system
      9m 15s
    3. Rewarding good behavior with the Userpoints module
      5m 57s
    4. Setting up Organic Groups
      6m 28s
    5. Adding content to groups
      2m 21s
    6. Seeing group activity better with views and panels
      10m 13s
    7. Making groups private
      4m 54s
    8. Letting each group have its own permissions
      3m 52s
  11. 25m 32s
    1. Understanding packaged Drupal distributions
      2m 8s
    2. Getting a head start with Acquia Drupal
      7m 28s
    3. Creating online storefronts with Drupal Commerce
      6m 53s
    4. Creating government web sites with OpenPublic
      9m 3s
  12. 1h 30m
    1. Taking the assignment
      3m 26s
    2. Planning the project
      3m 43s
    3. Preparing the infrastructure
      8m 42s
    4. Starting the design
      7m 35s
    5. Filling in the content
      7m 29s
    6. Developing the layout
      10m 27s
    7. Finishing the layout
      7m 8s
    8. Refining the CSS
      6m 32s
    9. Setting up sections for regional offices
      4m 53s
    10. Configuring regional offices
      7m 18s
    11. Connecting to social media
      5m 9s
    12. Cleaning up
      12m 32s
    13. Securing the site
      5m 56s
  13. 37s
    1. Next steps
      37s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Drupal 7 Advanced Training.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.