我为nginx创建了这个配置文件来访问我的laravel页面:
server {
listen 80;
listen [::]:80;
root /var/www/mfserver/public;
index index.php index.html index.htm;
server_name dispo.medifaktor.de;
location / {
try_files $uri $uri/ /index.php?is_args$args;
}
error_page 404 /index.php;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/mfserver/public;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
}
当我调用页面dispo.medifaktor.de时,我看到主页面。但是当我拨打http://dispo.medifaktor.de/v1/incidents时,我收到服务器错误500.为什么我无法访问这些页面?
路线文件正在运作:
Route::group(['domain' => 'dispo.medifaktor.de', 'namespace' => 'API'], function() {
Route::group(['prefix' => 'v1', 'namespace' => 'v1'], function() {
// INCIDENTS ROUTES
Route::get('/incidents', 'Incidents\APIIncidentController@index');
Route::post('/incidents', 'Incidents\APIIncidentController@store');
Route::get('/incidents/{incidents}', 'Incidents\APIIncidentController@show');
Route::get('/incidents/{incidents}/responders', 'Incidents\APIIncidentResponderController@index');
});
});
nginx的error.log状态:
2016/05/26 11:22:40 [error] 32590#0: *22 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/var/www/mfserver/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied' in /var/www/mfserver/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:97
Stack trace:
#0 /var/www/mfserver/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\StreamHandler->write(Array)
#1 /var/www/mfserver/vendor/monolog/monolog/src/Monolog/Logger.php(336): Monolog\Handler\AbstractProcessingHandler->handle(Array)
#2 /var/www/mfserver/vendor/monolog/monolog/src/Monolog/Logger.php(615): Monolog\Logger->addRecord(400, Object(UnexpectedValueException), Array)
#3 /var/www/mfserver/vendor/laravel/framework/src/Illuminate/Log/Writer.php(202): Monolog\Logger->error(Object(UnexpectedValueException), Array)
#4 /var/www/mfserver/vendor/laravel/framework/src/Illuminate/Log/Writer.php(113): Illuminate\Log\Writer->writeLog('error', Object(UnexpectedV...
PHP message: PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/var/www/mfserver/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied' in /var/www/mfserver/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:97
Stack trace:
#0 /var/www/mfserver/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\StreamHandler->write(Array)
#1 /var/www/mfserver/vendor/monolog/monolog/src/Monolog/Logger.php(336): Monolog\Handler\AbstractProcessingHandler->handle(Array)
#2 /var/www/mfserver/vendor/monolog/monolog/src/Monolog/Logger.php(615): Monolog\Logger->addRecord(400, Object(Symfony\Component\Debug\Exception\FatalErrorException), Array)
#3 /var/www/mfserver/vendor/laravel/framework/src/Illuminate/Log/Writer.php(202): Monolog\Logger->error(Object(Symfony\Component\Debug\Exception\FatalErrorException), Array)
#4 /var/www/mfserver
答案 0 :(得分:4)
大多数文件夹应该是正常的" 755
"和文件," 644
"。
对于基于nix的操作系统。使用以下内容。
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
答案 1 :(得分:0)
小组" www-data"没有在laravel文件夹上设置nginx。现在我可以访问所有内容