我正在运行Windows 7 Pro上的XAMPP。我想设置虚拟主机,这样当我使用“dev.app”作为域名时,我可以直接进入我的Laravel安装的公共文件夹。
Laravel位于F:/xampp/htdocs/dev/public。
我打开了位于F:\xamp\apache\conf\extra\https-vhosts.conf的httpd-vhosts.conf文件,并用以下内容替换了所有内容。
然而,当我在浏览器中打开dev.app时,出现了以下错误。
Laravel位于F:/xampp/htdocs/dev/public。
我打开了位于F:\xamp\apache\conf\extra\https-vhosts.conf的httpd-vhosts.conf文件,并用以下内容替换了所有内容。
# Virtual Hosts
#
# Required modules: mod_log_config
# 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.4/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 localhost>
DocumentRoot "F:/xampp/htdocs/"
ServerAdmin admin@localhost
<Directory "F:/xampp/htdocs/">
Options Indexes FollowSymLinks
AllowOverride all
</Directory>
</VirtualHost>
# Development
<VirtualHost dev.app>
DocumentRoot "F:/xampp/htdocs/dev/public"
ServerAdmin admin@localhost
<Directory "F:/xampp/htdocs/dev/public">
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
然后我打开了位于C:\ Windows \ System32 \ drivers \ etc
的hosts文件,并将localhost行更改为以下内容
127.0.0.1 localhost dev.app
127.0.0.1 127.0.0.1
然而,当我在浏览器中打开dev.app时,出现了以下错误。
Unable to connect
Firefox can't establish a connection to the server at app.dev.
The site could be temporarily unavailable or too busy. Try again in a few moments. If you are unable to load any pages, check your computer's network connection. If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.
我在这里错过了什么?
我做错了什么?
注意:在更改虚拟主机文件后,我重启了Apache。另外,我更新了Laravel配置文件夹中的app.php文件,使url值为http://dev.app
。
已更新:在添加了http://...
后,网站能够被访问,但图片无法显示。
http://...
才能使其正常工作。另外,在更新任何 Apache 配置文件后,确保重新启动 Web 服务器以使更改生效。 - user1669496