全新安装Laravel 5.1并获取服务器500

时间:2016-02-25 21:41:35

标签: apache install laravel-5.1

我通过/ storage和/ bootstrap / cache的composer set premissions安装Laravel 5.1,并在sites-enable / project.conf中创建vhost:

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    ServerName www.sklad.dev

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/sklad/public

    <Directory /var/www/html/sklad/public>
        AllowOverride All
        Order allow,deny
        Allow from all
        # New directive needed in Apache 2.4.3: 
        Require all granted
    </Directory>


    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

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

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>


# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
在/public/.htaccess中我有:

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

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

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

我在apache2上启用了revrite mod并重新启动apache.But我仍然找不到服务器500.你有什么想法可能有什么不对吗?而来自apache的日志是:

[Thu Feb 25 23:14:44.838725 2016] [:error] [pid 2505] [client 127.0.0.1:37241] PHP Fatal error:  Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/var/www/html/sklad/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied' in /var/www/html/sklad/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:87\nStack trace:\n#0 /var/www/html/sklad/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\\Handler\\StreamHandler->write(Array)\n#1 /var/www/html/sklad/vendor/monolog/monolog/src/Monolog/Logger.php(289): Monolog\\Handler\\AbstractProcessingHandler->handle(Array)\n#2 /var/www/html/sklad/vendor/monolog/monolog/src/Monolog/Logger.php(565): Monolog\\Logger->addRecord(400, Object(Symfony\\Component\\Debug\\Exception\\FatalErrorException), Array)\n#3 /var/www/html/sklad/vendor/laravel/framework/src/Illuminate/Log/Writer.php(202): Monolog\\Logger->error(Object(Symfony\\Component\\Debug\\Exception\\FatalErrorException), Array)\n#4 /var/www/html/sklad/vendor/laravel/framework/src/Illuminate/Log/Writer.php(113): Illuminate\\Log\\Writer- in /var/www/html/sklad/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 87

1 个答案:

答案 0 :(得分:2)

您尚未为/storage设置权限。它试图向日志写入错误,但没有创建或写入日志的权限。

要更改此功能,请确保以递归方式设置权限:

sudo chmod -R 777 /storage

设置777的权限可能会带来风险,因此请使用您认为合适的权限级别,可能是775,因为这会让Laravel读取和写入日志文件。

您可能需要重新检查对其他文件夹的所有权限,以确保以递归方式设置它们。