LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-19-2012, 06:48 AM   #1
ludo33
Member
 
Registered: Feb 2009
Posts: 119

Rep: Reputation: 16
Configure default server as Virtual host


Hello,

I know it's been asked before (and answered for httpd.conf) trouble is my apache config is all in apache2.conf (must be a distro thing)

I want to know how to make the default server a virtual host, got a couple of vhosts setup and they resolve back to the default, so I am guessing I got to add something to my apache2.conf (clean install apt-get apache2) to make it a virtual server. Or, which is greatly more than possible, completely wrong?

Thanks guys!
 
Old 10-19-2012, 06:52 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
The name of the config file doesn't matter in the slightest, just make the equivalent changes in apache2.conf. I don't really understand what you mean to make it virtual? you can take the default DocumentRoot and such and put them inside a <VirtualHost *:80> tag, there's nothing really difficult to it.
 
Old 10-19-2012, 06:56 AM   #3
ludo33
Member
 
Registered: Feb 2009
Posts: 119

Original Poster
Rep: Reputation: 16
Hello and thanks for reply,

"Nothing to it" you say. My apache2.conf is a horrendously long file, and you're saying just wrap the lot up <VirtualHost *:80> </VirtualHost> tags?

Sorry, but I am a bit green at this sort of stuff.

Thanks again.
 
Old 10-19-2012, 07:11 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
OK, so read a standard virtualhost doc and just slot in the relevant settings.

A simple definition looks like this:

Code:
NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin ramesh@thegeekstuff.com
    DocumentRoot "/usr/local/apache2/docs/thegeekstuff"
    ServerName thegeekstuff.com
    ServerAlias www.thegeekstuff.com
    ErrorLog "logs/thegeekstuff/error_log"
    CustomLog "logs/thegeekstuff/access_log" common
</VirtualHost>
so drop in the equivalents for your existing site, stick it at the end of the file and that's it really.
 
Old 10-19-2012, 07:35 AM   #5
ludo33
Member
 
Registered: Feb 2009
Posts: 119

Original Poster
Rep: Reputation: 16
Ok tried that, situation the same i.e. vhosts point back to default.

I get an error in the apache log:

(EAI 2)Name or service not known: Could not resolve host name *.80 -- ignoring!
 
Old 10-19-2012, 07:39 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
comapre "*.80" to "*:80"
 
Old 10-19-2012, 07:52 AM   #7
ludo33
Member
 
Registered: Feb 2009
Posts: 119

Original Poster
Rep: Reputation: 16
Doh! Sorry, just getting frustrated......happens to us all I guess

Ok so error gone, got a new one though "NameVirtualHost *:80 has no VirtualHosts" Something somewhere is wrong and I don't know where to look for it. Is there another file I gotta change?
 
Old 10-19-2012, 07:56 AM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
that delcaration just needs to match up with the reference in <VirtualHost *:80> line, so I presume you've changed one of them?
 
Old 10-19-2012, 08:08 AM   #9
ludo33
Member
 
Registered: Feb 2009
Posts: 119

Original Poster
Rep: Reputation: 16
Smile

This is what I put in, just as you suggested. Frustration is a terrible thing

Code:
NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin ramesh@thegeekstuff.com
    DocumentRoot "/usr/local/apache2/docs/thegeekstuff"
    ServerName thegeekstuff.com
    ServerAlias www.thegeekstuff.com
    ErrorLog "logs/thegeekstuff/error_log"
    CustomLog "logs/thegeekstuff/access_log" common
</VirtualHost>
 
Old 10-19-2012, 08:10 AM   #10
ludo33
Member
 
Registered: Feb 2009
Posts: 119

Original Poster
Rep: Reputation: 16
Oh and I changed you links to match what I have got here
 
Old 10-19-2012, 08:12 AM   #11
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Maybe the documentroot doesn't exist or some such. Check the end of /var/log/httpd/error_log after loading, or run a "apachectl configtest" or "httpd -t" to verbosely check the config file
 
Old 10-19-2012, 08:18 AM   #12
ludo33
Member
 
Registered: Feb 2009
Posts: 119

Original Poster
Rep: Reputation: 16
Sorry ,,,,,, once again!

Nothing in the apache log!

apachectl configtest returns:

Code:
[warn] NameVirtualHost *:80 has no VirtualHosts
And httpd -t returns:

Code:
-bash: httpd: command not found
 
Old 10-19-2012, 08:21 AM   #13
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
I really need to see the actual config here...
 
Old 10-19-2012, 08:23 AM   #14
ludo33
Member
 
Registered: Feb 2009
Posts: 119

Original Poster
Rep: Reputation: 16
Gimme a clue? What config do you need to see?
 
Old 10-19-2012, 08:28 AM   #15
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
the config you added!
 
  


Reply



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
apache default virtual host rs232 Linux - Software 5 12-23-2009 08:57 PM
[SOLVED] Apache2 - virtual host defaulting to default host slimjim Linux - Server 1 10-31-2009 01:47 AM
Getting nuts. Can't receive e-mail and can't configure a dns server (virtual host) stormrider_may Linux - Networking 22 02-14-2006 05:44 AM
IP and Domain resolving to default virtual host DropHit Linux - Newbie 4 11-19-2005 02:42 PM
RH9 Apache Virtual Host Default Document jswilson Linux - Newbie 2 01-29-2004 09:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:59 AM.

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