Installing Drupal with Drush
This is a short introduction to installing Drupal with Drush in which we will start with an empty directory, download Drupal and change the default theme.
First you will need Drush installed. Installation of Drush is beyond the scope of this post but you can go to the project page or here. I currently have Drush version 4.4 installed for this post. You can check your version by typingdrush --version
In order to install Drupal, we need to download it. Get to your web directory and type:drush pm-download drupal
Nice! We now have the latest stable version of Drupal in the web directory, now we need to let it go through the standard install scripts so that it will setup the database and all the variables needed. For this we will use site-install. There are a number of arguments for site-install that will allow you to set the default admin username and password along with the email, site name and the site email address. For the bare minimum you will need to tell Drupal where the database can be found with --db-url.drush site-install --db-url=mysqli://username:password@localhost/drupal7
Ok, now we have the site installed, you can go to your browser to login. If you used the bare minimum, you will see that your site is named Site-Install and your username and password are admin/admin and the admin email address is admin@example.com. Drush doesn't allow you to change the email address of a user, but we can change our password to make things a bit more secure.drush user-password --password="5up3Rp@$s"
There, that's a bit better than having admin as the password. During the install the site name was set which is kept in the variables table. We can change this by using the variable-set command.drush variable-set site_name "My Blog Site"
Drush asks which variable you'd like to set, it's Drush's way of asking "Are you sure?". Select 1 for site_name, and refresh your site. You will see that the name of your site has changed. Now we want to change the theme of the site from the default Bartik theme to something else. Using drush pm-list will show you a list of all the modules and themes you can choose from, but that's a pretty hefty list so we will just narrow it down to the themes by passing the --type flag.drush pm-list --type=theme
This give us a list of the four themes that came with Drupal. Since we are changing from Bartik, and Garland is so Drupal 6, we could use one of the other two. The remaining themes are a bit plain so we'll go ahead and download a different theme to use for our site. I've randomly chosen Corolla for this post so let's download it. We use the same command we used to download drupal originally but this time we will use the much shorter alias for pm-download which is just dl.drush dl corolla
Drush has now downloaded the theme to the correct directory without us having to tell it where to go, but now we will need to enable the theme. The command for this is pm-enable but again we will use it's much shorter alias en.drush en corolla
Awesome! that was easy, but wait there is one more step. After you've downloaded and enabled the theme, you need to let Drupal know that you want to use it as your default theme. Drupal treats themes very much like modules which is why there isn't a separate set of commands for them and is why we used pm-list to show them instead of something like theme-list and pm-enable instead of theme-enable. There is also not a theme set-as-default for this same reason. Like the site name, the default theme for Drupal is kept in the variables table so we will use variable-set (actually vset) to set the default theme.drush vset --yes theme_default corolla
This time I didn't want Drush to ask the "Are you sure?" question so I used the --yes flag to say, "Yes I really want to do this and don't ask again." Now if you go to your site, you will see that the new theme is enabled.
So we've started from an empty directory, downloaded Drupal 7, installed it, and changed it's default theme. Congratulations you can now login and start your blogging.
Post new comment