LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 04-08-2010, 12:29 PM   #1
craig467
Member
 
Registered: Jun 2005
Location: Maine
Distribution: Red Hat 9
Posts: 65

Rep: Reputation: 15
Can not get name bassed Virtual Hosting working on RH9


I was told that I could create multiple websites on a single machine useing Virutual Hosts. I have RedHat Linux 9 running Apache/2.0.40. I want to make offline test sites to learn with and have read it is as simple as changing /etc/httpd/conf/httpd.conf file but I have not been able to make it work yet. I have read over the past 3 days of working on this that the default virtual host must contain the same DocumentName and ServerName as the global info above the Virtual Host Section in the httpd.conf file.

Above Virtual Host Section:
Code:
Listen 80
ServerName localhost:80
DocumentRoot "/var/www/html"
In the Virtual Host Section:
Code:
NameVirtualHost *:80

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost *:80>
    ServerName www.site1.tld
    ServerAlias site1.tld
    DocumentRoot /var/www/site1
</VirtualHost>
<VirtualHost *:80>
    ServerName www.site2.tld
    ServerAlias site2.tld
    DocumentRoot /var/www/site2
</VirtualHost>
After makeing these alterations, I issued "service httpd restart" to restart the server and get OK's returned when stopping and starting.

In the browser, I can type in localhost or http://localhost/ and get the index.html page in the /var/www/html directory. However, when I type http://site1.tld or http://www.site1.tld, I get a brower page stating: "Server not found".

What am I doing wrong? The permissions are 755 on the DocumentRoot for site1 and site2, there are index.html pages in each. Am I supposed to do something with the /etc/hosts file or something? I do not know what to do or what I am doing wrong.

Any thoughts or suggstions?
 
Old 04-08-2010, 12:38 PM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
You don't need the main site in a virtual host (unless you are using it) and of course you need to edit /etc/hosts for your browser to know where site1.tld and site2.tld are.

A proper virtual host could look like :

Code:
<VirtualHost *:80>

        ServerName www.domain.com
        ServerAlias domain.com
        ServerAdmin you@youremail.com
        DocumentRoot /var/www/site1/html
        RewriteEngine on

        <Directory /var/www/site1/html/>
                Allow from all
                AllowOverride All
                Order allow,deny
        </Directory>

        SetEnv SITE_ROOT /var/www/site1
        SetEnv SITE_HTMLROOT /var/www/site1/html

        <IfModule mod_php4.c>
                # need to set php on explicitly (PR 24077).
                # using php_flag so site can override.
                php_flag engine on
        </IfModule>
        <IfModule sapi_apache2.c>
                php_flag engine on
        </IfModule>

</VirtualHost>

Last edited by smoker; 04-08-2010 at 12:44 PM.
 
Old 04-08-2010, 01:32 PM   #3
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
You will also have a much easier time generally with everything you do in Linux if you pick a more modern distro. RedHat 9 is not supported any more and is 7 years old. Apache 2.0.40 is 8 years old and is very insecure. It is also a lot harder to configure than the 2.2.x branch which is the current version. A lot has changed in the past 7 years with regard to Linux. It is now much more mature than it was then. Heck, even Windows has improved in that time (I guess, I don't really use it). If you were going to set up a server today, would you use Windows 7 or Windows 2003 Server? That's the time period that Red Hat 9 came out.

HTH

Forrest
 
Old 04-08-2010, 02:47 PM   #4
craig467
Member
 
Registered: Jun 2005
Location: Maine
Distribution: Red Hat 9
Posts: 65

Original Poster
Rep: Reputation: 15
Thanks forest. Where I live, we only have dial-up and when someone gave me the RedHat Linux 9 Bible it came with its own cd's. I have very little knowledge of Linux and so I thought it would be interesting to poke around and learn a little. It is a slow learn for me since most time 14.4 to 28.8 is the best speed I can get from Dial-up. So, I do what I can. I imagine that sometime in the future I will update, but for the time right now, this is where I stand.
 
Old 04-08-2010, 02:58 PM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Look in a book store like Barnes & Nobles or Borders. They may carry a Linux magazine that includes a DVD. They may also have starter kit magazines. E.G. There is a Linux Identity magazine for Cent OS 5.4 out currently in my local B&N.
 
Old 04-08-2010, 03:07 PM   #6
craig467
Member
 
Registered: Jun 2005
Location: Maine
Distribution: Red Hat 9
Posts: 65

Original Poster
Rep: Reputation: 15
Smoker,

Thanks for the template for a virtual host. I will incorporate that into mine. As for the host file, I am really new to this and so I am pretty sure I do not have this right either. I am not really sure what that should look like or what I should enter in. Could you give me an idea of what an entry for site1 should be?

my current /etc/hosts file has 2 entries in it (one for this virtual host and one so I can connect to my other computer)
Code:
127.0.0.1       localhost.localdomain    localhost 
192.168.0.100   localhost.localdomain    linserv
what do I need to add to make the site1 and site2 show up in my browser? Sorry to be so inept, but this is so overwhelming to me at this point.

Thanks
 
Old 04-08-2010, 03:13 PM   #7
craig467
Member
 
Registered: Jun 2005
Location: Maine
Distribution: Red Hat 9
Posts: 65

Original Poster
Rep: Reputation: 15
Thanks jschiwal,

I will take a look. Is there some sort of distribution that I should be looking for? Apparently Red Hat is old - is there any out there that are easy enough for me to learn or are there some out there I should stay away from? So far I have made a poor choice and do not want to repeat getting an outdated one.

Thanks
 
Old 04-08-2010, 03:30 PM   #8
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
Your profile says you live in Maine. If this is true, check out The MainE Linux Users' Group. They may have resources you can use to get a more recent distro as well as advice.

HTH

Forrest
 
Old 04-08-2010, 07:25 PM   #9
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
The free version of Red Hat is Fedora. One of the magazines may have a fedora 12 disc. I saw one that has Cent OS which is based from source on the current RHEL commercial product from Red Hat.
 
Old 04-09-2010, 12:10 PM   #10
craig467
Member
 
Registered: Jun 2005
Location: Maine
Distribution: Red Hat 9
Posts: 65

Original Poster
Rep: Reputation: 15
Thanks forrestt and jschiwal I will look into both of those items.
 
  


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
Virtual Hosting dougreed Linux - Newbie 7 08-20-2009 11:59 AM
do I really need virtual hosting if only hosting one site kustomjs Linux - Server 8 05-22-2008 12:17 PM
ctrl-alt-F(1-6) not working in PCLinuxOS) a KDE bassed distro BigBearOmaha Linux - Desktop 1 12-18-2006 03:26 PM
Virtual Hosting Thom_Redhat Fedora 0 01-14-2005 07:26 AM
Virtual Hosting not working!! HELP!! chrisfirestar Linux - General 1 10-01-2003 08:00 AM

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

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