Over a year ago I discovered the beauty of Drupal and the amazing things that could be done with it, and typically without doing any major programming. Modules like CCK, Views and the helpers for these modules make developing dynamic websites a snap. You will most likely need a bit of knowledge in terms of html/css (modifying templates to suite your needs) but in my experience I've had to do only a very moderate amount of actual PHP coding. If anything, I could add some specific behaviour to the page through the use of javascript.
After building several drupal sites and hosting them locally, I found that it was a bit of a pain to manage updates. I thus looked into what it would take to run all of the sites off of a drupal multisite installation. It really wasn't that bad, however I found that to be fully compatible it took several (error prone) steps to get setup. I figured I'd write a script to do the heavy lifting for me (its not really heavy lifting, just monotonous commands that are easy to mix up or get wrong if its been awhile since you last did a setup).
Here is the script:
#!/bin/bash
drupal_dir="${HOME}/webapps/cms/drupal"
site_dir="${HOME}/public_html"
if [ ! -d "$drupal_dir" ]
then
echo "Specified drupal directory either does not exist or is not a directory"
exit;
fi;
drupal_dir=`cd ${drupal_dir};pwd`
mkdir -p "$drupal_dir/sites/all/modules"
mkdir -p "$drupal_dir/sites/all/themes"
if [ ! -d "$site_dir" ]
then
echo "Specified site directory either does not exist or is not a directory"
exit;
fi;
site_dir=`cd ${site_dir};pwd`
echo "drupal directory: $drupal_dir"
echo "site directory: $site_dir"
read -e -p "Does this look correct? (y-continue, n-exit) "
if [ "$REPLY" == "n" ] || [ "$REPLY" == "N" ]
then
exit
fi;
settings_file="${drupal_dir}/sites/default/default.settings.php"
if [ ! -f "$settings_file" ]
then
echo "Settings file does not exist. You'll have to do create it at $drupal_dir}/sites/default and run this script again"
exit;
fi;
while true;
do
read -e -p "Enter site name or q when finished:" site_name
if [ "$site_name" != "q" ]
then
echo "creating ${site_name}..."
cd ${site_dir}
if [ ! -e "$site_name" ]
then
mkdir ${site_name}
cd ${site_name}
site_path=`pwd`
read -e -p "Enter domain name of website or press enter to use the site name as the domain name" domain_name
if [ -z "$domain_name" ]
then
domain_name="$site_name"
fi;
mkdir -p sites "sites/$domain_name"
cd "${drupal_dir}/sites"
mkdir -p "$domain_name" "$domain_name/files" "$domain_name/modules" "$domain_name/themes"
chmod ug+w "$domain_name/files"
cp "${drupal_dir}/.htaccess" "${drupal_dir}/robots.txt" "$site_path"
cp "$settings_file" "${drupal_dir}/sites/${domain_name}/settings.php"
chmod ug+w "${drupal_dir}/sites/${site_name}/settings.php"
ln -s "$drupal_dir/misc" "$site_path/misc"
ln -s "$drupal_dir/modules" "$site_path/modules"
ln -s "$drupal_dir/themes" "$site_path/themes"
ln -s "$drupal_dir/sites/all" "$site_path/sites/all"
ln -s "$drupal_dir/sites/$site_name/files" "$site_path/sites/$domain_name/files"
ln -s "$drupal_dir/sites/$site_name/modules" "$site_path/sites/$domain_name/modules"
ln -s "$drupal_dir/sites/$site_name/themes" "$site_path/sites/$domain_name/themes"
cd $site_path
files="index cron update xmlrpc install"
for f in $files;
do
echo "<?php
chdir('${drupal_dir}');
include('./${f}.php');
?>" > ${f}.php
done
echo "setup for ${site_name} : ${domain_name} complete"
fi;
else
break;
fi;
done
echo "finished"
To use this script, first you need to decide where you want to store the actual files for drupal (${drupal_dir} above).
Set that variable to suite your needs, and put your drupal installation there. This directory shouldn't be web accessible.
Then set the variable where your actual webroot lives (the directory where the site would be deployed).
Once you have that setup, you just run this command (with no arguments) and it will ask for the name of the site and then the domain of the site.
With my hosting provider, it creates a directory names without the TLD, thus example.com would be in public_html/example
Thus, when the script asks me for the name, I would enter example
and when it asks for the domain, I would enter example.com.
You can continue doing this for multiple sites if you want, but usually you just setup one and exit.
Now your directories should be setup, you'll need to make sure you have your apache configuration all setup to run the site, then just go to yoursite.com/install.php
to install the newly created site.
