LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Apache Virtual Hosts (http://www.linuxquestions.org/questions/linux-general-1/apache-virtual-hosts-230145/)

dienerk 09-13-2004 02:10 PM

Apache Virtual Hosts
 
This is killing me. I have tried reading everything I can find about setting up virtual hosts in Apache. I currently host about ten different sites on a windows machine. I am trying as hard as I can to switch to Linux but I am stumbling on this one.

I have Suse 9.1 professional, Red Hat 9.0, Mandrake 9.2 and 8.1, Fedora 2, and Xandros, to choose from. I lost my Debien disks when I lent them out and I haven't replaced them yet, I have replaced the from though.

I have use Webmin, and redhats gui for this and I just cannot seem to be successful.

I read all the forums that I can find on this and they're answers are either too technical for me still or a different distribution or something just way out there.

I am begging, please will someone tell me which distribution to use, and give me real life examples on how to set this up. Please use "See Spot Run Language".

Thanx for the help. I am sure this is something you guys do in your sleep, but I have been known to load three or four distributions in a day trying different combinations of information I have read or been told. Please help a guy out.

codecruncher 09-13-2004 02:30 PM

I do recommend Whitebox Enterprise Linux since it is the same as RedHat Enterprise server 3.0 just without the copyrighted stuff from RedHat.

Setting up Virtual Hosts is quite easy. Just edit /etc/http/conf/httpd.conf. At the very bottom you'll find the following:
#
# Use name-based virtual hosting.
#
#NameVirtualHost *

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>



Simply add the folowing:

NameVirtualHost 213.147.164.xxx

<VirtualHost 213.147.164.xxx>
ServerAdmin webmaster@yourdomain.com
DocumentRoot /var/wwwhtdocs.404/
ServerName 404.yourdomain.com
</VirtualHost>

<VirtualHost 213.147.164.xxx>
ServerAdmin webmaster@yourdomain.com
DocumentRoot /var/www/htdocs.shop_inet/
ServerName shop.yourdomain.com
</VirtualHost>

and so on...

HTH
Klaus

btw: This should work in every distro. This Apache specific - not Linux specific (meaning also works in Windows)

Pete M 09-13-2004 04:06 PM

dienerk, Klaus

Just to add a little something, be aware of this statement in httpd.conf

<Directory />
Order Deny,Allow
Deny from all
</Directory>
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

Which by default denies Apache access to all directories unless you specifically allow it

So
<VirtualHost 213.147.164.xxx>
ServerAdmin webmaster@yourdomain.com
DocumentRoot /var/wwwhtdocs.404/
ServerName 404.yourdomain.com
</VirtualHost>

<VirtualHost 213.147.164.xxx>
ServerAdmin webmaster@yourdomain.com
DocumentRoot /var/www/htdocs.shop_inet/
ServerName shop.yourdomain.com
</VirtualHost>

Needs to be
<VirtualHost 213.147.164.xxx>
ServerAdmin webmaster@yourdomain.com
DocumentRoot /var/www/htdocs.404/
ServerName 404.yourdomain.com
<Directory "var/www/htdocs.404">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 213.147.164.xxx>
ServerAdmin webmaster@yourdomain.com
DocumentRoot /var/www/htdocs.shop_inet/
ServerName shop.yourdomain.com
<Directory "var/www/htdocs.shop_inet">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

May help, took me a long time to work out my own Virtual Hosts

Pete

dienerk 09-13-2004 08:43 PM

Thank you very much for the tips, I will try them both. I appreciate your valuable time for helping a newbie.

dienerk 09-14-2004 04:22 PM

You know I feel pretty stupid, but I could not get the suggestions to work. I am taking yor advise and getting the White Box Enterprise distribution. I should be done downloading it in an hour.

Is there any way I could get a copy of a complete http.conf file with virtual hosts that works so I could have an entire working model? I believe it would be easier for me to grasp something that I already know works. I have noticed advise I have received in the past may not be good and that may be part of my problem.

I hope someone can help. Thanx again for your time and trouble.

Pete M 09-14-2004 05:16 PM

dienerk

I'm no httpd expert but I do know there are many variations of Apache so sending you a httpd.conf is doomed to fail

As you are downloading White Box Enterprise why not do a fresh install of Apache and start from scratch, in fact it probably comes as a default package

First piece of advise is make a copy of httpd.conf before you do anything this way you have something to fall back on, it's real easy to do, simply navigate to your /etc/httpd/conf directory and enter 'cp httpd.conf httpd.save' you now have an intact file called httpd.save should you need it

Secondly get your hands dirty on the command line when editing the file never had much success with GUI's plus you will learn a lot more about the inner workings of Apache

I know this is not the solution you are looking for but at least with Linux it only costs you time not money

Pete

dienerk 09-14-2004 06:56 PM

Thanx for the advise Pete. I will try it in the next day or two. I will try the command line idea. That seems to be the key in learning more about linux and how it works.

Thanx for your time.

Dunga Bee 09-14-2004 09:15 PM

Once you set some Name Virtual Hosts up, you should be able to test the config and see how it interprets your virt hosts by using a switch on the apache exe. I can't remember the exact switch now, but check the help on the apache command and it should say. I've found that to show me things I may never have thought of.

Good luck!

dienerk 09-15-2004 08:28 AM

Apache Virtual Host Dungeon!
 
I GIVE UP! APACHE WINS!
Below is a copy of my http.conf file. Can anyone tell me why this is not working?

Now I get an error that say" httpd failed. Starting httpd: (99) Cannot assign requested address: make_sock: could not bind to address 24.173.163.190:80 No listening sockets available, shutting down Unable to open logs! (Then I think I hear the machine laughing at me.)

How can apache be the most popular server on the internet when it is this difficult to setup? I tried reading the apache site again last night and still don't understand where I am going wrong.

Is ther anyone I can e-mail my httpd file to and they can have a look? I am blind at this moment.

ALL HELP IS APPRECIATED!!!!!!!!!

Dunga Bee 09-15-2004 08:33 AM

Post your config here and we can take a look.

dienerk 09-15-2004 11:12 AM

I tried first, but it said that it was too many characters. How much of the config to you need. Or should I edit out all of the lines with "#"? Suggestions?

does this much help?

#
# Use name-based virtual hosting.
#
NameVirtualHost 24.173.163.190:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>

<VirtualHost 24.173.163.190:80>
ServerAdmin linux@medscribe.biz
DocumentRoot /var/www/naghag.com/
ServerName naghag.com
</VirtualHost>

<VirtualHost 24.173.163.190:80>
ServerAdmin linux@medscribe.biz
DocumentRoot /var/www/medscribe.biz/
ServerName medscribe.biz
</VirtualHost>

<VirtualHost 24.173.163.190:80>
ServerAdmin linux@medscribe.biz
DocumentRoot /var/www/pandagirl.us/
ServerName pandagirl.us
</VirtualHost>

Pete M 09-15-2004 12:00 PM

dienerk

To keep it simple (KIS) find this statement in httpd.conf

# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
#
Listen 80

Use 'Listen 80' just to get Apache started we'll be more specific later, no ' : ' needed

Again KIS change your virtual host statements to read

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>

<VirtualHost *:80>
ServerAdmin linux@medscribe.biz
DocumentRoot /var/www/naghag.com/
ServerName naghag.com
</VirtualHost>

<VirtualHost *:80>
ServerAdmin linux@medscribe.biz
DocumentRoot /var/www/medscribe.biz/
ServerName medscribe.biz
</VirtualHost>

<VirtualHost *:80>
ServerAdmin linux@medscribe.biz
DocumentRoot /var/www/pandagirl.us/
ServerName pandagirl.us
</VirtualHost>

Did you remember about this statement

# First, we configure the "default" to be a very restrictive set of
# features.
<Directory />
Order Deny,Allow
Deny from all
</Directory>
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

If it looks like this then you will have to give Apache specific instructions in each VirtualHost to allow access to the DocumentRoot

Are the directories naghag.com, medscribe.biz, pandagirl.us world readable ? if not you will have to change the permissions

Do you have a Main server configuration ? if so you should also add this as a VirtualHost

Think that's enough for you to get on with

Pete

dienerk 09-15-2004 02:19 PM

Thanks for the Info. My wife is going into labor so it may be a little while before I can try this. I appreciate the help. My daughter should be here tonight or tomorrow.

Thanx again.

Dunga Bee 09-15-2004 02:21 PM

Congrats!

Pete M 09-15-2004 02:25 PM

dienerk

I think it's time for Apache to take a back seat, hope your wife and soon to be daughter are both OK

Just post back whenever you are ready

Regards

Pete


All times are GMT -5. The time now is 09:28 PM.