Pages

Wednesday, August 29, 2012

Drupal Website Building Tips - Part 4


Embed a video

  • You can easily embed a flash video from YouTube on any page. When creating a web page, make sure "Full HTML" is enabled as an input format:
Drupal -> Create content -> Page (or any content type) -> Input format -> Full HTML
For any YouTube video, the code which allows a video to be embedded on your website is found on the YouTube page in the upper right corner in the "Embed" box. Copy this code snippet.
In the "Body:" section of your Drupal Page (or other content), paste the code snippet and save. The video is now embedded on that page.

Add WYSIWYG editor

Apparently the choices here are FCKEditor, BUEditor, and TinyMCE editor. All require IMCE for image handling.
cd /etc/drupal/6/sites/all/modules
sudo wget http://ftp.drupal.org/files/projects/imce-6.x-1.3.tar.gz
sudo tar zxvf imce-6.x-1.3.tar.gz
sudo rm imce-6.x-1.3.tar.gz
  • Install one of the editors, such as BUEditor:
cd /etc/drupal/6/sites/all/modules
sudo wget http://ftp.drupal.org/files/projects/bueditor-6.x-2.1.tar.gz
sudo tar zxvf bueditor-6.x-2.1.tar.gz
sudo rm bueditor-6.x-2.1.tar.gz
Note: If you wish these modules to be available to only one subsite, then install them instead into the /etc/drupal/6/sites/mysite_x/modules folder.
Drupal -> Administer -> Modules -> Other -> select IMCE and BUEditor module functions to enable
Note: You must update and adjust permissions after module installation.

Update modules

Periodically, added modules are updated for security and functionality reasons. As always, backups are routinely advised before updating. In Drupal, most module updates are accomplished by overwriting old code with new code, not by patches. Therefore, if you have a highly customised installation, perform updates with care.
In this example, I will update Ubercart. Updating a module is essentially the re-installation of the new update, overwriting the old update.
cd /etc/drupal/6/sites/all/modules
sudo wget http://ftp.drupal.org/files/projects/ubercart-6.x-2.2.tar.gz
sudo tar zxvf ubercart-6.x-2.2.tar.gz
sudo rm ubercart-6.x-2.2.tar.gz
Note: If a module is available to only one subsite, install the update instead into the /etc/drupal/6/sites/mysite_x/modules folder.
Note: You must update after module re-installation.

Perform backups

Yeah, you need to do it. See the Drupal 6 backup instructions. Also see this module for customised backups.

Backup and migrate module

  • Install the Backup and migrate module. This module only supports MySQL, so if you are using postgreSQL, do not use it. Also, this module does not work if you intend to perform an upgrade. Do not use it for backup and restore during an upgrade (it can only be used to backup and restore to exactly the same version of Drupal6).
cd /etc/drupal/6/sites/all/modules
sudo wget http://ftp.drupal.org/files/projects/backup_migrate-6.x-2.2.tar.gz
sudo tar zxvf backup_migrate-6.x-2.2.tar.gz
sudo rm backup_migrate-6.x-2.2.tar.gz
Note: If you wish this module to be available to only one subsite, then install it instead into the /etc/drupal/6/sites/mysite_x/modules folder.
Drupal -> Administer -> Site building -> Modules -> Other -> select Backup and migrate module functions to enable
Note: You must update and adjust permissions after module installation.
The module saves manual backups by default to /etc/drupal/6/sites/mysite_x/files/backup_migrate/manual and cron-scheduled backups to /etc/drupal/6/sites/mysite_x/files/backup_migrate/scheduled, but you can (and should) change this:
Drupal -> Administer -> Backup and migrate -> Destinations
  • Perform a Quick backup into the "manual" backup directory:
Drupal -> Administer -> Backup and migrate -> Backup -> Quick Backup -> Backup from Default Database to Manual Backups Directory using Default Settings -> Backup Now

Backup and restore the MySQL database

  • This is an alternative to the Backup and migrate module that is necessary if you wish to backup during a migration of your website. The best way is to backup the original database with a MySQL dump:
mysqldump -u user -p databasename > drupaldatabasebackupfile.sql
or, if on a remote host:
mysqldump -h hostname -u username -p databasename > drupaldatabasebackupfile.sql
Note that the username and password should be the username and password that were used to create the specific database (not the MySQL root username/password).
  • The database should be restored to an empty database in the new site, because if you re-install a new database in the new site and then attempt to restore your old backed-up database on top of it, there is likely to be incompatibilities between the two. Here the username and password are those for the new empty database just created. (It probably is best to make them the same as those of the imported database.)
mysql -u username -p databasename < drupaldatabasebackupfile.sql
Notes: This was successful for me only if backing up and restoring to exactly the same version of Drupal6. I could not back up the database from one version of Drupal6 then restore to an upgraded version of Drupal6, because the scripts of the upgraded version of Drupal6 did not access the database in the same manner. I therefore performed upgrades only after moving the database.

Empty a database

I hesitate to put these instructions here. Be careful. This erases your database. Use it only if you are confident that you have made good backups. I use this only if I have created a database by accident (during the Drupal6 installation process) and wish to erase/empty it.
mysql -u root -p
mysql> DROP DATABASE mysqlexampledatabase;
mysql> quit
If your MySQL superuser name is something other than root, then use that, of course. Don't forget the semicolon ( ; ) at the end of each MySQL command.
Of course, once you erase the database, you must re-create a blank one for use with Drupal6.
sudo dpkg-reconfigure drupal6
Then you can restore the backup (as created above with mysqldump) into the newly recreated (but still empty) database.
mysql -u username -p databasename < drupaldatabasebackupfile.sql

Moving a Drupal6 installation to a new site

  • Install drupal6 on the new site (sudo apt-get install drupal6). When creating the database, use the same values as used on the old site. If you can't remember what they were, look at the /etc/drupal/6/sites/default/dbconfig.php (or similar) file for the old site (which contains the values for the old site).
  • On the new site, rename the newly created folders
  • /etc/drupal/6
  • /usr/share/drupal6
  • /var/lib/drupal6
to
  • /etc/drupal/6.bak
  • /usr/share/drupal6.bak
  • /var/lib/drupal6.bak
  • Copy the /etc/drupal/6, /usr/share/drupal6, and /var/lib/drupal6 folders from the old site to the new site. (This needs to be done as the root user, which can be done with sudo dolphin).
  • Copy the database dumpfile from the old site to the new site.
  • Check the settings.php, dbconfig.php, files and other folder permissions to make sure they match the permissions of the original system. (Sometimes during the copy process the ownership of all files and folders will be set to root.) In particular, make sure that dbconfig.php belongs to the www-data group.
Notes: I have never been successful in performing an upgrade in the middle of this process. I recommend moving the site exactly, and then performing any upgrades after it is moved.

No comments:

Post a Comment

Thanks for your comment.