LinuxQuestions.org
Review your favorite Linux distribution.
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-05-2009, 04:57 AM   #1
dlugasx
Member
 
Registered: Dec 2008
Location: Germany/Poland
Distribution: CentOS / Debian / Solaris / RedHat
Posts: 266

Rep: Reputation: 19
Apache - problem with virtual host


Hi all,


on my server I have connected domain:

www.my-first-domain.com which is installed in /var/www/first

For that domain I have installed virtual host.


Quote:
<VirtualHost *>
ServerName www.my-first-domain.com
ErrorLog /var/log/apache2/my-first-domain.com-error.log
TransferLog /var/log/apache2/my-first-domain.com-access.log

DocumentRoot /var/www/first/
<Directory /var/www/first/>
Options Indexes FollowSymLinks MultiViews
DirectoryIndex index.php index.html
AllowOverride None
Order allow,deny
allow from all
</Directory>

</VirtualHost>



I dont know why, when I will put address

my-first-domain.com instead of www.my-first-domain.com

server redirect that domain to folder /var/www/.


Does anybody knows whats going on ?
 
Old 10-05-2009, 05:08 AM   #2
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Did you restart the apache?

Give us the output of
Code:
apachectl -S
this will print all virtual domains apache finds in its configuration
If you go with apache2 use

Code:
apache2ctl -S
 
Old 10-05-2009, 05:09 AM   #3
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
double post

Last edited by zhjim; 10-05-2009 at 05:10 AM. Reason: double post
 
Old 10-05-2009, 05:21 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Add
Code:
ServerAlias my-first-domain.com
after ServerName and restart apache.

Regards
 
Old 10-05-2009, 05:28 AM   #5
dlugasx
Member
 
Registered: Dec 2008
Location: Germany/Poland
Distribution: CentOS / Debian / Solaris / RedHat
Posts: 266

Original Poster
Rep: Reputation: 19
Thumbs up

Quote:
Originally Posted by bathory View Post
Add
Code:
ServerAlias my-first-domain.com
after ServerName and restart apache.

Regards
Big beer for that man Thanks, I forgot about alias .
 
Old 10-05-2009, 05:41 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Thx for the beer. Cheers!!!

Btw, you can mark your thread as solved.
 
Old 10-05-2009, 06:36 AM   #7
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Damn I want one two

Just for my peace of mind.
Do you really need a ServerAlias to get it working? Specially when you have a ServerName allready set?
As far I got it you would need a ServerAlias directive for something like this.
Code:
ServerName my-domain.com
ServerAlias www.my-domain.com
 
Old 10-05-2009, 06:58 AM   #8
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
@zhjim

You need ServerAlias whenever you want your vhost to listen to alternative names regardless if the ServerName uses the fqdn, or just the domain name.

Regards
 
Old 10-05-2009, 09:01 AM   #9
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
Originally Posted by bathory View Post
@zhjim

You need ServerAlias whenever you want your vhost to listen to alternative names regardless if the ServerName uses the fqdn, or just the domain name.

Regards
Thanks for the explanation just like I had it in my mind
 
  


Reply

Tags
www



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 2.2.3 Virtual Host Problem kitek Linux - Networking 1 01-09-2008 05:35 PM
Apache virtual host problem. dave`2005 Linux - Software 2 05-26-2006 09:11 PM
Apache Virtual Host Problem eckertc1 Linux - Newbie 11 03-23-2005 03:31 PM
Apache Virtual Host problem Seventh Linux - Software 2 03-19-2005 06:33 PM
Apache virtual host problem Adrohak Linux - Software 3 07-18-2004 04:17 PM

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

All times are GMT -5. The time now is 12:52 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