Virtualmin on Debian Squeeze for Drupal HOWTO
Virtualmin is a powerful and flexible web hosting control panel for Linux and UNIX systems based on the well-known Open Source web-based systems management GUI, Webmin. By using Virtualmin we can simply create a virtual hosting environment for Drupal development/hosting within few clicks, including both Linux user account, Apache virtualhost, MySQL database, PHP5 in FCGI, FTP access, and even more.
This HOWTO will guide you though the Virtualmin installation on top of Debian Squeeze, then demonstrate the virtual hosting functionality by installing a Drupal 7.x website.
Before start I will assume you have a clean Debian Squeeze installed with minimal packages requirement. It is strongly recommend to install Virtualmin for a new host, as it will modify a lot of default settings; from the other point of view, don't install Virtualmin on top of an online production that already well configured ;-)
Configure hostname
You should double confirm the system hostname if it looks good. For example if this host is www.example.com
, the /etc/hostname
should be:
www.example.com
The /etc/hosts
should also be:
127.0.0.1 localhost.localdomain localhost127.0.1.1 www.example.com www
Now reboot your system, and check the system hostname with command:
hostname
Also remember to install some required packages so Virtualmin will works happily:
aptitude install resolvconf php5-curl php5-ffmpeg php5-gd php5-imap php5-mcrypt php5-memcached php5-snmp php5-sqlite php5-tidy php5-xmlrpc php-pear php-apc phpmyadmin rsync colordiff pwgen
Also update default php-apc setup by:
echo -e "extension=apc.so\napc.rfc1867=1" > /etc/php5/conf.d/apc.ini
Install Virtualmin with GPL installation script
Just simply access http://www.virtualmin.com/download.html and download the Virtualmin installation script with wget
:
cd /tmpwget http://software.virtualmin.com/gpl/scripts/install.sh
Now just run it with:
/bin/bash /tmp/install.sh
Follow the console online help message and it will update your apt source list, download required packages, install Virtualmin + Webmin + Usermin, change some configuration files, especially replace Exim4 with Postfix, and so on.
Once it get ready you should able to access Virtualmin (i.e. Webmin) interface with HTTPS + port 10000, e.g. https://www.example.com:10000. Don't forget to reboot the system before next step.
Post-configure after initial installation
Now access https://www.example.com:10000, login with root, and page should show up as below:
The Post-installation Wizard should now show up. Nothing special and just follow the guideline. My suggestion is to keep most unnecessary functionality NOT start up during system boot in order to save more memory.
Once post-installation wizard done, it will show the default landing page of Virtualmin. Note with the top system message, Virtualmin will suggest you to re-check configuration once again:
Well sounds good up to this point, BTW, don't trust the result yet! Remember to reboot your system and double/triple confirm with "System Settings -> Re-Check Configuration" and ensure that everything looks good even system reboot ;-)
Some recommended tweak on Virtualmin especially for Drupal virtual hosting
Next I would like tweak some setting which best suit as our Drupal R&D (which proofed by daily operation).
First of all update default shells from "System Customization -> Custom Shells", choose "Custom shells below...", enable /bin/bash and replace as default (rather than /bin/sh):
Secondly updaet default quota value by accessing "System Settings -> Account Plans -> Default Plan", Update from default 1GB into whatever suitable for your cases (usually I will update it up to 4GB):
So now go to the most important about the server templates. Go to "System Settings -> Server Templates -> Default Settings" and update as below:
- MySQL database
- Default database name: ${PREFIX}
- Prefix for additional database: ${PREFIX}_
- Default database character set: utf8 (UTF-8 Unicode)
- Default database collation order: utf8_general_ci
Moreover go to "System Settings -> Server Templates -> Settings For Sub-Servers" and update as below:
- MySQL database
- Default database name: ${USER}_${PREFIX}
- Prefix for additional database: ${USER}_${PREFIX}_
Ok now Virtualmin should be good enough as a Drupal R&D platform ;-)
Create your first Virtualmin Top-level server for Drupal R&D
When everything get ready you can now create a new server by "Create Virtual Server". Let say we are now creating for domain example.com, so just key in as below:
- Domain name: example.com (NOTE: even we hope to virtual server serve for www.example.com, this alias will automatically create for us so we should provide our base domain name here)
- Administration password: your_own_secret_password
Every required setting for a virtual hosting should setup for you with a single click on-the-fly. Now SSH login to the server with account created above and execute follow command:
echo "<?php print phpinfo(); ?>" > /home/example/public_html/phpinfo.php
Access http://www.example.com/phpinfo.php and result should looks as like as below:
Ok looks good! Now download Drupal 7.8 and extract it to /home/example/public_html:
cd /home/example/tmp/wget http://ftp.drupal.org/files/projects/drupal-7.8.tar.gztar zxvf drupal-7.8.tar.gzrsync -av /home/example/tmp/drupal-7.8/ /home/example/public_html
Access http://www.example.com should now show up Drupal 7.8 installer. Then operate as normal Drupal installation procedure which will not detail here:
How to create another subdomain under same user account, e.g. sub.example.com?
Subdomain management under Virtualmin is very simple: what you need to do is creating a "Sub-server" by accessing "example.com -> Create Virtual Server -> Sub-server" with:
- Domain name: sub.example.com
- Parent server: example.com (example)
Therefore another complete set of virtual hosting skeleton will be created on-the-fly under /home/example/domains/sub.example.com
, including MySQL database with name example_sub
, plus corresponding /home/example/domains/sub.example.com/public_html
:
How to create an alias for existing domain, e.g. alias.example.com for example.com?
This would be especially useful for Drupal multi-site installation, so you can handle and manage numbers of alias by using Virtualmin handy UI. Go to "example.com -> Create Virtual Server -> Alias of example.com" and configure as below:
- Domain name: alias.example.com
- Real server: example.com
Ok that's it, really simple isn't it ;-)
conclusion
Setting up R&D server, configure individual service, manage numbers of project R&D directory is always a nightmare for system administrator of small to medium size website development company. For sure that we can always apply for VPS or Amazon EC2 as R&D platform, but for sure that having your own server will always be the most flexible solution, especially your client may not only request for Drupal service or fancy 3rd party service integration (e.g. LDAP).
By using Virtualmin all complicated setup can simply handle by a friendly web interface. I am now managing my projects (30+ domain/subdomains/alias) with Virtualmin and save me a lot of time. It is also simple enough for Linux-dummy (e.g. our PM able to create new project folder with Virtualmin, where he even don't know much about console commands!).
In case if you can manage your client's server with VPS service, e.g. GoDaddy VDS or Amazon EC2, using Virtualmin and also keep both of your development server and production server configuration in sync, backup and migrate entire project simply, or redeploy website within few minutes.
Using Virtualmin as abstraction layer can also overcome the different of Linux distribution. Let's say you are using Debian as me for R&D, where client's website will host with GoDaddy VDS CentOS server, you can have a smooth backup -> transfer -> restore procedure for entire project redeployment, without understanding the different between deb-based or rpm-based Linux distribution: as long as Virtualmin (i.e. Webmin) able to handle its high-level backup information.
If you didn't try for Virtualmin yet but looking for a stable and powerful virtual hosting solution, you should give a try for it on today ;-)