I'm a new Drupal developer and am going through the docs to get my head around the project. I'm finding some places where I think I can add a lot of value by cleaning up bits of the documentation. Most notably, on the recent (and helpful!) "Best Practices" section regarding configuration Apache and PHP, which currently seems to simply have a copy-and-paste from a httpd.conf file, I suggest changing the content of the page to incorporate the following version:
#### STARTING TO CLEAN UP #####
#### todo: mysql tuning section ####
#### markup layout and use > <
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.
PHP Configuration
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 settings.php file.
- 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:ini_set('memory_limit', '16M');
- In your
Apache Virtual Host Configuration
If you have access to your system's Apache configuration files (typically /etc/httpd/httpd.conf or /etc/apache2/httpd.conf), you can also make some simple changes to simplify Drupal's multisite configuration for subdomains.
ServerName example.com
# Including a wildcard ServerAlias will direct all traffic to your end
# users site and simplifies using Drupal's multisite configuration for
# subdomains.
ServerAlias *.example.com
# 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.
DocumentRoot /var/www/example.com/public_html
# 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.
ErrorLog /srv/www/example.com/logs/error.log
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.
AllowOverride All
# 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 /etc/my.cnf.
# 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))
set-variable=max_connections=512
eacclerator
Comments
Comment #1
meitar commentedI don't have the access privileges I seem to need to make this change myself. Therefore, since I can't assign it to someone else, I'll simply un-assign it at the moment.
Comment #2
jefbak2 commentedI am currently stuck with the register_globals issue and could really use more documentation on this aspect of preparing for a drupal install in LAMP environments.
More on PHP and CGI considerations would be helpful for the non Unixers among us (like me).
Comment #3
Shai commentedMeitar,
This is a great idea. It will be a fine addition to the manual.
Have you checked if something like this already exists in the manual. If it does, you should edit that (after you get docs privileges), if not go for it, create a new page.
Re: content: I'd give some more examples on php settings that often need changing like max_post_size for example. I'd also give an example of how to change it in the .htaccess as an alternative to the settings.php.
I'm totally clueless on the MySQL twaking. I'm very curious. Is there another way to make those tweaks if you don't have access to the configuration file you mentioned, just like you can change php settings without having access to php.ini? I think discussing that, no matter what the answer is, would make a great addition.
In short, Go for it!
Shai
Comment #4
meitar commented@Shai:
It should be noted that the original document (at http://drupal.org/node/36628) was dopry's, and he's probably more familiar with the specifics of how to optimize Drupal, as I understand he's been a Drupal contributor for a long time. I was simply searching for best practices on Drupal set ups, came across his page, saw the code, and figured some English would go quite nicely with it, so I created this doc issue here. :)
That said, I do have some knowledge in this area so I'd be happy to add my own points to this page, too.
@jefbak2:
I'm not sure exactly what you're asking about, but it's almost universally accepted that you should turn off PHP's
register_globalsfeature immediately. It's been off by default ever since PHP 4.2.0, but many hosting providers turn it on "for convenience." See http://php.net/register_globals for more info….Cheers,
-Meitar
Comment #5
meitar commentedFixed. Could still use a bunch more detail, but at least it's formatted and has some inline textual explanations, now.
Comment #6
gpk commentedBig improvement :)
The main thing I don't understand is the title - I thought it meant "Shared Hosting Environment", but in such an environment you wouldn't be able to do most if any of the things suggested.
Also you can now get PHP/Drupal to work nicely with some forms of suexec - as my host has (that's within a cPanel environment).
Finally, I'm not sure if "Best practices" to have this page since there are other pages in different areas which deal with server config. But maybe moving stuff around is a separate issue ... maybe I should join the docs mailing list to get the feel of what current views are on the organisation of handbook sections etc ... Maybe a better solution than shunting stuff round would be for handbook pages to be tagged via taxonomy to enable the user to find pages on the same topic in different sections of the site ..?
Comment #7
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.