Drupal7 tips

From

Revision as of 16:01, 8 February 2013 by Perspectoff (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Drupal7 tips

These tips were written for Drupal6 and have not yet been edited for Drupal7 and therefore may not be accurate; this section is under construction.

Drupal (Web content publishing)

Drupal is the leading open-source package for website creation and content collaboration. A modular approach to website building, from simple out-of-the-box websites to complex sites, is possible with a short learning curve. Get more info on how to get started. Drupal requires an installation of a LAMP server stack; if you have not already installed LAMP, it will be installed along with Drupal 6. I have found it easier to use the MySQL database (the "M" in LAMP), but Drupal6 can also integrate with PostgreSQL if you have it installed. Drupal is available as a package, or from the command-line terminal:

sudo apt-get install drupal6
  • After everything is installed (and the problems below sorted out), make sure the apache2 rewrite engine module is enabled, then restart the apache2 server:
sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart
  • Finish installation through your browser:
http://localhost/drupal6/install.php

Installation quirks

Exim vs. Postfix

Exim and Postfix are mail handlers. I had installed Postfix at the time I installed my Ubuntu server (but was not using it). But Drupal uses Exim and therefore removes Postfix at installation and installs Exim instead. Therefore, it is better not to use Drupal on a mail server that uses Postfix.

Folder permissions

The files folder must belong to the www-data group, and the group must have "Can View & Modify Content" permissions.

The dbconfig.php file must belong to the www-data group, and the group must have "Can read" permissions.

Prior to the initial installation through the browser, make sure the settings.php file initially has "Can View & Modify Content" permissions set for Owner, Group, and Others. If it doesn't, an installation error will be generated. (As part of the installation process, the permissions will subsequently be adjusted to their final desired settings automatically.)

Browser installation

Status report

Updates

You may get the message that you need to update. The message won't go away. It's less easy once you've set up your site, so you should do it now.

  • Download the recommended update to your /etc/drupal folder and extract it. For example:
cd /etc/drupal
sudo wget -O drupal-current.tar.gz http://ftp.drupal.org/files/projects/drupal-6.16.tar.gz
sudo tar zxvf drupal-current.tar.gz
  • Read the UPGRADE.txt file that was extracted. It has complete details how to upgrade. The following instructions are for first time installation only, since I am not backing up the databases (which is a step you should not skip if you have already been using Drupal):
  • Go offline:
http://localhost/drupal6/?q=admin/settings/site-maintenance -> Offline
or
Drupal -> Administer -> Site configuration -> Site maintenance -> off-line -> Save configuration
  • Copy all the files that were extracted into the installation directory (which is /usr/share/drupal6):
sudo cp -rf /etc/drupal/drupal-6.16/* /usr/share/drupal6
Note: the option -f forces the old files to be overwritten.
  • Update the core database tables using the provided script:
http://localhost/drupal6/update.php
  • Go back online:
http://localhost/drupal6/?q=admin/settings/site-maintenance -> Online

There are lots of other steps to take if you are already using Drupal, so read the UPGRADE.txt file carefully.

  • If you are upgrading a multi-site version, it is trickier. If the core modules and themes were originally copied to the /etc/drupal/6/sites/all folder, the newly-updated core modules and themes should again be copied there. (Be careful, though, not to overwrite your own customized themes if you have already created some or modified the originals.)
sudo cp -rf /etc/drupal/drupal-6.16/modules/* /etc/drupal/6/sites/all/modules
sudo cp -rf /etc/drupal/drupal-6.16/themes/* /etc/drupal/6/sites/all/themes
Each of the multiple sites must then be updated individually.

Note: Many users do not use customized themes and prefer to have the core modules and themes always updated along with their core Drupal updates. For these users, it is best not to copy the core modules and themes into the /etc/drupal/6/sites/all folder. (Whenever the core installation is then updated, therefore, the modules and themes in the core installation directory (i.e. /usr/share/drupal6) will be simultaneously updated.) These users will only install add-on modules and customized themes into their /etc/drupal/6/sites/all or /etc/drupal/6/sites/mysite_x folders.

Cron

The documentation for this task is here. My site is small, so my cron task is daily and simple (and can be run by hand using):

http://localhost/drupal6/cron.php

I can add the task to my cron list:

sudo crontab -e

And add the line (with the nano editor, or the one you prefer):

45 18 * * * /usr/bin/wget -O - -q -t 1 http://localhost/drupal6/cron.php

this will run the script at 45 minutes after 1800 every day.
If you want it to run every hour on the hour, then use:

0 * * * * /usr/bin/wget -O - -q -t 1 http://localhost/drupal6/cron.php

Multi-site Installation

If you intend to run multiple websites, using a single Drupal6 installation, then follow these instructions carefully. I could only get this to work if each site had its own domain name, e.g mysite_1.mydomain.org and mysite_2.mydomain.org. (I could not get it to work for mysite.mydomain.org/subsite_1 and mysite.mydomain.org/subsite_2).

  • Install Drupal6 and the first website (mysite_1.mydomain.org).
sudo apt-get install drupal6
Configure database for drupal6 with dbconfig-common? Yes
Database type to be used by Drupal6: mysql
Password of your database's administrative user: mysqlrootpassword
MySQL application password for drupal6: mysqldrupal6password
  • Copy the /etc/drupal/6/sites/default folder to the first subsite (in this example named mysite_1.mydomain.org).
sudo cp -r /etc/drupal/6/sites/default /etc/drupal/6/sites/mysite_1.mydomain.org
  • Remove the symbolic link and create a new files folder. The files folder should belong to the group www-data, and the group should have "Can View & Modify Content" permissions.:
sudo rm /etc/drupal/6/sites/mysite_1.mydomain.org/files
sudo mkdir /etc/drupal/6/sites/mysite_1.mydomain.org/files
sudo chown -R root:www-data /etc/drupal/6/sites/mysite_1.mydomain.org/files
sudo chmod 764 /etc/drupal/6/sites/mysite_1.mydomain.org/files
  • Copy a 135x135 image that you wish to use as a logo (in the upper left corner) into the /etc/drupal/6/sites/mysite_1.mydomain.org/files folder. Rename it WebLogo.png in that folder.
  • Create a virtual host file for the new sites:
sudo nano /etc/apache2/sites-available/drupal6virtualhost

Add the lines:

#
# Virtual hosting configuration for Drupal6
#
#
<VirtualHost *:80>
ServerAdmin webmaster@mysite_1.mydomain.org
#
DocumentRoot /usr/share/drupal6/
ServerName mysite_1.mydomain.org
ServerAlias *.mysite_1.mydomain.org mysite_1.mydomain.org
RewriteEngine On
RewriteOptions inherit
</VirtualHost>
#
<VirtualHost *:80>
ServerAdmin webmaster@mysite_2.mydomain.org
#
DocumentRoot /usr/share/drupal6/
ServerName mysite_2.mydomain.org
ServerAlias *.mysite_2.mydomain.org mysite_2.mydomain.org
RewriteEngine On
RewriteOptions inherit
</VirtualHost>
  • Remember that your virtual host configuration file won't be active until you make a symbolic link:
sudo ln -s /etc/apache2/sites-available/drupal6virtualhost /etc/apache2/sites-enabled
  • Restart Apache:
sudo /etc/init.d/apache2 restart
  • Install the first website through the (Konqueror/Firefox) browser:

http://mysite_1.mydomain.org/install.php

Site Name: My Website 1
Site e-mail address: webmaster@mysite_1.mydomain.org
Administrator Account Username: webmaster -> Password: mywebmasterpassword
Clean URLs: Enabled
  • Makes sure only administrators can create new accounts initially, or you will have lots of new guest within the first 30 minutes of being live.
Drupal -> Administer -> User management -> User settings -> Only site administrators can create new accounts
  • Now you will re-install a new database for each planned subsite.:
sudo dpkg-reconfigure drupal6
  • Re-install database for drupal6? Yes
  • Database type to be used by drupal6: mysql
  • Connection method for MySQL database of drupal6: unix socket
  • Name of your database's administrative user: root
  • Password of your database's administrative user: mysqlrootpassword
  • username for drupal6: drupal6b
  • database name for drupal6: drupal6b
  • Copy the /etc/drupal/6/sites/default folder to the second subsite (in this example named mysite_2.mydomain.org).
sudo cp -r /etc/drupal/6/sites/default /etc/drupal/6/sites/mysite_2.mydomain.org
  • Remove the symbolic link and create a new files folder. The files folder should belong to the group www-data, and the group should have "Can View & Modify Content" permissions.:
sudo rm /etc/drupal/6/sites/mysite_2.mydomain.org/files
sudo mkdir /etc/drupal/6/sites/mysite_2.mydomain.org/files
sudo chown -R root:www-data /etc/drupal/6/sites/mysite_2.mydomain.org/files
sudo chmod 764 /etc/drupal/6/sites/mysite_2.mydomain.org/files
  • Sometimes the permissions of the settings.php and dbconfig.php must be unrestricted during installation:
sudo chmod 777 /etc/drupal/6/sites/mysite_2.mydomain.org/settings.php
sudo chmod 777 /etc/drupal/6/sites/mysite_2.mydomain.org/dbconfig.php
  • Install the second website through the (Konqueror/Firefox) browser:
http://mysite_2.mydomain.org/install.php
Site Name: My Website 2
Site e-mail address: webmaster@mysite_2.mydomain.org
Administrator Account Username: webmaster -> Password: mywebmasterpassword
Clean URLs: Enabled
  • Makes sure only administrators can create new accounts initially, or you will have lots of new guest within the first 30 minutes of being live.
Drupal -> Administer -> User management -> User settings -> Only site administrators can create new accounts
  • This process can be repeated if desired (if enough URLs are available).
  • The two websites will be available:
http://mysite_1.mydomain.org
and
http://mysite_2.mydomain.org

Now you have two separate sites. When it is time to upgrade, you will only have to upgrade the core Drupal installation.

Copy modules and themes folders

  • Files, themes, and modules to be shared by all subsites should go in the "all" subsite. (This is an optional step, but if you don't, then the core installation modules and themes folders will be used for common files. If you modify any of the core installation modules or themes, they will be overwritten at the time of an upgrade). Copy the code folders:
sudo cp -a /usr/share/drupal6/modules/ /etc/drupal/6/sites/all
sudo cp -a /usr/share/drupal6/themes /etc/drupal/6/sites/all
and (optionally) make a directory for shared files:
sudo mkdir /etc/drupal/6/sites/all/files
sudo chmod 777 /etc/drupal/6/sites/all/files
  • (Optionally), copy the themes and modules from the core installation folder to your subsite folder, so you can customize them without changing the core installation:
cp -a /usr/share/drupal6/modules/ /etc/drupal/6/sites/mysite_x.mydomain.org
cp -a /usr/share/drupal6/themes /etc/drupal/6/sites/mysite_x.mydomain.org

Note: If you do these steps before installing each subsite, Drupal will get confused and will display an error. Therefore, do this step only after completing the installation (install.php) script. During installation, Drupal only likes to find one modules folder (i.e. the one in /usr/share/drupal6). If you are adding subsites after having already used Drupal for a while, then temporarily rename the modules (and themes) folders in the /etc/drupal/6/sites/all folder to something else (such as modules.bak and themes.bak). Make sure there are no modules or themes folders in the subsite folder (i.e. in the /etc/drupal/6/sites/mysite_x.mydomain.org folder) until after installation has been completed. Then you can complete the steps above (or merely rename modules.bak and themes.bak to modules and themes again). You may need to run the update.php script for each subsite again, after doing this.

Note: Many users do not use customized themes and prefer to have the core modules and themes updated along with their core Drupal updates. For these users, it is best not to copy the core modules and themes into the /etc/drupal/6/sites/all folder. (Whenever the core installation is then updated, therefore, the modules and themes in the core installation directory (i.e. /usr/share/drupal6) will be simultaneously updated.) These users will only install add-on modules and customized themes into their /etc/drupal/6/sites/all or /etc/drupal/6/sites/mysite_x folders.

Update each site

There are a variety of error messages that may occur when using a multi-site installation (from initially using shared configuration files). Many can be cured just by updating each subsite individually. This will update configuration files and store them in your subsite folder(s). You must be logged in as the original user of the subsite to run the update script.

http://mysite_x.mydomain.org/update.php

Multisite cron

Refer to these instructions. I can add the task(s) to my cron list:

sudo crontab -e

And add the lines (with the nano editor, or the one you prefer):

45 18 * * * /usr/bin/wget -O - -q -t 1 http://mysite_1.mydomain.org/cron.php
45 19 * * * /usr/bin/wget -O - -q -t 1 http://mysite_2.mydomain.org/cron.php
45 20 * * * /usr/bin/wget -O - -q -t 1 http://mysite_3.mydomain.org/cron.php
this will run the scripts separately, at 45 minutes after the 1800 hour, the 1900 hour, and the 2000 hour every day (each site at a different hour).
If you want all the cron scripts to run every hour, then stagger them:
0 * * * * /usr/bin/wget -O - -q -t 1 http://mysite_1.mydomain.org/cron.php
20 * * * * /usr/bin/wget -O - -q -t 1 http://mysite_2.mydomain.org/cron.php
40 * * * * /usr/bin/wget -O - -q -t 1 http://mysite_3.mydomain.org/cron.php
this runs one script on the hour (0), one script at 20 minutes past the hour, and one script at 40 minutes past the hour.

Build your site

You should be ready to go. Start building your site.

Personal tools
Sponsor
     Asus 1015E