Posted by dhj on Wed 15 Aug 2007 at 10:08
Drupal is an excellent free software content management system, written in PHP. It's a good choice if you have to build a new site for non-technical users or customers, as both content editing and site administration can be done directly in the main site by authenticated users, and there's very little markup for those users to learn.
I'd investigated and deployed several different content management systems before discovering Drupal. For me, the best thing about switching to this particular CMS was that you can create templates that use only CSS for layout, rather than tables, and the application itself doesn't fill your CSS layouts with tables either. Drupal has a very active community too.
Packages
Drupal runs well on Etch, and pretty much everything you need is already packaged in the Etch repositories. There's a Drupal 4.7 package in Etch, but to get the latest 5.2 release you'll need the version from Debian testing. Alternatively, you can wget the latest tarball from the Drupal.org site, and unpack it as the web root directory you have set up in your Apache 2 configuration. For example, unpack the tarball in /var/www/ and point Apache's virtual host directive at a DocumentRoot of /var/www/drupal-5.2
You should make sure PHP5 is installed and working at this point. You'll also need a database server. MySQL 5 is the most common choice, and so that's what I'll be describing the use of in this article. PostgreSQL 7.3 or later is supported by the Drupal core modules, but not by all of the Drupal community's contributed modules (which can be very useful for extending your site).
Changing MySQL defaults
Some of the packages in Etch don't have appropriate defaults for a Drupal site, particularly if you are running your website on a virtual server, where memory resources are shared with other people's sites.
Firstly, set a root password for MySQL if you haven't done so already:
# mysql -u root
mysql> SET PASSWORD FOR root@localhost=PASSWORD('new_password');
mysql> quit;
Replace new_password in the above with something long and complicated; lots of random letters and numbers. This is not the root password for your system, it's for the primary database administrator, so it should be a different password (even if one person has both these roles).
Now you've set a root password, from now on you'll need to connect to MySQL with:
# mysql -u root -p
and you'll then get a password prompt. There are many more tips for hardening MySQL in this Security Focus article: www.securityfocus.com/infocus/1726
Then, edit /etc/mysql/my.cnf and remove the comment in front of the line:
skip-innodb
By default, the MySQL configuration in Etch will start two database engines, both MyISAM and InnoDB. You only need one engine running for a Drupal site, and making this small tweak can halve MySQL's memory usage as soon as you restart it with:
# /etc/init.d/mysql restart
Installing Drupal
After this, you can create a MySQL database for Drupal to use, following the install instructions on the Drupal site, or the install documents in the Drupal download tarball. Once that's done, open your web browser and enter the URL of the site you've set up in your Apache 2 configuration.
If everything has been configured correctly, you should see a Drupal page which asks you to enter the details of the MySQL database you've just set up. If that database works, you should next see a default Drupal page. You should now create the first user account straight away, with a good strong password, as this first user is the administrator of your new Drupal site.
Drupal performance tweaks
Once you've chosen a theme, set your site information (such as site name, slogan and logo) and posted some initial content, there's a further tweak you should make as soon as possible.
On the Drupal navigation menu, by default in the left sidebar, go to Administer >> Site configuration >> Performance. Caching mode will be set to Disabled by default. You need to set this to Normal, otherwise your server could take a severe performance nosedive as soon as your new site starts getting a decent number of hits. This is because with caching disabled, Drupal will serve a fresh, dynamically generated page to every single anonymous viewer that drops by.
You can also set a minimum cache lifetime and enable CSS aggregation on this page, which should also help if site load increases. If you've made all these tweaks and your site still runs into memory exhaustion problems, particularly if it's running on a virtual server with shared hardware, you can lower Apache's MaxClients setting and MySQL's max_connections setting.
This article can be found online at the Debian Administration website at the following bookmarkable URL:
This article is copyright 2007 dhj - please ask for permission to republish or translate.