Jump to content

Recommended Posts

Hi, I got problem configuring my virtual hosts (name & port based). I would appreciate any help.

I want to host two servers on one computer:

public (i want it to accessible on port 80)

development (on port 8001)

I have dynamic IP address, so I want users to type eg:

123.123.123.123 (public)
or
123.123.123.123:8001 (development)

to get to those servers.

In the same time, I want those servers to be accessible to me as:

localhost
and
development

by just typing that name into browser, without any ip, port or anything. As I understand it, I have to create two virtual hosts and modify /etc/hosts but, unfortunately, I can't get it to work.

 

Here's my /etc/hosts:

127.0.0.1	localhost
127.0.0.1:8001 development

 

My /etc/apache2/ports.conf:

Listen 80
Listen 8001

 

My /etc/apache2/sites-enabled/ files:

ServerName localhost
DocumentRoot /www/localhost/

 

NameVirtualHost *:8001
<VirtualHost *:8001 development>
ServerName development
ServerAlias 127.0.0.1:8001
DocumentRoot /www/development/
</VirtualHost>

 

Right now, remote access to my server (through IP & port) works, but my local access to development server won't. How to fix that?

Link to comment
https://forums.phpfreaks.com/topic/115996-help-configuring-apache-virtual-hosts/
Share on other sites

I'm having a similar issue, and am hoping someone can lend me a hand (I'm pretty new to Apache admin). Basically, I'm trying to use my computer as a test page for two simple sites I administer for the debate society at my university.

 

The two sites are called mdu and mduiv. What I'd like to be able to do is view them both on my computer, so if I go to mdutest.com, I see the mdu test site, if I go to ivtest.com, I see the mdu IV site. This is all running on a MacOSX (thus, BSD-based) system, with Apache 2.2 and PHP 5.0.

 

I've modified my hosts file to include these lines:

127.0.0.1	mdutest.com
127.0.0.1	ivtest.com

 

And have inserted these lines into my httpd-vhosts.conf file (which is, in turn included in the httpd.conf file):

<VirtualHost *:80>
ServerAdmin [redacted]
DocumentRoot "/Users/myname/Sites"
ServerName www.mdutest.com
ServerAlias *.mdutest.com
ErrorLog "/private/var/log/apache2/mdu-errorlog"
CustomLog "/private/var/log/apache2/mdu-customlog"
</VirtualHost>

<VirtualHost *:80>
ServerAdmin [redacted]
DocumentRoot "/Users/myname/Web Sites/MDU-IV-2008"
ServerName www.ivtest.com
ErrorLog "/private/var/log/apache2/mdu-iv-errorlog"
CustomLog "/private/var/log/apache2/mdu-iv-customlog"
</VirtualHost>

 

I have checked both the directories and they have the files I want to serve for each site. I've checked my hosts file, by redirecting mdutext.com to Google's IP, for example, and that works (so it's obviously checking the host file before the DNS servers), so that should work. But I'm either getting a "Server not found" message, or else seeing the page at the default location (in the base DocumentRoot directive). I'm not terribly familiar with Apache, is there something I'm missing?

 

Thanks in advance!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.