Installing virtual hosts for Drupal sites and subsites
Last modified: September 20, 2008 - 05:51
The purpose of this guide is to concisely summarize how to implement apache vhost settings for each site or subsite.
All steps for this tutorial were implemented with Debian using Apache version 2.0.54.
- Gain entrance into your shell system, and su to root or another user that can edit apache2 configuration files.
- Go to your apache configuration files:
cd /etc/apache2/sites-available - Create a configuration file for your new site. For an example site, www.example.com, we make the site as such:
nano example.com<VirtualHost *:80>
ServerAdmin me@myserver
DocumentRoot /home/web/drupal/
ServerName www.example.com
ServerAlias example.com *.example.com
RewriteEngine On
RewriteOptions inherit
CustomLog /var/log/apache2/example.com.log combined
</VirtualHost>
<VirtualHost *:443>
ServerAdmin me@myserver
DocumentRoot /home/web/drupal/
ServerName www.example.com
ServerAlias example.com *.example.com
RewriteEngine On
RewriteOptions inherit
CustomLog /var/log/apache2/example.com.log combined
# SSL Specific options
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile /etc/ssl/apache/CA.crt
SSLCertificateKeyFile /etc/ssl/apache/CA.key
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
</VirtualHost> - Activate the site's configuration:
a2ensite www.example.com - Reload Apache's configuration:
/etc/init.d/apache2 force-reload
Done!
If you get an apache error '/home/www/drupal5/.htaccess: Option Indexes not allowed here'
Assuming that my apache2 DocumentRoot is at /home/www,
and that drupal is linked to the doc root by
ln -s /usr/share/drupal5 /home/www/
add the following to /etc/apache2/conf.d/drupal.conf
<Directory /home/www/drupal5/>
Options +FollowSymLinks Indexes
AllowOverride All
order allow,deny
allow from all
</Directory>
Worked for me. Thank you
Worked for me. Thank you very much. The only trouble was an apache error '/home/www/drupal5/.htaccess: Option Indexes not allowed here'
Assuming that my apache2 DocumentRoot is at /home/www,
and that drupal is linked to the doc root by
ln -s /usr/share/drupal5 /home/www/
my fix is adding the following to /etc/apache2/conf.d/drupal.conf
<Directory /home/www/drupal5/>Options +FollowSymLinks Indexes
AllowOverride All
order allow,deny
allow from all
</Directory>
In actual fact, i found the above could replace the file /etc/apache2/conf.d/drupal.conf, as the old
contents didnt seem to do anything for me. It works either as an addition or a replacement for me.
Hmm...didn't work
I got an error saying:
"Syntax error on line 9 of /etc/apache2/sites-enabled/mysite: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration...fail"
www.corydorning.com
Shell scripts for Drupal and virtual hosts install
Note 7/6-09: I recently started to look into the drush project, and I have started to make a drush version of the shell scripts below. The densite script (aka the a2ensite debian script) can be found at http://www.os-cms.net/node/46 The densite script does the same things as the shell scripts found below (and some more: e.g. list your sites, populate database from a dump on install, or import dumps from other of your sites. It can also install directly via download and set up mysql or postgresql databases, setup the virtual host and then reload apache. It is intended to work out of the box on Debian machines. Just dump the densite folder in your drush command folder and it should work right away on Debian based machines (Tested on ubuntu .8.10 intreped and and Ubuntu 8.04 Hardy)
---
I've just installed Drupal. I found Drupal very clear and easy to install and start using. So I wanted to make another site, but I could not find a shell script for installing Drupals and virtual host for apache2 on-the-fly, so i created two simple scripts that accomplish this task. You need to be root to use these scripts, or another dedicated user who can change apache2s configuration, create files and databases.
I've used Drupal-6.10, and I don't know about other versions of Druapl.
Shell Script For Creating Virtual Drupal Hosts From Single Codebase
Shell Script for Creating Virtual Drupal Hosts From Standalone Codebase
Shell Script for Creating Virtual Drupal Hosts From Standalone Codebase
Go to eg. http://www.os-cms.net/install.php to create your new site:
All your have to do is enter an admin user password and email for your new site, and your new site is up.
Shell Script for Creating Virtual Drupal Hosts From Standalone Codebase
http://www.os-cms.net