Php wamp中的多虚拟主机
我试图在wamp中创建多个虚拟主机,但当我添加第二个虚拟主机时,它会显示wamp主页 这是我的主机文件:Php wamp中的多虚拟主机,php,apache,wamp,virtualhost,Php,Apache,Wamp,Virtualhost,我试图在wamp中创建多个虚拟主机,但当我添加第二个虚拟主机时,它会显示wamp主页 这是我的主机文件: #localhost name resolution is handled within DNS itself. #127.0.0.1 localhost #::1 localhost 127.0.0.1 localhost 127.0.0.1 www.site1.com 127.0.0.1 www.aksharen.c
#localhost name resolution is handled within DNS itself.
#127.0.0.1 localhost
#::1 localhost
127.0.0.1 localhost
127.0.0.1 www.site1.com
127.0.0.1 www.aksharen.com
::localhost
::www.site1.com
::www.aksharen.com
这是我的httpd-vhosts.conf文件:
<VirtualHost *:80>
DocumentRoot "C:/wamp/www"
ServerName localhost
</VirtualHost>
<VirtualHost 127.0.0.1>
DocumentRoot "C:/websites/www.site1.com/public"
ServerName "www.site1.com"
<Directory C:/websites/www.site1.com>
DirectoryIndex index.php
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require local
</Directory>
SetEnv APPLICATION_ENV "development"
</VirtualHost>
<VirtualHost 127.0.0.1>
DocumentRoot "C:/websites/www.aksharen.com/public"
ServerName "www.aksharen.com"
<Directory C:/websites/www.aksharen.com>
DirectoryIndex index.php
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require local
</Directory>
SetEnv APPLICATION_ENV "development"
</VirtualHost>
DocumentRoot“C:/wamp/www”
服务器名本地主机
DocumentRoot“C:/websites/www.site1.com/public”
服务器名“www.site1.com”
DirectoryIndex.php
选项索引跟随符号链接多视图
允许超越所有
要求本地
SetEnv应用程序_ENV“开发”
DocumentRoot“C:/websites/www.aksharen.com/public”
服务器名“www.aksharen.com”
DirectoryIndex.php
选项索引跟随符号链接多视图
允许超越所有
要求本地
SetEnv应用程序_ENV“开发”
我的第一个网站www.site1.com运行良好 你犯了一些错误 首先
127.0.0.1 localhost
127.0.0.1 www.site1.com
127.0.0.1 www.aksharen.com
::localhost
::www.site1.com
::www.aksharen.com
尝试将此更改为
127.0.0.1 localhost
127.0.0.1 www.site1.com
127.0.0.1 www.aksharen.com
::1 localhost
::1 site1.com
::1 aksharen.com
其次,我建议您对虚拟主机定义进行以下更改:-
<VirtualHost *:80>
DocumentRoot "c:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "c:/wamp/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/websites/www.site1.com/public"
ServerName site1.com
ServerAlias www.site1.com
<Directory "C:/websites/www.site1.com/public">
DirectoryIndex index.php
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require local
</Directory>
SetEnv APPLICATION_ENV "development"
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/websites/www.aksharen.com/public"
ServerName aksharen.com
ServerAlias www.aksharen.com
<Directory "C:/websites/www.aksharen.com/public">
DirectoryIndex index.php
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require local
</Directory>
SetEnv APPLICATION_ENV "development"
</VirtualHost>
DocumentRoot“c:/wamp/www”
服务器名本地主机
服务器别名本地主机
允许超越所有
要求本地
DocumentRoot“C:/websites/www.site1.com/public”
ServerName site1.com
ServerAlias www.site1.com
DirectoryIndex.php
选项索引跟随符号链接多视图
允许超越所有
要求本地
SetEnv应用程序_ENV“开发”
DocumentRoot“C:/websites/www.aksharen.com/public”
服务器名aksharen.com
ServerAlias www.aksharen.com
DirectoryIndex.php
选项索引跟随符号链接多视图
允许超越所有
要求本地
SetEnv应用程序_ENV“开发”
为虚拟主机使用环回地址IP。i、 e每个vhost都应该有自己独特的环回ip。对于eaxmple,您的主机文件应该类似于:
127.0.0.100 drupal.fox
127.0.0.2 play.fox
127.0.0.3 cake241.fox
<VirtualHost 127.0.0.100:80>
<Directory "c:/ampps/www/drupal.fox">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
allow from All
</Directory>
ServerName drupal.fox
ServerAlias drupal.fox
ScriptAlias /cgi-bin/ "c:/ampps/www/drupal.fox/cgi-bin/"
DocumentRoot "c:/ampps/www/drupal.fox"
ErrorLog "C:/ampps/apache/logs/drupal.fox.err"
CustomLog "C:/ampps/apache/logs/drupal.fox.log" combined
</VirtualHost>
因此,您的vhosts文件应该类似于:
127.0.0.100 drupal.fox
127.0.0.2 play.fox
127.0.0.3 cake241.fox
<VirtualHost 127.0.0.100:80>
<Directory "c:/ampps/www/drupal.fox">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
allow from All
</Directory>
ServerName drupal.fox
ServerAlias drupal.fox
ScriptAlias /cgi-bin/ "c:/ampps/www/drupal.fox/cgi-bin/"
DocumentRoot "c:/ampps/www/drupal.fox"
ErrorLog "C:/ampps/apache/logs/drupal.fox.err"
CustomLog "C:/ampps/apache/logs/drupal.fox.log" combined
</VirtualHost>
选项跟随符号链接索引
允许超越所有
命令拒绝,允许
通融
ServerName drupal.fox
ServerAlias drupal.fox
ScriptAlias/cgi-bin/“c:/amps/www/drupal.fox/cgi-bin/”
DocumentRoot“c:/amps/www/drupal.fox”
ErrorLog“C:/amps/apache/logs/drupal.fox.err”
CustomLog“C:/amps/apache/logs/drupal.fox.log”组合
当然,您必须创建新的虚拟主机条目,其IP等于主机文件中的IP。@NishantSolanki-如果您不需要多个虚拟主机,为什么还要虚拟主机呢?虚拟主机的全部意义在于在一台服务器上支持多个网站@昆汀嘿对不起,我只是误解了,我以为她想在她的本地pc上创建虚拟服务器…:P@Vaidehi.. 您好,您是否取消了
Include conf/extra/httpd vhosts.conf
您的httpd.conf
文件中这一行的注释??请参考此链接您可以使用httpd-S
验证虚拟配置语法请选择一个答案当您拥有唯一的域名时,为什么需要不同的ip地址?我只是觉得使用另一层来区分它们更清楚,因为在一些本地测试中,我们可能需要从不同的URL访问相同的web应用,因此,在本例中,我可以以drupal.fox或127.0.0.100访问它