我真的很感激我一整天都在努力解决一个问题......我使用WAMP在本地安装了WordPress,一切正常。我在C:/ wamp / www中创建了一个文件夹,命名为wordpress。 我只能通过在浏览器的URL上输入localhost来访问localhost,当我决定安装另一个wordpress网站我遇到问题时,我访问了输入localhost / wordpress / BUT的网站。我在www中创建了第二个文件夹,命名为joanaweb,并按照本教程的步骤进行操作:http://www.marolinedesign.com/tutorials/how-to-install-more-than-one-wordpress-site-on-your-local-wamp-server/我删除了位于httpd.conf上的Include conf / extra / httpd-vhosts.conf之前的#,其中没有'在教程中提到。 在此之后,第一个网站像以前一样被访问,而第二个网站通过键入joanaweb ....但我不能再访问localhost :(我只得到403错误。在这个网站http://www.apptools.com/phptools/virtualhost.php结束时这篇文章我找到了一个解决方案,但它并不适合我:/他们建议使用:
<VirtualHost 127.0.0.1>
DocumentRoot C:\Apache\htdocs
ServerName localhost
</VirtualHost>
由于我的htdocs位于另一个文件夹上,我在httpd-vhosts.conf上使用了这段代码
<VirtualHost *:80>
DocumentRoot "C:/wamp/bin/apache/apache2.4.9/htdocs/"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/localhost.log"
CustomLog "logs/localhost.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/joanaweb"
ServerName joanaweb
ServerAlias joanaweb
ErrorLog "logs/joanaweb.log"
CustomLog "logs/joanaweb.log" common
</VirtualHost>
我做错了什么?
这也是我的hosts文件中的所有代码(在评论之后):
127.0.0.1 localhost
::1 localhost
127.0.0.1 localhost
127.0.0.1 localhost
127.0.0.1 localhost localhost
127.0.0.1 localhost wordpress
127.0.0.1 localhost joanaweb
127.0.0.1 localhost lifestylepro
127.0.0.1 localhost xxxxxTranslations
这是httpd-vhosts.conf中的代码:
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "c:/Apache24/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "C:/wamp/www">
AllowOverride All
<IfDefine APACHE24>
Require local
</IfDefine>
<IfDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
</IfDefine>
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/wordpress"
ServerName wordpress
ServerAlias wordpress
<Directory "C:/wamp/www/wordpress">
AllowOverride All
<IfDefine APACHE24>
Require local
</IfDefine>
<IfDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
</IfDefine>
</Directory>
ErrorLog "logs/wordpress.log"
CustomLog "logs/wordpress.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/joanaweb"
ServerName joanaweb
ServerAlias joanaweb
<Directory "C:/wamp/www/joanaweb">
AllowOverride All
<IfDefine APACHE24>
Require local
</IfDefine>
<IfDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
</IfDefine>
</Directory>
ErrorLog "logs/joanaweb.log"
CustomLog "logs/joanaweb.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/lifestylepro"
ServerName lifestylepro
ServerAlias lifestylepro
<Directory "C:/wamp/www/lifestylepro">
AllowOverride All
<IfDefine APACHE24>
Require local
</IfDefine>
<IfDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
</IfDefine>
</Directory>
ErrorLog "logs/lifestylepro.log"
CustomLog "logs/lifestylepro.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/xxxxxTranslations"
ServerName xxxxxTranslations
ServerAlias www.xxxxxTranslations
<Directory "C:/wamp/www/xxxxxTranslations">
AllowOverride All
<IfDefine APACHE24>
Require local
</IfDefine>
<IfDefine !APACHE24>
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
</IfDefine>
</Directory>
ErrorLog "logs/xxxxxTranslations.log"
CustomLog "logs/xxxxxTranslations.log" common
</VirtualHost>
答案 0 :(得分:0)
好的,首先摆脱httpd-vhosts.conf
的这两个部分,这两个部分正是Apache作为示例代码发布的内容,与WAMPServer无关,因为它们指向WAMPServer未使用的位置。
所以删除这两个定义
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "c:/Apache24/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
然后我们来到您的虚拟主机定义,因为您正在使用Apache v2.4.x我将删除Apache版本检查,并使用Apache 2.4语法使其更容易理解。
# Should be the first VHOST definition so that it is the default virtual host
# Also access rights should remain restricted to the local PC and the local network
# So that any random ip address attack will recieve an error code and not gain access
<VirtualHost *:80>
DocumentRoot "C:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "C:/wamp/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/wordpress"
ServerName wordpress
ServerAlias wordpress
<Directory "C:/wamp/www/wordpress">
AllowOverride All
Require local
</Directory>
ErrorLog "logs/wordpress.log"
CustomLog "logs/wordpress.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/joanaweb"
ServerName joanaweb
ServerAlias joanaweb
<Directory "C:/wamp/www/joanaweb">
AllowOverride All
Require local
</Directory>
ErrorLog "logs/joanaweb.log"
CustomLog "logs/joanaweb.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/lifestylepro"
ServerName lifestylepro
ServerAlias lifestylepro
<Directory "C:/wamp/www/lifestylepro">
AllowOverride All
Require local
</Directory>
ErrorLog "logs/lifestylepro.log"
CustomLog "logs/lifestylepro.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/xxxxxTranslations"
ServerName xxxxxTranslations
ServerAlias www.xxxxxTranslations
<Directory "C:/wamp/www/xxxxxTranslations">
AllowOverride All
Require local
</Directory>
ErrorLog "logs/xxxxxTranslations.log"
CustomLog "logs/xxxxxTranslations.log" common
</VirtualHost>
现在有HOSTS文件。这需要包括IPC4的IP地址,即127.0.0.1 和IPV6的IP地址,即:: 1
因此,将您的HOSTS文件更改为此,删除不必要的重复并添加IPV6引用: -
127.0.0.1 localhost
127.0.0.1 wordpress
127.0.0.1 joanaweb
127.0.0.1 lifestylepro
127.0.0.1 xxxxxTranslations
::1 localhost
::1 wordpress
::1 joanaweb
::1 lifestylepro
::1 xxxxxTranslations
现在要确保将这些文件加载到dnscache中,使用“以管理员身份运行”选项启动命令窗口并运行这两个命令。
或者,只需重新启动,即可使这些当前。
net stop dnscache
net start dnscache
现在重新启动Apache,然后选择这些更改,并尝试使用虚拟主机。