Virtual hosts - all redirected to the WAMP localhost homepage

I installed the latest version of WAMP on my Windows 8 PC - I cannot get several virtual hosts to work, each local URL that I download will show the WAMP home page.

Can someone explain what I'm doing wrong?

// My hosts file
127.0.0.1   localhost   
127.0.0.1   client1.localhost
127.0.0.1   client2.localhost

I have two folders in my WAMP directory, 'client1' and 'client2', it is obvious that each folder will link client1 and client2 in the main file above.

// My virtual hosts file
<VirtualHost *:80>
  ServerName localhost
  DocumentRoot "C:\wamp\www"
</VirtualHost>

<VirtualHost *:80>
  ServerName client1.localhost
  DocumentRoot "C:\wamp\www\client1"
<Directory "C:\wamp\www\client1">
  allow from all
  order allow,deny
  AllowOverride All
</Directory>
 DirectoryIndex index.html index.php
</VirtualHost>

<VirtualHost *:80>
  ServerName client2.localhost
  DocumentRoot "C:\wamp\www\client2"
<Directory "C:\wamp\www\client2">
  allow from all
  order allow,deny
  AllowOverride All
</Directory>
  DirectoryIndex index.html index.php
 </VirtualHost>
+4
source share
4 answers

I followed this guide and it worked fine

I had to change the way ...

<VirtualHost *:80>
 ServerAdmin emailaddress@domain.com
 DocumentRoot "c:\wamp\www\client1"
 ServerName client1.localhost
 ErrorLog "logs/client1.log"
 CustomLog "logs/client1-access.log" common
</VirtualHost>

.. , WAMP http://www.techrepublic.com/blog/smb-technologist/create-virtual-hosts-in-a-wamp-server/#

0

, .

hosts, Windows, , Runs as Administrator : -

net stop "DNS Client"

, do

net start "DNS Client"

, !

DNS- , hosts , , .

vhost , - , , Apache vhost, vhost. , WAMP, , , vhost.

, , vhost - Require local, , , Require local, 404, .

// My virtual hosts file
<VirtualHost *:80>
  ServerName localhost
  DocumentRoot "C:\wamp\www"
  <Directory "C:\wamp\www">
     AllowOverride All
     # never want to allow access to your wamp home page area to anyone other than This PC
     # plus us the Apache 2.4.x syntax and not the 2.2 syntax
     Require local
  </Directory>
</VirtualHost>

<VirtualHost *:80>
  ServerName client1.localhost
  DocumentRoot "C:\wamp\www\client1"
  <Directory "C:\wamp\www\client1">
     AllowOverride all
     # use Apache 2.4 syntax to all access to your internal network only
     Require ip 192.168.0
     # Or if you really want to give access to the whole internet uncomment this and comment the previous line
     #Require all granted
 </Directory>
 DirectoryIndex index.html index.php
</VirtualHost>

<VirtualHost *:80>
  ServerName client2.localhost
  DocumentRoot "C:\wamp\www\client2"
  <Directory "C:\wamp\www\client2">
     AllowOverride all
     # use Apache 2.4 syntax to all access to your internal network only
     Require ip 192.168.0
     # Or if you really want to give access to the whole internet uncomment this and comment the previous line
     #Require all granted
  </Directory>
  DirectoryIndex index.html index.php
 </VirtualHost>

, , , Require ip 192.168.0. ( 192.168.0, . )

, , , Port Forward .

, , , Require local, WAMP.

WAMPServer 2.4, , , , , WAMPServer, , vhost. , .

, vhost, : -

1. vhost \wamp\bin\apache\apache2.4.4\conf\extra\httpd-vhosts.conf and then in the httpd.conf, ( conf.

# Virtual hosts
#Include conf/extra/httpd-vhosts.conf

# infront Include

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

2. vhost , , , \wamp\vhost.

httpd.conf , IncludeOptional "d:/wamp/vhosts/*" , vhost, . Apache 2.4. , Apache 2.4.x.

+10

C:\wamp\www\ C:\wamp\www\client1 C:\wamp\www\client2

, hosts client1.dev client1.localhost, Virtualhost,

<VirtualHost *:80>
DocumentRoot "F:\www\client1"
ServerName client1.dev
ServerAlias client1.dev www.client1.dev
Options Indexes FollowSymLinks
<Directory "F:\www\client1">
    AllowOverride All
    Order Deny,Allow
</Directory>
</VirtualHost>

,

+2
source

First, your directory structure should never exceed the folder wwwfor security purposes.

- c:\wamp\www (home)
    -c:\wamp\www\client1 (client1)
    -c:\wamp\www\client2 (client2)

Secondly, a change in vhost requires reload, but in your case you have to do restart, because it wampdoes not offer reload.

+1
source

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


All Articles