【问题标题】:Laravel 5.4 doesn't access the css in live serverLaravel 5.4 无法访问实时服务器中的 css
【发布时间】:2017-09-15 11:35:27
【问题描述】:

我在实时服务器中的应用程序无法访问styles.css,但可以在本地服务器上运行。下图是应用在本地服务器的截图。

但以下图片来自实时服务器。它不显示 jumbotron 背景图像。

我已将 Laravel 根文件夹中的 server.php 文件重命名为 index.php。并将公用文件夹.htaccess添加到根文件夹。

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

public文件夹权限如下。

和我的存储文件夹权限如下。

当我查看 apache 错误日志时,我可以看到以下错误。

Tue Apr 18 22:19:57.092337 2017] [autoindex:error] [pid 1664] [client 162.243.22.209:50174] AH01276: Cannot serve directory /home/admin/web/9url.cf/public_html/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive
[Tue Apr 18 22:22:06.708959 2017] [autoindex:error] [pid 1667] [client 162.243.22.209:50190] AH01276: Cannot serve directory /home/admin/web/9url.cf/public_html/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive
[Tue Apr 18 22:23:13.421368 2017] [:error] [pid 2449] [client 162.243.22.209:50192] PHP Fatal error:  Uncaught UnexpectedValueException: The stream or file "/home/admin/web/9url.cf/public_html/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /home/admin/web/9url.cf/public_html/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107\nStack trace:\n#0 /home/admin/web/9url.cf/public_html/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\\Handler\\StreamHandler->write(Array)\n#1 /home/admin/web/9url.cf/public_html/vendor/monolog/monolog/src/Monolog/Logger.php(337): Monolog\\Handler\\AbstractProcessingHandler->handle(Array)\n#2 /home/admin/web/9url.cf/public_html/vendor/monolog/monolog/src/Monolog/Logger.php(616): Monolog\\Logger->addRecord(400, Object(UnexpectedValueException), Array)\n#3 /home/admin/web/9url.cf/public_html/vendor/laravel/framework/src/Illuminate/Log/Writer.php(203): Monolog\\Logger->error(Object(UnexpectedValueException), Array)\n#4 /home/admin/web/9url.cf/public_html/vendor/laravel/framework/src/Illuminate/Log/Writer.php in /home/admin/web/9url.cf/public_html/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107
[Tue Apr 18 22:23:13.422505 2017] [:error] [pid 2449] [client 162.243.22.209:50192] PHP Fatal error:  Uncaught UnexpectedValueException: The stream or file "/home/admin/web/9url.cf/public_html/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /home/admin/web/9url.cf/public_html/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107\nStack trace:\n#0 /home/admin/web/9url.cf/public_html/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\\Handler\\StreamHandler->write(Array)\n#1 /home/admin/web/9url.cf/public_html/vendor/monolog/monolog/src/Monolog/Logger.php(337): Monolog\\Handler\\AbstractProcessingHandler->handle(Array)\n#2 /home/admin/web/9url.cf/public_html/vendor/monolog/monolog/src/Monolog/Logger.php(616): Monolog\\Logger->addRecord(400, Object(Symfony\\Component\\Debug\\Exception\\FatalErrorException), Array)\n#3 /home/admin/web/9url.cf/public_html/vendor/laravel/framework/src/Illuminate/Log/Writer.php(203): Monolog\\Logger->error(Object(Symfony\\Component\\Debug\\Exception\\FatalErrorException), Array)\n#4 /home/admin/web/9url.cf/public_h in /home/admin/web/9url.cf/public_html/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107
[Tue Apr 18 22:25:14.356282 2017] [autoindex:error] [pid 1665] [client 162.243.22.209:50200] AH01276: Cannot serve directory /home/admin/web/9url.cf/public_html/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive
[Tue Apr 18 22:25:18.269469 2017] [autoindex:error] [pid 1666] [client 162.243.22.209:50202] AH01276: Cannot serve directory /home/admin/web/9url.cf/public_html/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive
[Tue Apr 18 22:27:07.872258 2017] [autoindex:error] [pid 1668] [client 162.243.22.209:50204] AH01276: Cannot serve directory /home/admin/web/9url.cf/public_html/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive
[Tue Apr 18 22:28:25.159874 2017] [autoindex:error] [pid 1667] [client 162.243.22.209:50206] AH01276: Cannot serve directory /home/admin/web/9url.cf/public_html/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive
[Tue Apr 18 22:32:38.827488 2017] [autoindex:error] [pid 1664] [client 162.243.22.209:50212] AH01276: Cannot serve directory /home/admin/web/9url.cf/public_html/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive
[Tue Apr 18 22:32:49.900769 2017] [autoindex:error] [pid 1665] [client 162.243.22.209:50214] AH01276: Cannot serve directory /home/admin/web/9url.cf/public_html/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive
[Tue Apr 18 22:33:29.070301 2017] [autoindex:error] [pid 1666] [client 162.243.22.209:50216] AH01276: Cannot serve directory /home/admin/web/9url.cf/public_html/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive
[Tue Apr 18 22:33:35.622783 2017] [:error] [pid 1668] [client 162.243.22.209:50218] PHP Fatal error:  Uncaught UnexpectedValueException: The stream or file "/home/admin/web/9url.cf/public_html/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /home/admin/web/9url.cf/public_html/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107\nStack trace:\n#0 /home/admin/web/9url.cf/public_html/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\\Handler\\StreamHandler->write(Array)\n#1 /home/admin/web/9url.cf/public_html/vendor/monolog/monolog/src/Monolog/Logger.php(337): Monolog\\Handler\\AbstractProcessingHandler->handle(Array)\n#2 /home/admin/web/9url.cf/public_html/vendor/monolog/monolog/src/Monolog/Logger.php(616): Monolog\\Logger->addRecord(400, Object(UnexpectedValueException), Array)\n#3 /home/admin/web/9url.cf/public_html/vendor/laravel/framework/src/Illuminate/Log/Writer.php(203): Monolog\\Logger->error(Object(UnexpectedValueException), Array)\n#4 /home/admin/web/9url.cf/public_html/vendor/laravel/framework/src/Illuminate/Log/Writer.php in /home/admin/web/9url.cf/public_html/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107
[Tue Apr 18 22:33:35.623722 2017] [:error] [pid 1668] [client 162.243.22.209:50218] PHP Fatal error:  Uncaught UnexpectedValueException: The stream or file "/home/admin/web/9url.cf/public_html/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /home/admin/web/9url.cf/public_html/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107\nStack trace:\n#0 /home/admin/web/9url.cf/public_html/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\\Handler\\StreamHandler->write(Array)\n#1 /home/admin/web/9url.cf/public_html/vendor/monolog/monolog/src/Monolog/Logger.php(337): Monolog\\Handler\\AbstractProcessingHandler->handle(Array)\n#2 /home/admin/web/9url.cf/public_html/vendor/monolog/monolog/src/Monolog/Logger.php(616): Monolog\\Logger->addRecord(400, Object(Symfony\\Component\\Debug\\Exception\\FatalErrorException), Array)\n#3 /home/admin/web/9url.cf/public_html/vendor/laravel/framework/src/Illuminate/Log/Writer.php(203): Monolog\\Logger->error(Object(Symfony\\Component\\Debug\\Exception\\FatalErrorException), Array)\n#4 /home/admin/web/9url.cf/public_h in /home/admin/web/9url.cf/public_html/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107
[Tue Apr 18 22:37:41.752617 2017] [autoindex:error] [pid 1665] [client 162.243.22.209:50234] AH01276: Cannot serve directory /home/admin/web/9url.cf/public_html/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive, referer: http://9url.cf/public/

