我在Mac(高山脉)上配置了Apache,SQL和PHPMyAdmin。一切工作正常,除了出于某种原因我似乎无法使用我的虚拟主机地址。
以下是我为使用vhost编辑的代码行:
/private/etc/apache2/extra/httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Users/username/Sites/
</VirtualHost>
# http://localhost/ethospractice.cms.com/web/
<VirtualHost *:80>
DocumentRoot /Users/username/Sites/ethospractice.cms.com/web/
ServerName craft3.ethospractice.test
DirectoryIndex index.php
<Directory "/Users/username/Sites/ethospractice.cms.com/web/">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
我在/private/etc/apache2/httpd.conf上未输入以下行
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf
并更改de RootDirectory以为我的Sites文件夹提供服务,如下所示:
DocumentRoot "/Users/username/Sites"
<Directory "/Users/username/Sites">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options FollowSymLinks Multiviews
MultiviewsMatch Any
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
然后将其添加到主机文件中
127.0.0.1 localhost
127.0.0.1 craft3.ethospractice.test
当我进入craft3.ethospractice.test时,它说无法访问该站点。 但是,如果我手动转到为该主机指定的DocumentRoot(http://localhost/ethospractice.cms.com/web/)目录,则可以正常使用该站点。 我的本地主机工作正常。如果我转到本地主机,它将提供我的站点文件夹。
所以我不知道为什么我的虚拟主机配置无法正常工作。我已经上网了两天,还没有找到解决办法。
答案 0 :(得分:0)
为此,您必须遵循三个步骤。
<VirtualHost *:80>
ServerName craft3.ethospractice.test
DocumentRoot "C:/xamppneww/htdocs/craft_home/craft_revision/web"
SetEnv APPLICATION_ENV "development"
<Directory "C:/xamppneww/htdocs/craft_home/craft_revision/web">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
#127.0.0.1 localhost
127.0.0.1 craft3.ethospractice.test
仅此而已。您无需执行任何其他操作。如果你仍然没有得到,那么它一定是 xampp 设置或配置相关的问题。