LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-28-2006, 01:53 PM   #1
Markness
Member
 
Registered: Apr 2005
Location: Albany, NY
Distribution: Fedora Core 6
Posts: 85

Rep: Reputation: 15
Virtual Hosting Setup.


Ugh,

I don't understand how to implement this.

From what I understand, I dont want IP based hosting. I want name based. I dont have to worry about clients information and security...yet.

I went into my httpd.conf file to try and set it up myself, but its not working. Can anyone (*coughtomcough*) try and help me set up virtual hosting with my apache server.
 
Old 04-28-2006, 02:10 PM   #2
puntjuh
Member
 
Registered: Apr 2006
Location: holland
Distribution: Gentoo / debian / suse / mint
Posts: 558

Rep: Reputation: 42
have you readen the description at the apache website:

http://httpd.apache.org/docs/2.2/vhosts/name-based.html

I found it of great use when i first started apache.
 
Old 04-28-2006, 02:18 PM   #3
Markness
Member
 
Registered: Apr 2005
Location: Albany, NY
Distribution: Fedora Core 6
Posts: 85

Original Poster
Rep: Reputation: 15
yea I have
 
Old 04-28-2006, 03:42 PM   #4
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
Can you post what you have so far? If the examples at Apache aren't helping, then examples from us probably won't either.
 
Old 04-28-2006, 03:58 PM   #5
puntjuh
Member
 
Registered: Apr 2006
Location: holland
Distribution: Gentoo / debian / suse / mint
Posts: 558

Rep: Reputation: 42
I agree with gilead, post you're part of the Virtual host setting. We'll try "fixing" it for you. And if needed i'll post my Vhost section that i used to use for my server.
 
Old 04-28-2006, 04:38 PM   #6
Markness
Member
 
Registered: Apr 2005
Location: Albany, NY
Distribution: Fedora Core 6
Posts: 85

Original Poster
Rep: Reputation: 15
the problem is I dont know where to put it in my httpd.conf

thats kinda what I wanted examples of so I could see what needs and doesnt need to be edited.
 
Old 04-28-2006, 07:28 PM   #7
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
I'm assuming Apache 2.0.x for this... In your httpd.conf file right at the end should be something like the following:
Code:
NameVirtualHost *:80
# This section stops people scanning your web server by IP address
# It acts as a default host so that content is only served for your domains
<VirtualHost *:80>
  ServerName default.only
  RewriteEngine on
  RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
  RewriteRule .* - [F]
  <Location />
    Order allow,deny
    Deny from all
  </Location>
</VirtualHost>
# A virtual host
<VirtualHost *:80>
  DocumentRoot /var/www/html
  ServerName www.adomain.com
  <Directory "/var/www/html">
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>
I'm also assuming that you have domains registered and delegated to a DNS provider so that they resolve to your IP address.
 
Old 05-02-2006, 10:05 PM   #8
tomdkat
Member
 
Registered: May 2003
Location: S.F. Bay Area
Distribution: Ubuntu 9.04 AMD64
Posts: 595

Rep: Reputation: 30
Yep, my virtual hosting setup is similar to gilead's.

Mark, what do you not understand?

Instead of using this syntax:
Code:
<VirtualHost *:80>
I use this syntax:
Code:
<VirtualHost [IP address]>
I also have "NameVirtualHost [IP address]" specified and the rest just works.

So, after you've posted what you've done thus far we can go from there. You don't need to post the entire httpd.conf, but the virtual host you've defined and any other options you've set with "virtualhost" in the name.

Peace...
 
Old 05-03-2006, 04:04 AM   #9
Markness
Member
 
Registered: Apr 2005
Location: Albany, NY
Distribution: Fedora Core 6
Posts: 85

Original Poster
Rep: Reputation: 15
Where do I find out what the ip addresses are?
 
Old 05-03-2006, 10:39 AM   #10
tomdkat
Member
 
Registered: May 2003
Location: S.F. Bay Area
Distribution: Ubuntu 9.04 AMD64
Posts: 595

Rep: Reputation: 30
Quote:
Originally Posted by Markness
Where do I find out what the ip addresses are?
Ok, first tell us what you're wanting to do outside of the high-level "host some websites".

Will these websites all have the same IP address or will they have unique IPs? Or will there be a mixture of IP addresses used?

Will the server they will be hosted on be multi-homed (with either multiple physical or virtual network interfaces)?

If the server will have just one network interface (i.e. one NIC with one IP address), the IP address of the server is the only IP address you will use, both to configure the virtual hosts (unless you use the "*:80" notation above) AND to setup the DNS settings for each website you intend to host.

Here's how it would then work:

I point my browser at markness.com and the DNS comes back with aaa.bbb.ccc.ddd. Then my browser contacts machine aaa.bbb.ccc.ddd on port 80 and your Apache server handles the incoming request. It knows the incoming request is for markness.com and uses the virtual host settings for markness.com to serve up that website.