非常感谢任何建议。

谢谢!

【问题讨论】:

  • 您的存储文件夹没有写入权限。
  • @Daan 但是我已经设置了 777 存储文件夹和 laravel.log 文件的权限。
  • 当我访问9url.cf 时,它会显示图像。尝试清空您的缓存,禁用阻止内容的插件等。此外,它应该是“缩短您的 URL”。
  • @SaeedPrez 这是因为作为一种解决方法,我将样式添加为内联样式。非常感谢您显示该错误。这是一个学习 Laravel 的项目。
  • 我不知道该告诉你什么,我访问了你的网站,它工作正常。如果您需要帮助,为什么要解决问题并隐藏问题? Apache 错误基本上是说找不到索引,并且您的选项设置有-Indexes,这会阻止 Apache 生成目录索引。

标签: php css .htaccess laravel-5 laravel-5.4


【解决方案1】:

检查以下内容

1.css url(可能是错误的url)

2.检查.htaccess文件(css是否被阻止)

3.index.php 文件

4.storage/ ---> 权限(chmod 777 -R)

6.将css添加到公共文件夹(我们可以使用每个where项目)

7.apache mod_rewrite 应该启用(http 服务器)

那么肯定会起作用。

【讨论】:

    猜你喜欢
    • 2018-05-17
    • 2017-10-24
    • 2017-10-16
    • 2019-05-12
    • 1970-01-01
    • 2018-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多