【发布时间】:2016-03-02 16:16:03
【问题描述】:
Laravel 5 部署获取:
内部服务器错误
服务器遇到内部错误或配置错误,无法完成您的请求
我的文件结构:
|
|-pub -> from laravel folder public
|-my_apps
|- my_first_app -> all other files from laravel project
|- app
|- bootstrap
|- config
|- database
|- resources
|- storage
|- ...
我已将存储文件夹权限设置为:
用户::rwx
组::rwx
其他::rwx
这是我在 /pub 目录中的 .htaccess 文件
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase / <-------- I added this line
# 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]
</IfModule>
我也在\pub\index.php中更改路径
<?php
//updated path
require __DIR__.'/../my_apps/my_first_app/bootstrap/autoload.php';
//updated path
$app = require_once __DIR__.'/../my_apps/my_first_app/bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
我本地机器上的 PHP 是 PHP 5.6,它是 PHP 5.5。我尝试添加
AddHandler application/x-httpd-php55 .php
在RewriteEngine On 行之后的.htaccess 中。
更新
服务器运行 PHP 5.5.0,所以我将 Laravel 5.1 降级到 5.0,它现在可以在宅基地上运行。 我现在正在关注https://medium.com/laravel-news/the-simple-guide-to-deploy-laravel-5-application-on-shared-hosting-1a8d0aee923e#.50q2s8wer 进行部署。 当我检查 laravel 的版本时,降级实际上失败了
【问题讨论】:
-
检查 laravel 和 apache 日志以获取有关错误性质的更多信息。
-
检查php版本
-
服务器上的php 5.5.0版本,我在homestead上使用php 5.6进行开发
-
使用您在默认代码中所做的更改降级到 laravel 5 是否正常工作?你是什么意思:“它现在可以在宅基地上运行。”
标签: php .htaccess laravel-5 web-deployment