LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   I got a question about configuring my web server (https://www.linuxquestions.org/questions/linux-newbie-8/i-got-a-question-about-configuring-my-web-server-643099/)

trist007 05-18-2008 03:51 PM

I got a question about configuring my web server
 
the default location for the index.html on fedora 8 is
/var/www/html/ on which port 80 is listening

Can I configure another index.html listening on another port, say 8080? How would I do that? Would that index.html still be in /var/www/html/?
What would i have to change?

I know I'd have to edit the Listen port on httpd.conf, but can I have two separate web servers (webpages) listening on two different ports? I know that if someone wanted to access the one on port 8080 they'd just append :8080 after the domain name. But what do I need to change to have two web servers running on the same computer?

dkm999 05-18-2008 04:09 PM

What you want is to set up virtual hosting on your webserver. There is a separate section in the Apache documentation that describes how to do this. Boiled down, you need to make 3 changes to what you now have (assuming that you are not yet doing virtual hosting).
1. Create a <VirtualHost> container for your current website. You might want to move the pages to a subfolder, say /var/www/html/bar. This container should specify port 80.
2. Create a <VirtualHost> container for your new stuff. It should probably be in a different folder (mine are all of the form /var/www/html/foo. This container should specify port 8080
3. Edit your httpd.conf file (maybe in /etc/httpd/conf/httpd.conf), so that it not only listens on the standard port (80), but also on your special port:
Code:

Listen 80
Listen 8080

.

As an alternative to this, you can use Name-Based Virtual Hosting; in this scheme, you need to have a way of allowing users to map different DNS names to your IP address; then the Apache server matches the name in the request against the VirtualHost ServerName. If your users are on the public Internet, this means registering a second DNS name that resolves to the same IP address as your first site name. If your users are only on a private net, then you can set up a private DNS server that will supply the correct name-to-address resolution for those users.

trist007 05-18-2008 05:30 PM

but how does httpd now which webpage is tied to 8080 and which is tied to 80?

I mean if I have one on
/var/www/html/foo/index.htm

and another on
/var/www/html/bar/index.htm

How will httpd know which one is for port 80 and which one is for port 8080?

Also, won't httpd be looking for the index.htm in
/var/www/html/ instead of /var/www/html/foo ?

I was looking at httpd.conf and I'd have to modify

Listen 80
I would add another line
"Listen 8080"

ServerName 192.168.1.131:80
I would add another linke
ServerName 192.168.1.131:8080

DocumentRoot
/var/www/html/
I would edit this by replacing it with two lines
/var/www/html/foo/
/var/www/html/bar/

But still, how would httpd.conf know which is for which port?

dkm999 05-19-2008 01:08 AM

I realize this may be daunting when you first set out, but you really should Read The Fine Manual. There is a thorough discussion of all this here

Once you define the first <VirtualHost> container, one of the first things that you will need to put inside each one is a configuration line that says
Code:

DocumentRoot /var/www/html/foo
and in the second <VirtualHost> container, a configuration line that says
Code:

DocumentRoot /var/www/html/bar
These differing document roots will tell the server that when it receives a request that matches the specifications for the first <VirtualHost> definition, it should begin looking for files in /var/www/html/foo, but if it receives a request that matches the specifications for the second <VirtualHost> definition, it should begin looking for files in /var/www/html/bar.


All times are GMT -5. The time now is 06:21 PM.