leszczu Posted July 22, 2008 Share Posted July 22, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/115996-help-configuring-apache-virtual-hosts/ Share on other sites More sharing options...
toivo Posted July 25, 2008 Share Posted July 25, 2008 Have you tried the following in the hosts file: 127.0.0.1 development The entries in the hosts file do not have ports. Quote Link to comment https://forums.phpfreaks.com/topic/115996-help-configuring-apache-virtual-hosts/#findComment-599323 Share on other sites More sharing options...
MacGod Posted July 29, 2008 Share Posted July 29, 2008 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! Quote Link to comment https://forums.phpfreaks.com/topic/115996-help-configuring-apache-virtual-hosts/#findComment-602872 Share on other sites More sharing options...
corbin Posted July 29, 2008 Share Posted July 29, 2008 www.mdutest.com and *.mdutest.com != mdutest.com. Quote Link to comment https://forums.phpfreaks.com/topic/115996-help-configuring-apache-virtual-hosts/#findComment-603003 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.