Drupal 6 is SLOW

So Drupal 6 is incredibly slow right now. We, Adam and I, just installed a lot of modules and enabled them.

Setup is Debian 5 with Apache 2.

1st assumption
Database. Accessing the database could be the reason. Checking the logs (@ /var/log) of mysql reveals nothing, there is nothing there. Perhaps I didn't enable logging. I'll check on that later.

2nd assumption
Modules. Let's disables all the modules! It helped just a tiny bit. In the process of this I disable all caching options of Drupal.

So I took a day or so break to think it over, maybe I'm over thinking this. Check on the website again and it's fast! Except, when you click on the administration URL it's very slow. Here's the reason why on the Drupal support forum:

"cog.rusty - February 21, 2009 - 13:50

The admin pages in Drupal 6 are slow because they do perform a lot of housekeeping and rebuilding (thousands of queries, as you noticed, and these are not just cosmetic). Caching probably won't help with that.

If it is unworkable, disabling the update status module will probably help a bit, and also there are open issues for reducing the number of queries in next updated, but don't expect the D6 admin pages to become snappy. They take the hit for some tasks which make the user part of the site more reliable.

About the normal site pages... the usual optimization methods should apply."


Alrighty then, let's just optimize the webpage.

Installed some tools to help me:
Life-of-Request Info extension
Devel module (where is this log file?)

1st optimization:
Let's optimize PHP by installing the APC package (read about it here):
Here's a tutorial on using APC.
http://www.easywebdns.com/tutorials/Linux/php/APC_ON_DEBIAN_LENNY

Access to main drupal as webmaster:
1st try: 1.3 s
2nd try (browser's cache cleared): .661s
3rd try: 0.877s

As a non user: 0.536s


Let's enable all the modules:

main page: 1.114s - 1.124s
content generated pages: ~.224s at most < .5s (no pictures or anything heavy just texts) Yay, it's faster!

Drupal's Website Down Error

If you get this error from Drupal:

Unable to use the MySQLi database because the MySQLi extension for PHP is not installed. Check your php.ini to see how you can enable it.

The php.ini is located at: /etc/php5/apache2/php.ini

I was trying to give a direct link to php modules for one of the Drupal modules and it just didn't work.

Ubercart Quest: Clean URL for Drupal

Problem:

Product's images are not showing
One of the solutions or problem from the Ubercart's forum is Clean URLs is not enable.



Step 1: Clean URLs needs mod_rewrite to be enable
(Note: mod_rewrite is an Apache 2 module)

Type this command to see all the modules that is currently enable on Apache 2.

/usr/sbin/apache2ctl -M


Look for rewrite_module this is the mod_rewrite module that clean URL requires.

Step 2:
If mod_rewrite is not enable

To enable mod_rewrite module:

sudo /usr/sbin/a2enmod rewrite


You should get this after entering the command:


Enabling module rewrite.
Run '/etc/init.d/apache2 restart' to activate new configuration!



To disable the mod:

sudo /usr/sbin/a2dismod rewrite

You should get this after disabling the mod:

Module rewrite disabled.
Run '/etc/init.d/apache2 restart' to activate new configuration!
Remember to restart apache2:
sudo /etc/init.d/apache2 restart


Step 3: Check your apache2 config file
(I'm an apache2 noob so bare with me)

In the /etc/apache2/sites-enabled folder I've created a conf file that tells apache2 to host my drupal website.

Here's the general gist of what the config file, /etc/apache2/sistes-enabled/drupal.conf, have:



ServerName www.example.com
DocumentRoot /var/www/drupal-6.13

Options FollowSymLinks
AllowOverride None
Order allow,deny
allow from all



What you need to add:


RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

So it should look like this:


ServerName www.example.com
DocumentRoot /var/www/drupal-6.13

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Options FollowSymLinks
AllowOverride None
Order allow,deny
allow from all




Remember to restart apache2:
sudo /etc/init.d/apache2 restart

Step 4: Enabling Clean URLS




System: Debian Lenny with Apache2

For information about mod_rewrite:
Apache module mod_rewrite

This post made possible by a mash of information from these websites:

Find It