Later on, I point my browser at somedomain.net and the DNS comes back with aaa.bbb.ccc.ddd, which is the SAME IP returned for markness.com. Then my browser contacts machine aaa.bbb.ccc.ddd on port 80 and your Apache server handles the incoming request. It knows the incoming request is for somedomain.net and uses the virtual host settings for somedomain.net to serve up that website.

So, before we proceed with any virtual hosting setup, you need to let us know what you are wanting to do and what your game plan is. Only then can we provide the best information for you.

Peace...
 
Old 05-03-2006, 11:02 PM   #11
Markness
Member
 
Registered: Apr 2005
Location: Albany, NY
Distribution: Fedora Core 6
Posts: 85

Original Poster
Rep: Reputation: 15
Q. Will these websites all have the same IP address or will they have unique IPs? Or will there be a mixture of IP addresses used?

A. I'm assuming because they're coming from my pc with one nic card, that they're all going to use the same ip address.


Q. Will the server they will be hosted on be multi-homed (with either multiple physical or virtual network interfaces)?

A. Not quite sure what you mean by multi-homed. The computer sits in my room on my desk, connected to the internet. There are no other computers on that internet line through routers or anything like that, if thats what you're asking.

All in all, I'm going to have several different domains pointing to my server.

Sorry for the lack of quicker replies. I'm currently registering for classes and dealing with Army BS as usual.
 
Old 05-04-2006, 02:11 AM   #12
tomdkat
Member
 
Registered: May 2003
Location: S.F. Bay Area
Distribution: Ubuntu 9.04 AMD64
Posts: 595

Rep: Reputation: 30
Quote:
Originally Posted by Markness
Q. Will these websites all have the same IP address or will they have unique IPs? Or will there be a mixture of IP addresses used?

A. I'm assuming because they're coming from my pc with one nic card, that they're all going to use the same ip address.
No room for assumption here as this is something you really need to know. It's possible to have virtual network interfaces such that a single machine will respond to requests for different and multiple IP addresses. What kind of Internet connection will you be using for this?

Quote:
Q. Will the server they will be hosted on be multi-homed (with either multiple physical or virtual network interfaces)?

A. Not quite sure what you mean by multi-homed. The computer sits in my room on my desk, connected to the internet. There are no other computers on that internet line through routers or anything like that, if thats what you're asking.
Nope, I'm asking if the computer has more than one network interface, either physical or virtual. A physical network interface is a network interface card (NIC), like a 3COM card or whatever brand you use. A virtual network interface is like a physical network interface that doesn't physically exist. The NIC you do have installed would then respond to as many IP address requests it was configured to respond to.

Quote:
All in all, I'm going to have several different domains pointing to my server.
Then assuming they will all have the same IP address, the virtual hosting should be rather simple. If the sites won't have any special requirements, like PHP or stuff like that, mass virtual hosting would be even easier for you.

Here is the template I use for each virtual host I define on my server:
Code:
# Domain: xxx
<VirtualHost aa.bb.cc.dd>
       DocumentRoot    "/mnt/websites/xxx"
       ErrorLog "| /usr/local/cronolog/sbin/cronolog /usr/local/apache/logs/xxxx/error_log.%Y.%m.%d"
       CustomLog "| /usr/local/cronolog/sbin/cronolog /usr/local/apache/logs/xxx/access_log.%Y.%m.%d" combined
       ScriptAlias /cgi-bin/ "/mnt/websites/xxx/cgi-bin/"
       ScriptAlias /website-stats/ "/mnt/websites/xxx/cgi-bin/website-stats/"
       <Directory "/mnt/websites/xxx/cgi-bin/website-stats">
         AllowOverride         AuthConfig
         Options None
       </Directory>
        <Location /cgi-bin/>
                SetHandler perl-script
                PerlResponseHandler ModPerl::Registry
                PerlOptions +ParseHeaders
                Options +ExecCGI
        </Location>

        <Location /website-stats/>
                SetHandler perl-script
                PerlResponseHandler ModPerl::Registry
                PerlOptions +ParseHeaders
                Options +ExecCGI
        </Location>
       ServerName      xxx
       ServerAlias     xxx
</VirtualHost>
You won't need all of those directives and you might need different ones depending on the site(s) you'll be hosting. The ServerName and ServerAlias directives control the fully qualified domain names (FQDNs) for which the virtual host is defined. The httpd.conf file should have an example of a basic virtual host configuration in it, near the bottom of the file.

Peace...
 
Old 05-04-2006, 02:20 AM   #13
Markness
Member
 
Registered: Apr 2005
Location: Albany, NY
Distribution: Fedora Core 6
Posts: 85

