Xampp 上的 Laravel 虚拟主机无法正常工作 在虚拟主机定义中在 apache2.conf 中

我想在 XAMPP 上使用虚拟主机加载我的 Laravel 5.8 项目。所以这就是我所做的:

我打开 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,我添加了这个:

<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

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

但是现在当我想在浏览器上运行 local.nanoclub.ir 时,我得到了这个:

Xampp 上的 Laravel 虚拟主机无法正常工作
      
    在虚拟主机定义中在 apache2.conf 中

所以这里出了什么问题?我以前可以正确访问此 local.nanoclub.ir,但现在它会加载此屏幕。

如何解决这个问题?

zsdzjwx 回答:Xampp 上的 Laravel 虚拟主机无法正常工作 在虚拟主机定义中在 apache2.conf 中

您需要授予对该目录的访问权限。

您可以在您的虚拟主机定义或 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。

本文链接:https://www.f2er.com/25327.html

大家都在问