X-AMP Based Web Sites

I’ve been developing web sites since 1996 and was the architect of Paul Mueller’s plate heat exchanger design program brought online in 2000. So far the web sites I’ve built have used Microsoft’s Internet Information Server (IIS).

I’m working on some new web sites running on Linux and using the Apache web server. In particular they are using Apache, MySql database and PHP which refer to using the “AMP” designation. There’s WAMP for a Windows version, LAMP versions for Linux applications, and XAMPP. I ended up using the XAMPP project from ApacheFriends as described in this Ubuntu Forums thread. I went to the XAMPP area on SourceForge to download the latest version. This placed the LAMP applications in my /opt/lampp directory.

Virtual Domains

I am creating multiple web sites and want a separate development environment on my laptop for each web domain. Next I edit the /etc/hosts file to define local ip addresses for each of my web sites. Localhost is already defined at 127.0.0.1, then I’m adding the name of my computer, gtdev1, so it points to 127.0.0.1 also. I will be working on the following web sites: GeometricTechnology.com, MyStudySource.com, DIYRoboticsLab.com, UnBiasedSewing.com, LabyWiinth.com, and MakeKC.com.

I’m hard coding IP locations mapped to my computer. If I were to use the “.com” designation it would hijack any attempts to go to the live Internet web sites from my computer. To prevent confusion I’m changing the names slightly using a “.dom” designation instead. I use .dom to represent domain. I edit the /etc/hosts file adding the lines mapped to IP addresses 127.0.0.1.

127.0.0.1    localhost
127.0.1.1    gtdev1
127.0.1.1    GeometricTechnology.dom
127.0.1.1    MyStudySource.dom
127.0.1.1    DIYRoboticsLab.dom
127.0.1.1    UnBiasedSewing.dom
127.0.1.1    labywiinth.dom
127.0.1.1    MakeKC.dom

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Now, for instance, when I type http://MyStudySource.dom into the web browser it serves up the default page from my laptop. This lets me work with each unique local web domain. The next thing I need to do is provide a separate folder for each domain instead of the default localhost location.

I created a folder called under /opt/lampp/htdocs/ called www with folders inside for each of the domains, for instance /opt/lampp/htdocs/www/geometrictechnology.dom.

Next I edit the /opt/lampp/etc/extra/httpd-vhosts.conf file to identify folders for each of the local domains.

#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn’t need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/&gt;
# for further details before you try to setup virtual hosts.
#
# You may use the command line option ‘-S’ to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#

<VirtualHost *:80>
DocumentRoot htdocs/xampp
ServerName localhost
ErrorLog logs/localhost-error_log
CustomLog logs/localhost-access_log common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@geometrictechnology.dom
DocumentRoot htdocs/www/geometrictechnology.dom
ServerName geometrictechnology.dom
ErrorLog logs/geometrictechnology.dom-error_log
CustomLog logs/geometrictechnology.dom-access_log common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@mystudysource.dom
DocumentRoot htdocs/www/mystudysource.dom
ServerName mystudysource.dom
ErrorLog logs/mystudysource.dom-error_log
CustomLog logs/mystudysource.dom-access_log common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@diyroboticslab.dom
DocumentRoot htdocs/www/diyroboticslab.dom
ServerName diyroboticslab.dom
ErrorLog logs/diyroboticslab.dom-error_log
CustomLog logs/diyroboticslab.dom-access_log common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@labywiinth.dom
DocumentRoot htdocs/www/labywiinth.dom
ServerName labywiinth.dom
ErrorLog logs/labywiinth.dom-error_log
CustomLog logs/labywiinth.dom-access_log common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@unbiasedsewing.dom
DocumentRoot htdocs/www/unbiasedsewing.dom
ServerName unbiasedsewing.dom
ErrorLog logs/unbiasedsewing.dom-error_log
CustomLog logs/unbiasedsewing.dom-access_log common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@makekc.dom
DocumentRoot htdocs/www/makekc.dom
ServerName makekc.dom
ErrorLog logs/makekc.dom-error_log
CustomLog logs/makekc.dom-access_log common
</VirtualHost>

To enable the http-vhosts.config settings check the httpd.config again to verify the following Include statements are un commented.

# Virtual hosts
Include etc/extra/httpd-vhosts.conf

# XAMPP
Include etc/extra/httpd-xampp.conf

# Various default settings
Include etc/extra/httpd-default.conf

After making these changes stop and restart Apache so it will find the changes.

Under the /opt/lampp/htdocs/www/ folder I have a folder for each of the domains I want to use. Inside each of the domain folders I have a file named index.html. This file simply has the paragraph tag

<p> Hello World </p>

Actually, I customized the message in each to know which folder the web page was served from. Now when I type my local domain name into a browser is serves up my Hello World or equivalent example from each domain’s directory.

About SomeoneKnows

(c) 2010 Vince Thompson
Advertisements

One Response

  1. […] to get web server functionality that I’ll use to create web sites offline as I described in X-AMPP Based Web Sites. Since then I’ve downloaded Drupal 6 from the Drupal download site and prepared to install in […]

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: