2016-10-03 58 views
0

我已经安装了Laravel 5.1并尝试在共享主机上进行配置。 我已在项目的根和.htaccess文件index.php文件公用文件夹中,但仍然得到:配置Laravel .1 htaccess

500 Internal server Error

我已经运行: composer install

我已在.env文件数据库配置中添加。

我的项目文件夹名为cms

然后我试图改变.htaccess filepublic directory这样的:

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

 
    RewriteEngine On 
 
    RewriteBase /cms/ 
 

 
    # 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>
.htaccess fileproject root是:

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

 
    RewriteEngine On 
 
    RewriteBase /cms/ 
 
# RewriteBase /home/crewjobe/public_html/ 
 
    # 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>

我在项目根目录和公共目录中都有index.php文件。 公共目录中的Index.php是从laravel安装的。在项目的根 index.php文件是:

<?php 
 

 
/** 
 
* Laravel - A PHP Framework For Web Artisans 
 
* 
 
* @package Laravel 
 
* @author Taylor Otwell <[email protected]> 
 
*/ 
 

 
$uri = urldecode(
 
    parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) 
 
); 
 

 
//This file allows us to emulate Apache's "mod_rewrite" functionality from the 
 
// built-in PHP web server. This provides a convenient way to test a Laravel 
 
// application without having installed a "real" web server software here. 
 
if ($uri !== '/' && file_exists(__DIR__.' /public'.$uri)) { 
 
    return false; 
 
} 
 

 
require_once __DIR__.' /public/index.php';

我哪里错了?在全新安装Laravel时是否有一种非常规的配置方式?谢谢。

+0

我从来没有在.htaccess中看到嵌套的IF ..不知道这是问题,但它看起来很奇怪。推荐的'如果mod_rewrite的”块 外侧移动这个 #选项-MultiViews

+0

这与laravel安装时创建在此way..I变化不大的另一部分 –

+1

你怎么知道这个问题与'.htaccess'有关?错误500提示一些PHP错误。你在共享主机的'public'或'public_html'目录中有'error.log'吗?另外,添加'ini_set('display_errors',1); error_reporting(-1);'到'index.php'并检查是否有详细错误 –

回答

0

谢谢@milz后,我检查服务器错误日志,发现这些消息:

path/to/project/folder/ is writeable by group

和搜索的问题,我发现这个解决方案: Solution

我改项目文件夹权限为0644,也是项目/公共文件夹,现在没问题。