Can not get name bassed Virtual Hosting working on RH9
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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>
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.
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.
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.
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)
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.