Xampp 上的 Laravel 虚拟主机无法正常工作 [英] Laravel virtual host on Xampp does not work properly
问题描述
我想在 XAMPP 上使用虚拟主机加载我的 Laravel 5.8 项目.所以这就是我所做的:
I want to load my Laravel 5.8 project with Virtual Host on XAMPP. So here is what I did:
我打开了 C:\Windows\System32\drivers\etc\hosts
并输入:
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 local.nanoclub.ir
然后在C:\xampp\apache\conf\extra\httpd-vhosts.conf
,我添加了这个:
Then at C:\xampp\apache\conf\extra\httpd-vhosts.conf
, I added this:
<VirtualHost local.nanoclub.ir:80>
DocumentRoot "C:/xampp/htdocs/badges/public"
ServerName local.nanoclub.ir
ServerAlias *.local.nanoclub.ir
SetEnv APPLICATION_ENV "development"
<Directory "C:/xampp/htdocs/badges/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
并将其添加到我的项目中,public .htaccess
:
And also added this to my project, public .htaccess
:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
但是现在当我想在浏览器上运行 local.nanoclub.ir
时,我得到了这个:
But now when I want to run local.nanoclub.ir
on browser, I get this:
所以这里出了什么问题?我曾经正确访问这个 local.nanoclub.ir
但现在它加载了这个屏幕.
So what's going wrong here? I used to access this local.nanoclub.ir
correctly but now it loads this screen.
如何解决这个问题?
推荐答案
您需要授予对该目录的访问权限.
You need to grant access to this directory.
您可以在您的虚拟主机定义或 apache2.conf 中授予此访问权限
You can grant this access in your virtual host definition or in the apache2.conf
<VirtualHost local.nanoclub.ir:80>
DocumentRoot "C:/xampp/htdocs/badges/public"
ServerName local.nanoclub.ir
ServerAlias *.local.nanoclub.ir
SetEnv APPLICATION_ENV "development"
<Directory "C:/xampp/htdocs/badges/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
# The missing one
Require all granted
</Directory>
</VirtualHost>
在 apache2.conf 中
<Directory C:/xampp/htdocs/badges/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
注意:更改配置后不要忘记重启apache.
Notice: Don't forget to restart apache after changing configuration.
这篇关于Xampp 上的 Laravel 虚拟主机无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!