Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Virtual Hosts on Different Ports in WAMP

So I have this problem...

I use WAMP and have set up perfectly working Virtual Hosts in the past, but now I have come to something I never foresaw.

I am trying to do this:

Access C:\wamp\www through http://localhost

Access D:\somethingelse through http://localhost:8080 OR http://something.dev

I much prefer using the proper http://something.dev, as the working site is http://something.co, and so I can keep them separate.

I have followed guides and read forum posts, but all I have manages to do so far is this:

Access C:\wamp\www through http://localhost OR http://something.dev

Access D:\somethingelse through http://localhost:8080 OR http://something.dev:8080

Anybody got any idea how you would do this? Here's my VirtualHost Code:

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "C:\wamp\www"
ServerName localhost
ServerAlias www.localhost.com
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>

<VirtualHost *:8080>
ServerAdmin webmaster@something
DocumentRoot "D:/something/www"
ServerName something.dev
ServerAlias www.something.dev
ErrorLog "logs/something-error.log"
CustomLog "logs/something-access.log" common
<directory "D:/something/www">
    Options Indexes FollowSymLinks
    AllowOverride all
    Order Allow,Deny
    Allow from all
</directory>
</VirtualHost>

And in httpd.conf I have this

Listen *:80
Listen *:8080

And my hosts file is working and points both of these to 127.0.0.1

(The reason I want to do this is that when I code on my machine I use the http://something.dev, but I run Livereload Windows, and test my website simultaneously on an iPhone and iPad on the same local network, but without any access to iOS's equivalent of the hosts file. It also allows me to open up only a specific part of my server to the internet, through port forwarding on my router.)

like image 973
Alfo Avatar asked Mar 09 '12 21:03

Alfo


People also ask

How can I change port number in WAMP server?

By default, when running the WAMP application on an Apache server, the localhost port is set to port 80. However, you can adjust this setting on your server by editing the "http. conf" and entering a new port number.

What port does WAMP use?

Windows services that listen on port 80 Right click WAMP icon in the system tray and select Tools.


1 Answers

I suppose you have solved the issue. Anyway is good to share some nice information on how to set up multiple Virtual Hosts in Wamp. This is working for me:

http://www.kristengrote.com/blog/articles/how-to-set-up-virtual-hosts-using-wamp

In my case I am working with ports 8080 and 8181. 8080 is redirecting to a subfolder under c:\wamp\www\myfolder, while 8181 is redirecting to root c:\wamp\www.

To make 8181 work I had to edit httpd-vhosts.conf, hosts (in \drivers\etc folder) and httpd.conf.

In httpd.conf my Apache is listening:

Listen 8080
Listen 8181

also I uncommented:

Include conf/extra/httpd-vhosts.conf

my root is pointing to

DocumentRoot "c:/wamp/www/myfolder"

root directory is configured as:

<Directory "c:/wamp/www">
    Options Indexes FollowSymLinks
    AllowOverride All
     Order Deny,Allow
     Deny from all
     Allow from 127.0.0.1
     Allow from ::1
     Allow from localhost
</Directory>

and added:

<VirtualHost *:8181>
DocumentRoot "C:\wamp\www"
ServerName name-of-my-fake-server
</VirtualHost>

in httpd-vhosts.conf I have set:

NameVirtualHost *:8181

in hosts (c:\windows\system32\drivers\etc) I have added:

127.0.0.1       localhost
127.0.0.1       name-of-my-fake-server #My Test Site

Doing that I have now two ports working 8080 and 8181: so 8080 points to directory "c:\wamp\www\myfolder" and the other port 8181 points to my root folder "c:\wamp\www\"

like image 98
Junior Mayhé Avatar answered Oct 04 '22 06:10

Junior Mayhé