Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
865 views
in Technique[技术] by (71.8m points)

apache - WAMP Virtualhost not working with Laravel instance

I'm working on a Laravel project locally using WAMP 3.1.0 and everything was working correctly until there was a windows update today.

When I go to my project I get an error page
enter image description here

I followed this post WAMP Virtual Host not working but that didn't solve my problem.
I've edited my C:WindowsSystem32driversetchosts file in admin mode which looks like this:

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

I've also edited my C:wamp64inapacheapache2.4.27confextrahttpd-vhosts.conf file which looks like this:

# 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>

When I visit my page like this http://localhost/test/public/order/23456 my page loads but when I try http://test.dev/order/23456 it doesn't.

I'm using apache 2.4.27

Can anyone tell me what's going on?

Also, this is my C:wamp64inapacheapache2.4.27confhttpd.conf file :

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/*"
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The first thing you should know is that the .dev tLD is now a real tLD and has been bought by Google. So as of Chrome 63 (out since December 2017), Chrome itself will force all domains ending on .dev (and .foo) to be redirected to HTTPS via a preloaded HTTP Strict Transport Security (HSTS) header.

So we should all stop using .dev and use something else, suggestions are to use .localhost or .test.

A simple test for this would be to try using FireFox or IE instead of Chrome to access your current configured site. If it runs in another browser, some of your problem is related to the Chrome changes that redirect .dev domains automatically.

Secondly, your Virtual Host definitions are not good. For some time now in WAMPServer there has been a tool provided within WAMPServer to help you create Virtual Hosts easily and correctly. Look at the WAMPSever homepage under the Tools menu for a link called Add Virtual Host (see below).

enter image description here

All you need to do is first create the folder that you want the site to live in before running the "Add Virtual Host" tool.

I suggest you revert your httpd-vhosts.conf file back to its initial state which contains only a definition for 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>

And then using the "Add Virtual Host" menu, create your Virtual Hosts again, but this time using paycafe.localhost for example.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...