This article covers some basic steps to move an existing installation of Drupal or to create a new installation of Drupal on a linux VPS – in this case one running Ubuntu hosted with Linode. These instructions assume some configurations that we have performed in previous articles, so your individual configuration may vary.
The related articles are our Ubuntu Setup on a Linode VPS, and our PHP, Mysql, Apache Setup on Ubuntu articles.
Your particular situation may vary, but these general steps are common to most situations. These steps are related more to creating databases, moving data around, etc. and do not cover the installation of Drupal in any depth. The Drupal guidebooks have detailed information on this, and the procedure is fairly straightforward (i.e. create the database, copy the files to your location, and edit the settings file with your db username and password).
1. Setup The MySQL Database For Your Site
sudo mysql -u root -p
CREATE DATABASE name;
GRANT ALL PRIVILEGES ON dbname.* TO "dbuser" IDENTIFIED BY "dbpass";
2. Copy Your Database Files (if you are moving an existing site, otherwise the empty database is fine) and your Drupal files to your site:
scp -r -P yoursshport /home/myaccount/mysites/site1 username@yourip:~/webfiles
scp -r -P 30101 /home/myaccount/mysites/site1.sql username@yourip:~/webfiles
3. In case you don’t already have a database dump from a previous host and just for reference. Here is how you peform and database backup and restore for Drupal (and any other database)
mysqldump -u username -p database > file.sql
mysql -u username -p database < file.sql
4. Connect to your server and upload the database file you just copied over:
ssh -P yoursshport yourusername@yourip
mysql -u username -p databasename < /home/websites/site1.sql
5. Copy your web files to the appropriate directory:
cp -r /webfiles* /srv/hostname.com/public
6. Final Apache Changes for Drupal .htaccess to work
In /etc/apache2/domainname.com.conf make sure these sections match:
Options Indexes FollowSymLinks +Includes
allow from all
Drupal and other CMS’s require cron jobs to perform a range of maintenance tasks. The following sets up the crontab to run drupal cron application to perform the necessary system updated. The following lines will run it every 6 hours at 3 minutes past the hour. You can modify this according to your needs (hourly, daily, etc.).
7. Drupal Cron Setup for domain1
sudo crontab -e
3 */6 * * * /usr/bin/wget -O – -q http://domain1.com/cron.php
sudo crontab -l