Apache Virtual Hosts problem

I have a dns server set up for http://dirtywerm.com, what I want to do now is set up apache virtual hosting.

Everytime I try to enable the virtual hosting everything but localhost stops working.

I'm not sure if the problem is to do with my dns server or if i'm doing something wrong with apache.

So what I'm trying to do is make sure that my domain name works both locally and externally using virtual hosts.
dirtywermAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dirtywermAuthor Commented:
Also I am using apache 2

When I try to enable virtual hosting I uncomment the following line:
#Include conf/vhosts/vhosts.conf


Here is vhosts.conf:

NameVirtualHost *
<VirtualHost *>
ServerName dirtywerm.com
DocumentRoot /var/www/dirtywerm/htdocs
</VirtualHost>

/var/www/dirtywerm is just a copy of /var/www/localhost


0
jlevieCommented:
It would most helpful to know what version of Apache you are using.

For a 2.x version of Apache you'd configure virtual hosts by having something along the lines of:

NameVirtualHost *:80

<VirtualHost *:80>
  ServerName "www.dirtywerm.com"
  ServerAlias "dirtywerm.com"
  ServerAdmin "webmaster@dirtywerm.com"
  DocumentRoot "/home/webs/www.dirtywerm.com/htdocs"
  <Directory />
    AllowOverride AuthConfig
    Options FollowSymLinks Multiviews
    Order allow,deny
    Allow from all
  </Directory>
   ScriptAlias /cgi-bin/ "/home/webs/www.dirtywerm.com/cgi-bin/"
  <Directory "/home/webs/www.dirtywerm.com/cgi-bin">
    AllowOverride AuthConfig
    Options ExecCGI
    Order allow,deny
    Allow from all
  </Directory>
  CustomLog "/home/webs/www.dirtywerm.com/logs/access_log" combined
  ErrorLog "/home/webs/www.dirtywerm.com/logs/error_log"
</VirtualHost>

with httpd.conf (with the paths adjusted for local conditions). To have the site work internally and externally you need to ensure that the DNS views for each properly resolve the anme to the appropriate IP. That means that from inside you get an inside IP for the name and from outside you get an outside IP.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dirtywermAuthor Commented:
Ok, the virtual host is working now but how do I set up bind 9 to working differently internally and externally?
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

dirtywermAuthor Commented:
Here is my current named.conf

options {
        directory "/var/bind";

        listen-on-v6 { none; };
        listen-on { 127.0.0.1; 192.168.0.100; };

        pid-file "/var/run/named/named.pid";
};

zone "." IN {
        type hint;
        file "named.ca";
};

zone "localhost" IN {
        type master;
        file "pri/localhost.zone";
        allow-update { none; };
        notify no;
};

zone "127.in-addr.arpa" IN {
        type master;
        file "pri/127.zone";
        allow-update { none; };
        notify no;
};

zone "dirtywerm.com" IN {
        type master;
        file "pri/dirtywerm.zone";
        allow-update { none; };
        notify no;
};

zone "b-train.com" IN {
        type master;
        file "pri/btrain.zone";
        allow-update { none; };
        notify no;
};

0
jlevieCommented:
What version of Bind are you using? And is this copy of Bind the only name server for the domain?
0
dirtywermAuthor Commented:
For now this is the only name server. I was making sure my set up was right. I am using bind 9.
0
dirtywermAuthor Commented:
Would this be the correct way to set up the views?

options {
        directory "/var/bind";

        listen-on-v6 { none; };
        listen-on { 127.0.0.1; 192.168.0.100; };

        pid-file "/var/run/named/named.pid";
};

view "internal" {

        match-clients { localnets; };
        recursion yes;

        zone "." IN {
                type hint;
                file "named.ca";
        };

        zone "localhost" IN {
                type master;
                file "pri/localhost.zone";
                allow-update { none; };
                notify no;
        };

        zone "127.in-addr.arpa" IN {
                type master;
                file "pri/127.zone";
                allow-update { none; };
                notify no;
        };

        zone "dirtywerm.com" IN {
                type master;
                file "pri/dirtywerm.internal";
                allow-update { none; };
                notify no;
        };

        zone "b-train.com" IN {
                type master;
                file "pri/btrain.internal";
                allow-update { none; };
                notify no;
        };
};

view "external" {
        match-clients { any; };
        recursion no;

        zone "dirtywerm.com" IN {
                type master;
                file "pri/dirtywerm.external";
                allow-update { none; };
                notify no;
        };

        zone "b-train.com" IN {
                type master;
                file "pri/btrain.external";
                allow-update { none; };
                notify no;
        };
};

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.