Original Poster
Rep: Reputation: 15
Quote:
No room for assumption here as this is something you really need to know. It's possible to have virtual network interfaces such that a single machine will respond to requests for different and multiple IP addresses. What kind of Internet connection will you be using for this?
I'll be using cable internet.

I will be using PHP on the sites. Would that modify the virtual host config you just posted at all?

Quote:
# Domain: www.mydomain.org
<VirtualHost this is where I put my computers IP address? How do I find that?>
DocumentRoot "/mnt/websites/xxx" <- var/www/html I'm guessing from our previous apache installation?
ErrorLog "| /usr/local/cronolog/sbin/cronolog /usr/local/apache/logs/xxxx/error_log.%Y.%m.%d"
CustomLog "| /usr/local/cronolog/sbin/cronolog /usr/local/apache/logs/xxx/access_log.%Y.%m.%d" combined
ScriptAlias /cgi-bin/ "/mnt/websites/xxx/cgi-bin/"
ScriptAlias /website-stats/ "/mnt/websites/xxx/cgi-bin/website-stats/"
<Directory "/mnt/websites/xxx/cgi-bin/website-stats"> <- how is directory different from document root? Isnt root where all the main files are stored?
AllowOverride AuthConfig
Options None
</Directory>
<Location /cgi-bin/>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
Options +ExecCGI
</Location>

<Location /website-stats/> <-- is this where my PHP options would go?
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
Options +ExecCGI
</Location>
ServerName xxx
ServerAlias xxx
</VirtualHost>
Also, Tom if you get a chance check out my thread on DVD Shrink in WINE, Trouble locating drives! in the software section of the forums. I could use your help there as well.

Last edited by Markness; 05-04-2006 at 02:22 AM.
 
Old 05-04-2006, 02:36 AM   #14
tomdkat
Member
 
Registered: May 2003
Location: S.F. Bay Area
Distribution: Ubuntu 9.04 AMD64
Posts: 595

Rep: Reputation: 30
Quote:
Originally Posted by Markness
I'll be using cable internet.

I will be using PHP on the sites. Would that modify the virtual host config you just posted at all?
Actually, it could. Some PHP apps want different PHP settings than others. It's funny you mention PHP since I took out the PHP settings I use in my virtual host settings to keep things simple.

Here is what the full-blown version looks like:
Code:
# Domain: xxx
<VirtualHost aa.bb.cc.dd>
        php_value include_path ".:../../:/usr/local/php/lib/php"
        php_admin_value  safe_mode 0
        php_admin_value  safe_mode_allowed_env_vars LC_,LANG
        php_flag  magic_quotes_gpc off
        php_flag  register_globals on
#
       DocumentRoot    "/mnt/websites/xxx"
       ErrorLog "| /usr/local/cronolog/sbin/cronolog /usr/local/apache/logs/xxxx/error_log.%Y.%m.%d"
       CustomLog "| /usr/local/cronolog/sbin/cronolog /usr/local/apache/logs/xxx/access_log.%Y.%m.%d" combined
       ScriptAlias /cgi-bin/ "/mnt/websites/xxx/cgi-bin/"
       ScriptAlias /website-stats/ "/mnt/websites/xxx/cgi-bin/website-stats/"
       <Directory "/mnt/websites/xxx/cgi-bin/website-stats">
         AllowOverride         AuthConfig
         Options None
       </Directory>
        <Location /cgi-bin/>
                SetHandler perl-script
                PerlResponseHandler ModPerl::Registry
                PerlOptions +ParseHeaders
                Options +ExecCGI
        </Location>

        <Location /website-stats/>
                SetHandler perl-script
                PerlResponseHandler ModPerl::Registry
                PerlOptions +ParseHeaders
                Options +ExecCGI
        </Location>
       ServerName      xxx
       ServerAlias     xxx
</VirtualHost>
That gives me a working PHP4 and mod_perl 2.0.2 Apache 2.0.55 server. The PHP settings you would actually use would depend on your PHP environment. Do not simply use my settings to get something up and running. Print out my settings and go over the Apache doc to see what the directives mean, then craft your own virtual host settings and post them here if you want them peer reviewed.

Quote:
Also, Tom if you get a chance check out my thread on DVD Shrink in WINE, Trouble locating drives!
Sorry, I don't support apps like DVD Shrink.

Peace...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Virtual Hosting? nr5 Linux - Software 10 06-03-2005 01:30 PM
virtual hosting setenv02 Linux - General 6 05-05-2005 02:35 AM
Virtual hosting... id10t Linux - Networking 4 02-02-2004 05:43 PM
Virtual Hosting - what does it actually do? gevers1 Linux - General 3 02-01-2004 09:28 AM
Virtual Hosting joseph Linux - General 3 08-20-2003 04:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration