Lab 5: Install Drupal

20 points.

In this lab you will install the Drupal CMS on your server and perform some initial configuration.

Hint: since you will be doing lots of work that requires root permission, you may wish to log in as the root user so you don't have to put "sudo" before every command. To do so you can type "sudo su root". (If you aren't doing extensive root work, it's better just to use sudo when you need root permissions.)

Tasks

  1. Install the packages php-mysql, mcrypt, php-mcrypt, php-gd, php-xml, php-imagick, and php-mbstring if they aren't already installed. (A reminders of how to install packages is available here.) Then restart the web server with service apache2 restart.
  2. The mysql database server should already be installed and running. (If not, you can install the package mysql-server.) If you are not already logged into linux as root, do so now with the command su root. Then log into the database server with the command

    mysql

  3. Create a database called "drupal7" with the command

    CREATE DATABASE drupal7;

    Don't forget the ; at the end of MySQL commands. Now create a database user called "drupal7" for your Drupal website:

    CREATE USER 'drupal7'@'localhost' IDENTIFIED BY 'my-new-password';

    In real life you should of course use a better password than 'my-new-password' and you may do so here as well. However, don't use a password you use for other purposes because you'll have to type it into a text file and others may be able to read it. Be sure to write it down.

    You will also need to give the drupal7 user permission to read and modify the drupal7 database. You can do that with the commands

    GRANT ALL PRIVILEGES ON drupal7.* TO drupal7@localhost;
    FLUSH PRIVILEGES
    ;

    Type exit to get out of mysql. Test that things have worked correctly by logging into mysql with the new user:
    mysql -u drupal7 -p drupal7
    [enter your password]
    CREATE TABLE test(a int);
    DROP TABLE test;
    exit

  4. Now we can install Drupal. Rather than installing the drupal7 package with apt-get we are going to install the latest released version from the drupal.org website. Go to the Drupal.org website and locate the download for the latest recommended version of Drupal 7, 7.56 as of this writing. Copy the URL for the tar.gz version combined into a single file with tar, then compressed with gzip.

    Note that it won't work to just click the "Download tar.gz" link. That would download it to the PC in the ulab, not to your virtual machine.

    Now go to a terminal window logged in to your VM and cd into the Web server's document directory, /var/www/html. Make sure you are still logged in as root. Download the Drupal installation file with a command such as wget http://ftp.drupal.org/files/projects/drupal-7.56.tar.gz.

  5. Uncompress and unpack the file with the command tar xvfz drupal-7.56.tar.gz. If you have done it correctly, you should have a directory /var/www/html/drupal-7.56 containing all of Drupal's files.

    Now we need to move the contents of the drupal-7.56 directory into the /var/www/html directory. You can do so with the command

    cd drupal-7.56; mv * .htaccess ..

    You need to specifically move the .htaccess--because its name starts with "." it is treated as "hidden"; it won't be moved unless you specifically add it to the command.

    Delete the index.html file in /var/www/html so that the new index.php file will open by default.

  6. Briefly, you will need to create a /var/www/html/sites/default/files directory owned by the user www-data. You'll also need to copy sites/default/default.settings.php to settings.php and give that file permissions 777. Detailed instructions are available here.
  7. Make sure the "rewrite" module is enabled (you did so in a previous lab) by checking for the file /etc/apache2/mods-enabled/rewrite.load. If it's not there, you can enable the "rewrite" module in apache with the command a2enmod rewrite and restarting apache2.

  8. Run the install script by opening http://yourlogin.calvincs.com/install.php and perform a standard install. (If you need them, detailed instructions are available here.)

    Fill in the site configuration forms. (Your database should be called drupal7, and the database login you created should have the username drupal7 and whatever password you gave it.) For site name, use something like "John Smith's dev site". Use your own email address as the site email address. Create a maintenance account with the username admin and password of your choice.

    Change the permissions to 744 for the settings.php file.

  9. At this point you should be able to connect to your drupal website and log in with the administrator user name and password you configured earlier. Now log in and do some basic site configuration: Click "Configuration" and edit the site information. Note that this site is just for labs. You'll create a different Drupal site for your term project. So enter site information appropriately. Add a site name and slogan. You can edit the other site info as desired.

Turn In

I will check your website directly from the the link on the course projects page. The site should have a name and slogan entered.