【发布时间】:2018-11-26 09:51:52
【问题描述】:
我正在尝试在共享主机包上部署 Laravel 5.6 应用程序。此软件包使用 DirectAdmin 和 PHP 7.2。
由于其他应用程序位于public_html 目录的子目录中,我不得不将应用程序也托管在子目录中。
在对在子目录中托管 Laravel 应用程序进行了一些研究后,我的设置如下所示:
- domains
- example.com
- public_html
- laravel
- otherapp
- other_site
- laravel_code
public_html 文件夹中的 laravel 文件夹与 Laravel 应用程序中的每个 public 文件夹具有相同的文件。这意味着文件index.php、.htaccess 等...
laravel_code 文件夹目录包含我的应用程序的源代码。我知道我必须将我的index.php 引用到此文件夹。我是这样做的:
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/
require __DIR__ . '/../../laravel_code/vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__ . '/../../laravel_code/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
我的.htaccess 文件如下所示:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteBase /
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
尝试导航到域时,我只收到 HTTP 500 错误页面,而我的storage/logs文件夹中没有生成任何日志文件。
我已经尝试清除我的缓存并重新缓存我的配置。我也确定我的数据库凭据正常工作。
我的.env 文件如下所示:
APP_NAME=WBS
APP_ENV=local
APP_KEY=base64:knjh2YEuePhEzBblBp5zLJQOQEwaiRBOSkmxz1gcYGw=
APP_DEBUG=true
APP_URL=http://www.example.com/laravel/
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=mydomain
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
文件也有适当的权限,我给所有文件755权限进行测试。
什么可能导致此 HTTP 500 错误,我该如何解决?
【问题讨论】: