These are some simple guidlines for setting up Drupal on a classic Linux-Apache-MySQL-PHP (LAMP) stack that provides a fair amount of security for the rest of your system.
To start, some common PHP configuration options can be optimized. On some systems, these settings may already be set, but it never hurts to add them yourself just in case.
PHP settings can be controlled in a number of ways. If you have access to the
php.ini configuration file (usually found at
/etc/php.ini), you can simply edit this file to cause system-wide changes. If you'd prefer to make these changes just for your Drupal installation, however, the best place to do so is in your Drupal installation's
- First, increase PHP's memory limit to avoid getting out-of-memory errors when you begin to add a few modules. These errors may look something like this:
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 30720 bytes) in /path/to/drupal/modules/system/system.module on line 1022
- In your
php.inifile, include a line that reads:
memory_limit = 16M. Or…
- …in your
settings.phpfile, include a line that reads:
Apache Virtual Host Configuration
If you have access to your system's Apache configuration files (typically
/etc/apache2/httpd.conf), you can also make some simple changes to simplify Drupal's multisite configuration for subdomains.
# Including a wildcard ServerAlias will direct all traffic to your end
# users site and simplifies using Drupal's multisite configuration for
# This path will vary depending on your system. If you are using debian
# make sure you drop the default images alias. Leaving it can be very
# annoying to users on shared servers.
# Place the log where your end users can see them, and make sure they
# are at the least readable to an end user.
# Performance option:
# You can move the Apache logs to another partition or drive to
# get some small increases in disk i/o on heavily loaded servers.
# You can symlink the log files to /var/www/example.com/logs/
# to keep the persistent user interface, however it doesn't work in
# chroot environments.
CustomLog /srv/www/example.com/logs/access.log combined
# Allow end users to manipulate their virtual hosts to their
# hearts' content by enabling .htaccess files for them.
# Since mod_php doesn't like you to respect su_exec, and safe_mode is just
# too paranoid to be usable, restrict php to the proper vhost but to a level
# above the DocumentRoot so users have some private file space for
# .htpasswd, Drupal files, backups, etc.
php_admin_value open_basedir /var/www/example.com
# Move PHP's temporary files into the open_basedir restricted space.
php_admin_value upload_tmp_dir /var/www/example.com/tmp
# session.save path isn't really necessary for drupal since it
# stores sessions in the database, but for general php enabled
#vhosts it keeps session data tied to each vhost.
php_admin_value session.save_path /var/www/example.com/tmp
MySQL Performance Optimization
Tweaking the configurations for your MySQL database server can give you a boost in performance. The MySQL configuration file is typically
# big ol mysql.querycache(128M) (be aware of your systems memory limitations)
query_cache_size = 134217728
# boost mysql max connections (min = (20*number of drupal sites))