我在Windows 7 Pro上运行XAMPP。我正在尝试设置一个虚拟主机,这样当我使用“dev.app“作为域时,我就可以直接进入laravel安装的公共文件夹。
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
的主机文件,并将localhost行更改为如下所示
127.0.0.1 localhost dev.app
127.0.0.1 127.0.0.1
但是,当我dev.app在浏览器中转到www.example.com时,出现此错误
无法联机
Firefox无法在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.
我错过了什么?我做错了什么?
**注意:**我在更改vhosts文件后重新启动了Apache。另外,我更新了laravel的config文件夹中的app.php文件,使url中有http://dev.app
值。
已更新在添加http://....后,网站已解决,但图像未显示。
2条答案
按热度按时间3zwjbxry1#
hosts文件应如下所示,以便可以在IPV4和IPV6网络上找到它
如果您使用的是Apache 2.4.x,则httpd-vhosts.conf中的此行
Apache 2.4不再需要或允许。
vhost文件应该如下所示,您混合了Apache 2.2和2.4语法,虽然只要激活了
mod_access_compat
,就允许使用其中任何一种语法,但不应该混合它们,2.4语法更好。3xiyfsfu2#