stefhs — 2011-12-13T05:22:28-05:00 — #1
I'd like to recreate locally an environment similar to our dedicated server.
Therefore I've installed on my PC Windows 7:
- Apache 2.2.21
- PHP 5.3.8
I am also running IIS on the same PC, so I've set Apache on the port 8080.
Everything works fine so far and I did not have any problem.
However I wanted to be able to browse multiple websites locally just typing "mywhateverwebsitename" instead of "localhost:8080", but it seems I am unable to do it.
I am Administrator on this PC.
I've edited the httpd-vhosts.conf file and the Windows hosts file.
In the httpd-vshosts.conf file I have:
Options Indexes FollowSymLinks
Allow from all
In the hosts I have just:
I did not have any issue with permissions.
If I write in the hosts file the line
and then try ping www.altavista.com all seems fine and the ping shows the local IP.
If I write in the hosts file the line
and then try ping www.altavista.com it shows the real public IP of altavista.
If I write
and ping it works and shows the local address (and it shows the IIS home in the browser). If I type
and then try to ping phpserver.site it does not work and the browser shows nothing (not found).
Clearly the hosts file is working properly, and I do not understand where the problem is and if I can do what I want on this PC with this configuration.
I've tried to read as much as possible on the topic before posting here, but nothing seems to work, therefore I'm assuming there is something I don't know or did not understand!
I would really appreciate some help!!
scallioxtx — 2011-12-13T05:27:17-05:00 — #2
You can't put ports in the hosts file, only IP address -> domain name mappings
If you have the 127.0.0.1 phpserver.site in your hosts file, you should be able to visit phpserver.site:8080 and see the site Apache is serving.
stefhs — 2011-12-13T05:38:58-05:00 — #3
Hi ScallioXTX, many thanks for your reply...
That's one thing I did not know, although I was guessing it eheh
So let's say I have
in my Windows hosts file.
Then I have
in my httpd-vhosts.conf file.
When I type mytest.site in my browser it goes to IIS and not Apache
What am I doing wrong? (I'm sure many things eheheh )
Edit: Nevermind, I did not read the address you wrote properly sorry! So I can't just have mytest.site, I need anyway to use the :8080 at the end?
stefhs — 2011-12-13T06:14:28-05:00 — #4
Using the port with the name it works perfectly, so many thanks!!
Is there a way to reach these subdomains I create on my PC locally from another PC (browser) on the same LAN?
scallioxtx — 2011-12-13T06:21:36-05:00 — #5
Browsers will connect to port 80 by default, so if you your server running on a different port you need to supply it; there is no way around that.
As for the other PC in the LAN, yes, that can also access your if you put the same domain name and your LAN IP in their host file.
For this to work you need either
Listen 8080, Listen
*:8080 or Listen
<your LAN IP>:8080 in the httpd.conf.
Listen 127.0.0.1:8080 will not work.
(my personal preference is just the port, so
Listen 8080, but it's up to you :))
stefhs — 2011-12-13T07:04:45-05:00 — #6
Many many thanks!!
What you wrote, it is very clear to me if I want my colleague to reach the localhost:8080, myIP:8080.
Providing that there is nothing preventing the connection (like a firewall setting, etc.) I would expect this to work fine.
Now, in case I do not want the user to connect to one of the subdomains I created through both the hosts and httpd-vhost.conf files.
How would my colleague reach it?
I was wondering tif this should go through a different, additional port?
scallioxtx — 2011-12-13T07:56:02-05:00 — #7
I'm not entirely sure I get that last question, but it sounds like you're looking for Access control
stefhs — 2011-12-13T11:02:21-05:00 — #8
Oops sorry, I inserted a "not" too much in my post eheh
This is the scenario.
Apache root localhost:8080 on my PC.
If my colleague types myIP:8080 it should show the above.
On my PC I have a subsite namesomething (127.0.0.1 namesomething in hosts and the related code in httpd-vshost.conf).
Therefore on my PC I can type namesomething:8080 in my address bar and see this local website.
Now I would like my colleague being able to browse this subwebsite from his PC, using a standard browser.
scallioxtx — 2011-12-13T11:47:14-05:00 — #9
You can do if you add the name of that site to your colleague's host file.
There are other ways, but this is by far the simplest
dklynn — 2011-12-14T04:26:04-05:00 — #10
Good responses, Rémon. As noted, if you have a conflict between servers on the same system, one is allowed port 80, the other is usually relegated to 8080.
My first question is WHY keep IIS if you have a good server to use, i.e., Apache? Isn't it more trouble than it's worth to use the 8080 port work around?
As for your LAN cohorts, if they update their hosts file (on Win7, that's C:\Windows\system32\drivers\etc\hosts) with your LAN address (is it fixed or dynamic - that will be a problem if the latter) and the 8080 port but I'd make sure that any "domains" that you want to protect are not under localhost! I keep all my test domains on the W: (for web) partition and use acronyms for each for my own benefit but that could provide some security (by obfuscation) within your LAN. If that's not sufficient, password protect your domains (with a site login if you can't use file attributes or Apache's password protection)!
stefhs — 2011-12-19T08:53:42-05:00 — #11
Hi and thanks to both for your replies!
You are right in normal conditions I would do differently, but firstly I have to develop also using .NET and Classic ASP, so Apache is not the right environment. This hopefully will be a temporary situation, but it could be "temporary" for a while eheh
Anyway, I should just write
in the hosts file of my colleague?
Too good to be true but I'll give it a go!!!
Many thanks again, I'll come back here crying if (when) I'll fail my attempt eheheh
scallioxtx — 2011-12-19T09:05:52-05:00 — #12
You could, if you want, run the Apache website through a reverse proxy from IIS, or the other way around.
That way you just have one port, makes it a lot easier
It would cost more data traffic, but since it's all on the same host it doesn't really matter.
stefhs — 2011-12-22T04:57:51-05:00 — #13
Just popped up to say thank you again.
Everything is working absolutely fine and I have to say it was very easy in the end.
That is how I proceeded:
1. Allowed a range of local IPs on my Domain network in Windows 7 Firewall by creating a Connection Security Rule (this itself obviously allowed my colleagues to browse the IIS websites easily);
2. The hosts file on my colleague's Windows 7 PC, same LAN, was edited just adding the line myIP nameofmylocalapacheSubsite (for example 192.168.1.33 mylocal.website).
And that was it!
All fine, all happy
Thank you again very much!! (: