Drupal can use a MySQL or PostgreSQL database but Chado prefers PostgreSQL so that is what we will use for both Drupal and Chado. We need to create the Drupal database. The following command can be used to create a new database user and database.
First, become the 'postgres' user:
sudo su - postgres
Next, create the new 'drupal' user account. This account will not be a "superuser' nor allowed to create new roles, but should be allowed to create a database.
createuser -P drupal
When requested, enter an appropriate password. Finally, create the new database:
createdb drupal -O drupal
We no longer need to be the postgres user so exit
We want to install Drupal into our web document root (/var/www/html). Before we can install Drupal we must ensure that that we are allowed to add files into the /var/www/html directory. Select a user account that will be the owner of all web files and change the owner of the /var/www/html directory to that user:
sudo chown -R [user] /var/www/html
Substitute [user] for the name of the user that will own the web files.
Note: The apache web server runs as the user 'www-data'. For security reasons you should chose a user other than 'www-data' to be the owner of the /var/www/html directory.
Tripal 2.x requires version 7.x of Drupal. Drupal can be freely downloaded from the http://www.drupal.org website. At the writing of this Tutorial the most recent version of Drupal 7 is version 7.54. The software can be downloaded manually from the Drupal website through a web browser or we can use the 'wget' command to retrieve it:
cd /var/www/html wget http://ftp.drupal.org/files/projects/drupal-7.54.tar.gz
Note: if you are using older version of Ubuntu the web root directory may be /var/www rather than /var/www/html and you may need to change the path accordingly.
Next, we want to install Drupal. We will use the tar command to uncompress the software:
tar -zxvf drupal-7.54.tar.gz
Notice that we now have a drupal-7.54 directory with all of the Drupal files. We want the Drupal files to be in our document root, not in a 'drupal-7.54' subdirectory. So, we'll move the contents of the directory up one level:
mv drupal-7.54/* ./ mv drupal-7.54/.htaccess ./
If an index.html file is present (as is the case with Ubuntu installations) you can move it out of the way so that it doe not interfere with Drupal by executing the following:
mv index.html index.html.orig
Note: It is extremely important the the hidden file .htaccess is also moved (note the second 'mv' command above. Check to make sure this file is there
ls -l .htaccess
Next, we need to tell Drupal how to connect to our database. To do this we have to setup a configuration file. Drupal comes with an example configuration file which we can borrow.
First navigate to the location where the configuration file should go:
Next, copy the example configuration that already exists in the directory to be our actual configuration file by renaming it to settings.php.
cp default.settings.php settings.php
Now, we need to edit the configuration file to tell Drupal how to connect to our database server. To do this we'll use an easy to use text editor gedit
Find the following line
$databases = array();
and then insert the following array just after the above line:
$databases['default']['default'] = array( 'driver' => 'pgsql', 'database' => 'drupal', 'username' => 'drupal', 'password' => '********', 'host' => 'localhost', 'prefix' => '', );
Replace the text '********' with your database password for the user 'drupal' created previously. Save the configuration file and close the editor.
Files directory creation
Finally, we need to create the directory where Drupal will have write-access to add files. By default, Drupal expects to have write permission in the /var/www/html/sites/default/files directory. Therefore, we will set group ownership of the directory to the group used by the Apache web server. This will be the user that Drupal uses to write files.
mkdir -p /var/www/html/sites/default/files sudo chgrp [group] /var/www/html/sites/default/files sudo chmod g+rw /var/www/html/sites/default/files
Substitute [group] for the name of the web server's group. In Ubuntu this is www-data in CentOS this is apache.The above commands creates the directory, sets the group ownership for group. and gives read/write permissions to the group on the directory.
Navigate to the installation page of our new web site http://localhost/install.php
Ensure that Standard is selected and click Save and Continue. You will next be asked to select the language you want to use. Choose English (which is probably the only choice).
You will see a progress bar (as shown above) as Drupal is installed. Once it completes, a configuration page with some final settings will be visible.
Here you will provide details appropriate for your site, including your site name and administrative password. If you are experimenting with Tripal the following values can be used:
- Site Information
- Site Name: Tripal 2.x
- Site email: Your email address
- Site Maintenance Account
- Username: administrator (all lower-case)
- Email: Your email address
- Password: ********
- Server Settings
- Default country: (wherever the site is located)
- Default time zone: (your time zone)
- Update Notifications (both boxes checked)
Now, click the Save and Continue button. You will see a message about unable to send an email. This is safe to ignore for the tutorial, but for a production site you will need that your server can send emails to a service provider. Now, your site is enabled. Click the link Your new site:
Drupal Cron Entry
The last step for installing Drupal is setting up the automatted Cron entry. The Drupal cron is used to automatically execute necessary housekeeping tasks on a regular interval. We want to integrate Drupal Cron with the UNIX Cron facility. To do so, we must first get the appropriate URL for the cron by navigating to Configuration → Cron. On this page you will see a link that we will use for cron:
In this example the URL is http://localhost/cron.php?cron_key=3979hhoUyiCQ2PhRpWEZc3lrnFbPvPeXSBDSC5kEk0U
To add an entry to the UNIX cron we must use the crontab tool:
sudo crontab -e
Add this line to the crontab:
0,30 * * * * /usr/bin/wget -O - -q http://localhost/cron.php?cron_key=3979hhoUyiCQ2PhRpWEZc3lrnFbPvPeXSBDSC5kEk0U
Now save the changes. We have now added a UNIX cron job that will occur every 30 minutes that will execute the cron.php script and cause Drupal to perform housekeeping tasks.