View Full Version : Multiple WebServers
ttttt
12-16-2006, 02:25 PM
Hi, I have a few webservers running at the moment. However, I can't run them all at once, as they all use localhost. Is there anyway I can change this, so that http://server1/ for example points to one of the webservers, and http://server2/ points to another?
I'm using apache, and have already had a look at the httpd.conf but can't find anything there.
Thanks,
whizard
12-16-2006, 03:49 PM
Why do you need to run two servers?
Dan
I have never had two Apache server running on the same machine before. So, i am not sure if this would help you or not.
If you look at the configurations file "httpd.conf", there should be a line around 121
Listen 80
You should make sure that the two servers have different ports.
How about leaving one to listen to port 80 and setting the other to listen to port 8080.
If you do that, then you can access the first one like so http://localhost and you can access the second http://localhost:8080 or http://127.0.0.1:8080
Please let's know how you get on...as it would be interesting to see if it is a port issue.
Good luck.
Ess
ttttt
12-16-2006, 04:05 PM
Well, the main reason is, if I only use one, it gets too cluttered, and I lose too many files, but I run more than one site, and prefer to keep things seperate.
I know it's possible, as I have seen it don before.
Thanks for you reply,
ttttt
12-16-2006, 04:10 PM
I have never had two Apache server running on the same machine before. So, i am not sure if this would help you or not.
If you look at the configurations file "httpd.conf", there should be a line around 121
Listen 80
You should make sure that the two servers have different ports.
How about leaving one to listen to port 80 and setting the other to listen to port 8080.
If you do that, then you can access the first one like so http://localhost and you can access the second http://localhost:8080 or http://127.0.0.1:8080
Please let's know how you get on...as it would be interesting to see if it is a port issue.
Good luck.
Ess
Well that works, but I really wanted to change the localhost part, rather then the port number.
Thanks,
whizard
12-16-2006, 04:12 PM
Ok- I just wanted to make sure you knew you could run more than one
site on the same server..
Make sure you have them running on different ports.
Dan
EDIT: wow I missed a lot of posting, sorry this is all so late
ttttt
12-16-2006, 04:23 PM
Maybe I need to use mod_rewrite, but I have no experience of using this or even what it is.
How about using Virtual Hosts.
here is a sample that I personally use.
but first, you need to uncomment the following line...which should be at the end of httpd.conf file
NameVirtualHost *:80
second, you need to create VHost for every website you wish to have. here is a sample.
<VirtualHost *:80>
ServerAdmin admin@localhost
DocumentRoot '/home/user_name/public_html/site1'
ServerName lc.site1.com
</VirtualHost>
Note:
ServerAdmin: the email of the administrator of that virtual host.
DocumentRoot: is the root to the website you have
ServerName: the url name you wish to use for the website. Personally, I always add 'lc' in front of every website I create...so I know it is local and it is for website i.e. "site1.com"
Note:
there should be a sample in your httpd.conf file anyway...but this is just a sample that you can use out of the box. There are loads of variables that you can set for every virtual host as well. I would suggest that you search google for Virtual Hosts...and you should find quite a lot of examples out there.
If you using windows...you need add ServerName to
C:\WINDOWS\system32\drivers\etc\hosts
here is an example
127.0.0.1 lc.site1.com
If you are using linux, you need to add the above code in the hosts file located in /etc/hosts
Note:
Every time you add a virtual host, you will need to restart your Apache server. You do not need to restart your computer, only Apache.
hope that helps
good luck.
ess
ttttt
12-16-2006, 04:48 PM
For some reason that's not working, and now my server won't start.
Do you know if it might be to do with mod_rewrite?
Cannot be.
Mod_rewrite should not affect the server from starting up.
However, you do need to make sure that mod_rewrite is enable if you wish to use it. To do this, uncomment the following line by removing "#"
LoadModule rewrite_module modules/mod_rewrite.so
good luck
Ess
By the way, if you are using windows...you should make sure that when you write DocumentRoot say for a website that is located in the following directory E:\www\test that you replace "\" with "/" so it reads
DocumentRoot 'E:/www/test'
Good luck.
Ess
ttttt
12-16-2006, 05:11 PM
Thanks, I'll have a look at mod_rewrite, but I don't know w.hether it will hold the answer or not If anyone knows how to solve the problem, could you please tell me. Thanks,
oracleguy
12-16-2006, 08:00 PM
Just modify your hosts file so 'server1' and 'server2' point to the server. (You could tweak your DNS server if you wanted it to affect your whole network but thats more involved than you probably need)
Now considering this code:
<VirtualHost *:80>
ServerAdmin admin@localhost
DocumentRoot '/home/user_name/public_html/site1'
ServerName lc.site1.com
</VirtualHost>
As an example, the VirtualHost *:80 part is what you'll want to change. That star means anything then port 80. Try changing it to:
<VirtualHost server1:80> And then another one for server2.
I've never actually tried it myself but it should work and is the gist of what you need to do. You shouldn't need mod_rewrite.
ttttt
12-17-2006, 12:52 PM
Just modify your hosts file so 'server1' and 'server2' point to the server.
What exactly is my hosts file, and what do you mean by my user_name?
Thanks,
oracleguy
12-17-2006, 06:08 PM
The hosts file is what ess was talking about:
Code:
C:\WINDOWS\system32\drivers\etc\hosts
here is an example
Code:
127.0.0.1 lc.site1.com
If you are using linux, you need to add the above code in the hosts file located in /etc/hosts
So you'd want to add like:
127.0.0.1 server1
127.0.0.1 server2
To the file
The only code that matters in the stuff I posted was how I changed the virtualhost opening tag. I included a sample one with more code so you could get the context.
ttttt
12-19-2006, 03:53 PM
But I don't really want to use virtual servers. Can I modify the hosts file to point to my different servers; a file path?
Thanks,
CFMaBiSmAd
12-19-2006, 04:26 PM
The two different methods that have been given are the available ways to make this work.
To get two separate servers to run at the same time they must listen on different ports.
To get one server to run but respond to different host names requires using virtual servers. This would allow each host name to have its own separate root folder of web files. This appears to be what you are trying to do.
The reason mod_rewrite won't help is that it functions at the server level. When a request reaches a web server, the mod_rewrite rules are applied to rewrite the URL. The rules apply to paths within the current web server.
oracleguy
12-19-2006, 05:22 PM
But I don't really want to use virtual servers.
Is there a reason you don't want to?
ttttt
12-19-2006, 05:37 PM
Not any more. But how do I add the users, and what do I do first? Can you give me a list of what I need to do, from the basics, like enabling it- like I said, I've never done anything except basic hosting with apache.
Thanks,
ttttt
12-20-2006, 11:24 AM
Don't worry, it's working.
Thanks for all of your help!
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.