我正在我的计算机上本地开发一个Wordpress网站。我有两个Wordpress安装,一个在 C:\ xampp \ htdocs \ wordpress 内,另一个在 C:\ My_Sites \ medicalproject \ wordpress
我已安装XAMPP,我通过输入 localhost / wordpress 来访问第一个安装。第二天,我创建了一个名为 medicalproject 的虚拟主机,为了访问它,我只需打开浏览器并输入 medicalproject 。
一切顺利,直到我尝试为测试目的创建另一台主机。我看到它没有工作所以我删除了新的虚拟主机,只留下了 medicalproject 一个。但问题没有解决。会发生什么是浏览器(FF,IE,Chrome,Opera)无法识别 medicalproject 并运行谷歌搜索。 Apache正常启动,我可以访问 localhost 和 localhost / wordpress ,这是第一次安装。
我提到当我尝试添加第二个虚拟主机时,Avira Free Antivirus阻止访问主机文件,您必须为本地主机添加环回IP(127.0.0.1和服务器名称)。我禁用了这个功能,重新启动了几次并尝试但没有运气。
以下是我的httpd-vhosts.conf的样子。我提到这个确切的配置在以前工作。
## Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
##<VirtualHost *:80>
##ServerAdmin postmaster@dummy-host.localhost
##DocumentRoot "C:/xampp/htdocs/dummy-host.localhost"
##ServerName dummy-host.localhost
##ServerAlias www.dummy-host.localhost
##ErrorLog "logs/dummy-host.localhost-error.log"
##CustomLog "logs/dummy-host.localhost-access.log" combined
##</VirtualHost>
##<VirtualHost *:80>
##ServerAdmin postmaster@dummy-host2.localhost
##DocumentRoot "C:/xampp/htdocs/dummy-host2.localhost"
##ServerName dummy-host2.localhost
##ServerAlias www.dummy-host2.localhost
##ErrorLog "logs/dummy-host2.localhost-error.log"
##CustomLog "logs/dummy-host2.localhost-access.log" combined
##</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
Servername localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:\My_Sites\medicalproject\wordpress"
ServerName medicalproject
ErrorLog "C:\My_Sites\medicalproject\medicalproject.error.log"
CustomLog "C:\My_Sites\medicalproject\medicalproject.access.log" combined
<Directory "C:\My_Sites\medicalproject\wordpress">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>