laravel 项目未加载 css 使用 apache artisan serve 工作正常

laravel project not loading css with apache artisan serve working fine

我创建了一个 Laravel 项目,我之前使用 apache2 部署了它,并且运行良好。

当我完成我的最新部署时,我发现在我完成时没有加载外部 CSS。所以我多次检查了所有步骤,但我认为我没有遗漏任何东西。

然而,运行 php artisan serve 一切正常。

这是我的 virtual_host 配置文件:

<VirtualHost *:80>
    ServerAdmin admin@project
    DocumentRoot /var/www/html/project/public/index.php
    ServerName example.com
    ServerAlias www.example.com
    DirectoryIndex index.php

    <Directory /var/www/html/project/public>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

在虚拟主机配置中,您应该尝试使用

<VirtualHost *:80>
    ServerAdmin admin@project
    DocumentRoot /var/www/html/project/public
    ServerName example.com
    ServerAlias www.example.com
    DirectoryIndex index.php

    <Directory /var/www/html/project/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<Directory> 中删除 public 文件夹,同时从 DocumentRoot 中删除 index.php