Multiple virtual hosts on different ports in WAMP

So I have this problem ...

I used WAMP and in the past I set up well-functioning Virtual Hosts, but now I have come to what I never foresaw.

I am trying to do this:

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

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

I prefer to use the correct http://something.dev , since the production site is http://something.co , and therefore I can store them separately.

I followed the instructions and read the forum posts, but all I managed to do was:

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

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

Does anyone have any ideas how you will do this? Here is 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 works and points both of these options to 127.0.0.1

(The reason I want to do this is because when I write code on my computer, I use http://something.dev , but I run Livereload Windows and simultaneously test my website on iPhone and iPad in one LAN, but without any access to the iOS equivalent of the hosts file. It also allows me to open only a specific part of my server to the Internet through port forwarding on my router.)

+5
source share
4 answers

I suppose you solved the problem. In any case, it’s good to share some nice information on how to set up multiple virtual hosts in Wamp. This works for me:

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

In my case, I work with ports 8080 and 8181. 8080 is redirected to a subfolder under the c: \ wamp \ www \ myfolder folder, and 8181 is redirected to root c: \ wamp \ www.

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

In httpd.conf, my Apache listens for:

 Listen 8080 Listen 8181 

Also I unearthed:

 Include conf/extra/httpd-vhosts.conf 

my root points to

 DocumentRoot "c:/wamp/www/myfolder" 

The 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 installed:

 NameVirtualHost *:8181 

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

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

Now I have two ports running on 8080 and 8181: therefore, 8080 points to the directory "c:\wamp\www\myfolder" and the other port 8181 points to my root folder "c:\wamp\www\"

+12
source

Using * as the host name requires the use of NameVirtualHost:

 NameVirtualHost *:80 NameVirtualHost *:8080 
+1
source

For those who have MAMP, edit httpd.conf

 nano /Applications/MAMP/conf/apache/httpd.conf 

Add Listen for each port

 Listen 80 Listen 8080 

And ServerName too

 ServerName localhost:80 ServerName localhost:8080 

Once done, edit httpd-vhosts.conf

 nano /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf 

Define NameVirtualHost

 NameVirtualHost *:80 NameVirtualHost *:8080 

And VirtualHost

 <VirtualHost *:80> DocumentRoot "/Users/yourUser/path/project1" ServerName project1.local </VirtualHost> <VirtualHost *:8080> DocumentRoot "/Users/yourUser/path/project2" ServerName project2.local </VirtualHost> 

Of course you need to have project1.local and project2.local in the hosts

 sudo nano /etc/hosts 

And add

 127.0.0.1 project1.local project2.local 

Restart MAMP and you can access your vhost with

 project1.local project2.local:8080 

project2 can also be accessed on your network or using an external IP (for example, for testing from another device, such as a mobile phone). Assuming your IP address is 192.168.1.10

 192.168.1.10:8080 
0
source

The question is a bit about this. But I suggested that this is nearby and may be useful to someone.

I recently ran into a problem when I need to access several resources (Debian repository, my site and phpmyadmin) at one external IP address and port.

After studying the problem, I found that the technology is called reverse proxy . It is like a proxy, but the server accepts all connections from many users and redirects them to one target (your server).

I made a simple Docker image and a docker-compose file and uploaded it to github.com/urpylka/docker-nginx-reverse-proxy and hub.docker.com .

The config file is very simple:

 server { listen 80; server_name smirart.ru robotic.lol; location / { proxy_pass http://robotic.lol:1080/; } } server { listen 80; server_name repo.smirart.ru; location / { proxy_pass http://8.8.8.8:2080/; } } 

You can use this for multiple web servers running with different IPs.

0
source

Source: https://habr.com/ru/post/1400656/


All Articles