Configuring
a single document-root directory for two web-servers running on a
dual-boot computer
Whether
you do all of your own web-development under Linux or not, there is at least one task that still require Windows and Internet Explorer. Many of the
visitors to your site will be using Internet Explorer, and you will
no doubt want to leave a good impression on all of your visitors, and
customers!, regardless of their web browser. Having a dual boot web-server will allow you to see just
how your web-pages will be displayed in all of the major browsers,
including Internet Explorer, even when your web-server is not
connected to a local network.
Where
would I put a “shared” document-root directory?
Anyone
who has configured a dual-boot computer in the past will understand
what I am talking about when I say that Windows is dumb when it comes
to file systems. Windows understands Windows, nothing else. Linux,
on the other hand, is very smart when it comes to file systems. It
understands Windows file systems as well as it’s own. Currently,
Linux has a much easier time writing to FAT32 (or FAT) partitions
than to NTFS partitions, so a Windows FAT32 partition that both
operating systems have full permissions to is then the natural choice
for a home to park the shared document-root directory. A FAT
partition will also work but will have tighter size restrictions than
FAT32 has.

A
“getting started” overview:
A
typical dual-boot system begins life with Windows being installed
first, using just enough physical drive space for the “C:”
drive partition as is necessary. This partition can be formatted to
any file-system that your version of Windows supports including FAT,
VFAT, FAT32 or NTFS. Your web-server of choice (IIS, Apache…)
should be installed and configured with temporary settings and made
operational now. Next, a second Windows partition needs to be
created which will be shared between Linux and Windows. When this
partition is created, don’t forget to leave enough free-space for
your future Linux installation. This partition needs to be formatted
FAT32 or FAT. This will typically be your D: or E: drive, depending
on the drive letter chosen by Windows. Now you will need to create a
directory on your new FAT32 partition that will become the shared
document-root directory. If you installed IIS, you should have a
directory called “inetpub” on your “C:”
drive, which contains a few default web pages in it’s own
document-root directory, “wwwroot”. The easiest thing to
do here is to copy-and-paste the entire “inetpub”
directory, including all subdirectories and files, to your new FAT32
partition. Once you have done this, start your IIS configuration
utility, and change the document-root setting to point to the new
location. You will need to restart your IIS services in the control
panel, or just do the old Windows reboot trick. That’s it for
Windows. Viewing http://localhost/
in Internet Explorer, under Windows, should now be using the files
on your new FAT32 partition. Create a new html document and place
in your new shared document-root directory and try it !
What
about Linux and Apache?
Next,
install Linux on your remaining hard drives free-space. A Linux
distribution such as Mandriva will have your web-server and all
web-services such as PHP and MySQL running on the very first boot if
you select those options during the initial installation. Another
thing that Mandriva will do for you during installation is locate,
and mount, existing Windows partitions for you automatically,
typically in a directory like
/mnt/win_c
for the “C:” drive. If you installed Windows after
Linux, or if you’re using another distribution that doesn’t
automatically mount windows partitions for you, then you will have to
tackle this part on your own. Typically though, an entry similar to
this in your fstab should get it mounted for you assuming
the /mnt/win_d directory already exists AND your “D:”
drive is hda2 as mine is:
/dev/hda2
/mnt/win_d vfat umask=0,iocharset=iso8859-1,codepage=850 0 0
What’s
next?
Linux
uses the Apache web-server. The default document-root directory in a
Mandriva installation is /var/www/html. Next, a symbolic link is
created inside the /var/www/html directory that points to the new
document-root directory on the FAT32 partition, which is mounted in
/mnt/win_d. To create the symbolic link, open a terminal, do an “su”
to root, change working directory to /var/www/html, then create the
link like this:
ln
-s /mnt/win_d/Inetpub/wwwroot wwwroot
It
may, or may not, be necessary to change the permissions on the link.
To grant full permissions to all users:
chmod
777 wwwroot
How
will Apache web-server know about the document-root directory change?
You
will have to make a small change in the Apache configuration file,
and restart the web-services for the change to become effective in
Linux. Locate your Apache configuration file, typically
/etc/httpd/conf/httpd.conf (or httpd2.conf if using Apache 2.x).
Find the entry for the Document root and add the symbolic link name
to it as you would if it were a directory.
It
should look like this before making any changes:
DocumentRoot
/var/www/html
And
like this after your change is made:
DocumentRoot
/var/www/html/wwwroot
Is
that it?!
Just
about. You need to restart Apache. From a terminal prompt, as root:
service
httpd restart
or
you can just reboot if you’re used to Windows. You are now using the
same web-server document-root directory whether in Windows or Linux.
What
else should I consider before tackling this?
Other
services such as PHP, Perl, MySQL can be made to work with this
configuration with a little massaging, which is beyond the scope of
this document. Your computer name (hostname) should be the same and
your IP address should be the same (if networked) under both
operating systems. Other than that, you’re ready to go!
