WAMP 虚拟主机无法与 Laravel 实例一起使用
WAMP Virtualhost not working with Laravel instance
我正在使用 WAMP 3.1.0 在本地开发一个 Laravel 项目,在今天 windows 更新之前一切正常。
当我进入我的项目时,我收到一个错误页面
我遵循了这个 post WAMP Virtual Host not working 但这并没有解决我的问题。
我在管理员模式下编辑了我的 C:\Windows\System32\drivers\etc\hosts 文件,如下所示:
127.0.0.1 localhost
::1 localhost
127.0.0.1 test.dev
::1 test.dev
127.0.0.1 shoppingcart.dev
::1 shoppingcart.dev
127.0.0.1 gitproject.dev
::1 gitproject.dev
我还编辑了我的 C:\wamp64\bin\apache\apache2.4.27\conf\extra\httpd-vhosts.conf 文件,如下所示:
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
DocumentRoot "${INSTALL_DIR}/www"
</VirtualHost>
<VirtualHost *:80>
ServerName test.dev
#ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www/test/public"
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
<Directory "${INSTALL_DIR}/www/test/public">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName shoppingcart.dev
#ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www/shoppingcart/public"
#<Directory "${INSTALL_DIR}/www/">
# Options +Indexes +Includes +FollowSymLinks +MultiViews
# AllowOverride All
# Require local
#</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName gitproject.dev
#ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www/git_project/public"
#<Directory "${INSTALL_DIR}/www/">
# Options +Indexes +Includes +FollowSymLinks +MultiViews
# AllowOverride All
# Require local
#</Directory>
</VirtualHost>
当我像这样访问我的页面时 http://localhost/test/public/order/23456 my page loads but when I try http://test.dev/order/23456 它没有。
我正在使用 apache 2.4.27
谁能告诉我这是怎么回事?
此外,这是我的 C:\wamp64\bin\apache\apache2.4.27\conf\httpd.conf 文件:
ServerSignature On
ServerTokens Full
Define APACHE24 Apache2.4
Define VERSION_APACHE 2.4.27
Define INSTALL_DIR c:/wamp64
Define APACHE_DIR ${INSTALL_DIR}/bin/apache/apache${VERSION_APACHE}
ServerRoot "${APACHE_DIR}"
Listen 0.0.0.0:80
Listen [::0]:80
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule allowmethods_module modules/mod_allowmethods.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cache_module modules/mod_cache.so
LoadModule cache_disk_module modules/mod_cache_disk.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule file_cache_module modules/mod_file_cache.so
LoadModule include_module modules/mod_include.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule php5_module "${INSTALL_DIR}/bin/php/php5.6.31/php5apache2_4.dll"
<IfModule unixd_module>
User daemon
Group daemon
</IfModule>
ServerAdmin wampserver@wampserver.invalid
ServerName localhost:80
<Directory />
AllowOverride none
Require all denied
</Directory>
HostnameLookups Off
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +FollowSymLinks +Multiviews
AllowOverride all
Require local
</Directory>
<IfModule dir_module>
DirectoryIndex index.php index.php3 index.html index.htm
</IfModule>
<Files ".ht*">
Require all denied
</Files>
ErrorLog "${INSTALL_DIR}/logs/apache_error.log"
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "${INSTALL_DIR}/logs/access.log" common
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "${INSTALL_DIR}/cgi-bin/"
</IfModule>
<IfModule cgid_module>
</IfModule>
<Directory "${INSTALL_DIR}/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule headers_module>
RequestHeader unset Proxy early
</IfModule>
<IfModule mime_module>
TypesConfig conf/mime.types
AddEncoding x-compress .Z
AddEncoding x-gzip .gz .tgz
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
</IfModule>
EnableSendfile off
AcceptFilter http none
AcceptFilter https none
Include conf/extra/httpd-autoindex.conf
Include conf/extra/httpd-vhosts.conf
<IfModule proxy_html_module>
Include conf/extra/proxy-html.conf
</IfModule>
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
Include "${INSTALL_DIR}/alias/*"
您应该知道的第一件事是 .dev
顶级域名现在是一个真正的顶级域名并且已经被 Google 购买。因此,从 Chrome 63(自 2017 年 12 月起)开始,Chrome 本身将强制所有以 .dev
(和 .foo
)结尾的域通过预加载的 HTTP 重定向到 HTTPS严格的传输安全 (HSTS) header.
所以我们都应该停止使用.dev
并使用其他东西,建议使用.localhost
或.test
。
对此的一个简单测试是尝试使用 FireFox 或 IE 而不是 Chrome 来访问您当前配置的站点。如果它在另一个浏览器中运行,则您的某些问题与自动重定向 .dev
域的 Chrome 更改有关。
其次,您的虚拟主机定义不好。一段时间以来,在 WAMPServer 中,WAMPServer 中提供了一个工具来帮助您轻松正确地创建虚拟主机。查看 Tools 菜单下的 WAMPSever 主页,找到名为 Add Virtual Host 的 link(见下文)。
您需要做的就是 首先 在 运行 "Add Virtual Host" 工具之前创建您希望站点所在的文件夹。
我建议您将 httpd-vhosts.conf
文件恢复到初始状态,其中仅包含 localhost
的定义
#
# Virtual Hosts
#
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
然后使用 "Add Virtual Host" 菜单再次创建您的虚拟主机,但这次使用 paycafe.localhost
例如。
我正在使用 WAMP 3.1.0 在本地开发一个 Laravel 项目,在今天 windows 更新之前一切正常。
当我进入我的项目时,我收到一个错误页面
我遵循了这个 post WAMP Virtual Host not working 但这并没有解决我的问题。
我在管理员模式下编辑了我的 C:\Windows\System32\drivers\etc\hosts 文件,如下所示:
127.0.0.1 localhost
::1 localhost
127.0.0.1 test.dev
::1 test.dev
127.0.0.1 shoppingcart.dev
::1 shoppingcart.dev
127.0.0.1 gitproject.dev
::1 gitproject.dev
我还编辑了我的 C:\wamp64\bin\apache\apache2.4.27\conf\extra\httpd-vhosts.conf 文件,如下所示:
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
DocumentRoot "${INSTALL_DIR}/www"
</VirtualHost>
<VirtualHost *:80>
ServerName test.dev
#ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www/test/public"
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
<Directory "${INSTALL_DIR}/www/test/public">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName shoppingcart.dev
#ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www/shoppingcart/public"
#<Directory "${INSTALL_DIR}/www/">
# Options +Indexes +Includes +FollowSymLinks +MultiViews
# AllowOverride All
# Require local
#</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName gitproject.dev
#ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www/git_project/public"
#<Directory "${INSTALL_DIR}/www/">
# Options +Indexes +Includes +FollowSymLinks +MultiViews
# AllowOverride All
# Require local
#</Directory>
</VirtualHost>
当我像这样访问我的页面时 http://localhost/test/public/order/23456 my page loads but when I try http://test.dev/order/23456 它没有。
我正在使用 apache 2.4.27
谁能告诉我这是怎么回事?
此外,这是我的 C:\wamp64\bin\apache\apache2.4.27\conf\httpd.conf 文件:
ServerSignature On
ServerTokens Full
Define APACHE24 Apache2.4
Define VERSION_APACHE 2.4.27
Define INSTALL_DIR c:/wamp64
Define APACHE_DIR ${INSTALL_DIR}/bin/apache/apache${VERSION_APACHE}
ServerRoot "${APACHE_DIR}"
Listen 0.0.0.0:80
Listen [::0]:80
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule allowmethods_module modules/mod_allowmethods.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cache_module modules/mod_cache.so
LoadModule cache_disk_module modules/mod_cache_disk.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule file_cache_module modules/mod_file_cache.so
LoadModule include_module modules/mod_include.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule php5_module "${INSTALL_DIR}/bin/php/php5.6.31/php5apache2_4.dll"
<IfModule unixd_module>
User daemon
Group daemon
</IfModule>
ServerAdmin wampserver@wampserver.invalid
ServerName localhost:80
<Directory />
AllowOverride none
Require all denied
</Directory>
HostnameLookups Off
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +FollowSymLinks +Multiviews
AllowOverride all
Require local
</Directory>
<IfModule dir_module>
DirectoryIndex index.php index.php3 index.html index.htm
</IfModule>
<Files ".ht*">
Require all denied
</Files>
ErrorLog "${INSTALL_DIR}/logs/apache_error.log"
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "${INSTALL_DIR}/logs/access.log" common
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "${INSTALL_DIR}/cgi-bin/"
</IfModule>
<IfModule cgid_module>
</IfModule>
<Directory "${INSTALL_DIR}/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule headers_module>
RequestHeader unset Proxy early
</IfModule>
<IfModule mime_module>
TypesConfig conf/mime.types
AddEncoding x-compress .Z
AddEncoding x-gzip .gz .tgz
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
</IfModule>
EnableSendfile off
AcceptFilter http none
AcceptFilter https none
Include conf/extra/httpd-autoindex.conf
Include conf/extra/httpd-vhosts.conf
<IfModule proxy_html_module>
Include conf/extra/proxy-html.conf
</IfModule>
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
Include "${INSTALL_DIR}/alias/*"
您应该知道的第一件事是 .dev
顶级域名现在是一个真正的顶级域名并且已经被 Google 购买。因此,从 Chrome 63(自 2017 年 12 月起)开始,Chrome 本身将强制所有以 .dev
(和 .foo
)结尾的域通过预加载的 HTTP 重定向到 HTTPS严格的传输安全 (HSTS) header.
所以我们都应该停止使用.dev
并使用其他东西,建议使用.localhost
或.test
。
对此的一个简单测试是尝试使用 FireFox 或 IE 而不是 Chrome 来访问您当前配置的站点。如果它在另一个浏览器中运行,则您的某些问题与自动重定向 .dev
域的 Chrome 更改有关。
其次,您的虚拟主机定义不好。一段时间以来,在 WAMPServer 中,WAMPServer 中提供了一个工具来帮助您轻松正确地创建虚拟主机。查看 Tools 菜单下的 WAMPSever 主页,找到名为 Add Virtual Host 的 link(见下文)。
您需要做的就是 首先 在 运行 "Add Virtual Host" 工具之前创建您希望站点所在的文件夹。
我建议您将 httpd-vhosts.conf
文件恢复到初始状态,其中仅包含 localhost
#
# Virtual Hosts
#
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
然后使用 "Add Virtual Host" 菜单再次创建您的虚拟主机,但这次使用 paycafe.localhost
例如。