Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Question about Apache and virtual hosts on a local development server...???

Posted on 2009-05-15
3
Medium Priority
?
321 Views
Last Modified: 2013-12-16
I´ve got Ubuntu 9 installed in a VM with lamp + phpmyadmin installed and working great.  I´d like to figure out how to configure virtual hosts now so I can setup my clients with their own testing servers from this.

What I´m reading seems pretty straight forward except I´m confused about how to browse different sites locally.  For example, I´ve included my /etc/apache2/available-sites/default file as it is now.  I left the default settings and then just added a new virtual host for a new web site.

So the way I understand it now is that I´d update DNS for beta-sandbox.angelleye.com to point to this server now and because of the virtual host config it would correctly point it to /home/angelleye/www.  

What about local browsing, though?  I´m hitting my server using 192.168.1.136.  beta-sandbox.angelleye.com will mean nothing to the other computers on my network.  Is there some way I add that to my local machines DNS only??

I´ve got Windows and Mac machines on this network that will need to reach this test server and call up each site accordingly.  Any information on how I can do this would be greatly appreciated.  Thanks!


<VirtualHost *:80>
	ServerAdmin webmaster@localhost
 
	DocumentRoot /var/www
	<Directory />
		Options FollowSymLinks
		AllowOverride None
	</Directory>
	<Directory /var/www/>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride None
		Order allow,deny
		allow from all
	</Directory>
 
	ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
	<Directory "/usr/lib/cgi-bin">
		AllowOverride None
		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
		Order allow,deny
		Allow from all
	</Directory>
 
	ErrorLog /var/log/apache2/error.log
 
	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn
 
	CustomLog /var/log/apache2/access.log combined
 
    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
 
</VirtualHost>
 
<VirtualHost *:80>
	ServerAdmin webmaster@localhost
 
	DocumentRoot	/home/angelley/www
	ServerName	beta-sandbox.angelleye.com
 
	<Directory />
		Options FollowSymLinks
		AllowOverride None
	</Directory>
	<Directory /home/angelley/www/>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride None
		Order allow,deny
		allow from all
	</Directory>
 
	ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
	<Directory "/usr/lib/cgi-bin">
		AllowOverride None
		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
		Order allow,deny
		Allow from all
	</Directory>
 
	ErrorLog /var/log/apache2/error.log
 
	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn
 
	CustomLog /var/log/apache2/access.log combined
 
</VirtualHost>

Open in new window

0
Comment
Question by:Andrew Angell
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 30

Expert Comment

by:Kerem ERSOY
ID: 24393289
Hi,

Apache works this way:

As an example say you have 2 domains that you want to have websites such as:
 
www.domain.com
w3.anotherdomain.com

- You just edit your DNS sones and add records like this:

domain.com DNS zone file:

www     IN    A    x.x.x.x

danotherdomain.com DNS zone file:

w3         IN     A  x.x.x.x

So that bothe www.domain.com and w3.domain.com will point to your Apache server's IP address.

Then you'll have your Apache configuration and you'll tell your apache that
- You'll have 2 virtual servers called:

www.doamian.com and w3.danotherdomain.com.
- You'll tell apache wihc folder contains website files for each of them

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot    /home/angelley/www
        ServerName      www.domain.com
 
        <Directory /home/angelley/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
 
        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>
 
        ErrorLog /var/log/apache2/www-domain-com-error.log
 
        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
 
        CustomLog /var/log/apache2/www-domain-com-access.log combined
 
</VirtualHost>
 
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot    /home/angelley/w3
        ServerName      w3.anotherdomain.com
 
        <Directory /home/angelley/w3/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
 
        ScriptAlias /cgi-bin/ /usr/lib/w3/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>
 
        ErrorLog /var/log/apache2/w3-anotherdomain-com-error.log
 
        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
 
        CustomLog /var/log/apache2/w3-antoherdomain-com-access.log combined
 
</VirtualHost>

Open in new window

0
 
LVL 30

Expert Comment

by:Kerem ERSOY
ID: 24393306
You can omit /cgi-bin alias. If you do cgi-bin will point  to a subfolder called cgi-bin under the home directory.

You can omit <Directory ... Directives. then System defaults wiill kick in.

You'd like to give a special name denoting your site to the logfiles so that you can follow each viertualhost from their unique filenames.

There was a mistake in my example above  the directory optin was /usr/lib/cgi-bin instead of /usr/lib/w3/cgi-bin


The corrected snippet as follows:

        ScriptAlias /cgi-bin/ /usr/lib/w3/cgi-bin/
        <Directory "/usr/lib/w3/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

Open in new window

0
 
LVL 30

Accepted Solution

by:
Kerem ERSOY earned 2000 total points
ID: 24393353
> What about local browsing, though?  I´m hitting my server using 192.168.1.136.  
> beta-sandbox.angelleye.com will mean nothing to the other computers on my network.  Is there some
> way I add that to my local machines DNS only??

You can do 2 things:
- Either you can edit your /etc/hosts in linux or C:\WINDOWS\system32\drivers\etc
add your sites called:

191.168.1.136             beta-sandbox.angelleye.com

So that when you type http://beta-sandbox.angelleye.com you'll get your page.

Don't forget that Apache does virtualhosting  matching the original request hostpart with virtualserver names it is configured for not IP address basis. So if it can match the hostname part of the incoming request then it serves is from the configured directory.

Another option ais t1 setup an internal DNS so that you'll serve your pages from there.  
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question