【发布时间】:2021-09-27 19:28:23
【问题描述】:
我想用 XAMPP 为我的 Laravel 项目创建一个虚拟主机,所以我按照以下步骤操作:
第 1 步) C:\WINDOWS\system32\drivers\etc\ 打开“hosts”文件(以管理员身份):
127.0.0.1 test.com
第 2 步) xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/freedeliveries/public"
SetEnv APPLICATION_ENV "development"
<Directory "C:/xampp/htdocs/freedeliveries/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ServerName www.test.com
</VirtualHost>
第 3 步) C:\xampp\apache\conf\httpd.conf。向下滚动到末尾的 Supplemental configuration 部分,并找到以下部分(大约第 500 行),从第二行的开头删除了 #,因此该部分现在看起来像这样:
#Virtual hosts
Include conf/extra/httpd-vhosts.conf
第 4 步) 重新启动 XAMPP,现在在我的浏览器中运行它:
www.test.com
但现在我得到了这个结果:
错误无法检索请求的 URL
The following error was encountered while trying to retrieve the URL: http://test.com/
Unable to determine IP address from hostname test.com
The DNS server returned:
Name Error: The domain name does not exist.
This means that the cache was not able to resolve the hostname presented in the URL. Check if the address is correct.
Your cache administrator is root.
那么如何解决这个问题并在虚拟主机名上运行 Laravel 项目?
更新:
【问题讨论】:
-
你的项目是用wordpress或者core php或者laravel开发的?
-
@RakeshkumarOad Laravel 5.8
-
localhost/freedeliveries你的项目是直接用这个url运行的吗?
-
@RakeshkumarOad 我不明白你的问题。我的项目目录位于
xampp\htdocs` and is calledfreedeliveries. Because it's a Laravel project I have to run CMD and typephp artiasn serve` 并在浏览器上转到localhost:8000以加载项目。现在我需要通过在浏览器上说:www.test.com来加载它。 -
我的回答有问题吗?
标签: php mysql sql laravel phpmyadmin