Localhost引发403禁止的错误Apache Laravel

时间:2020-06-08 21:06:56

标签: php laravel mongodb apache docker-compose

因此,我刚刚将工作计算机从Windows Surfacebook移至公司提供的Thinkpad。我一直在进行laravel设置,以使我们的项目在环境中运行。但是,当我进入localhost:8888时,得到以下信息: Forbidden You don't have permission to access / on this server.

所以我一直在试图弄清楚为什么会这样。我经历了Windows的确切过程:安装了Docker桌面,安装Chocolatey,通过composer安装php,将代码从github拉到src文件夹,使用docker-compose创建了Apache php和mongodb容器。但是我仍然收到403禁止错误。

我尝试用composer update处理依赖关系,检查了我从未触摸过的.htaccess文件,但该文件已在另一台计算机上的其他项目中工作过,与另一台计算机上的.env文件相同,等等。也许是因为它是一台全新的计算机?我必须将我的用户添加到用户组中才能使用docker,也许这阻止了它?我需要在这台新计算机上授予权限吗?所有这些文件应该都很好,这就是为什么我很困惑的原因。

有什么帮助,请告诉我是否还有您想要查看其代码的文件!

.htaccess文件: 选项-MultiViews-索引

RewriteEngine On

# 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]

我的.env文件:

APP_ENV=local
APP_KEY=base64:8LWCAd54wFeq8GUwikoyfKuaKlaUKS/BZwsClqEuAx4=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mongodb
DB_HOST=192.168.99.100
DB_PORT=9999
DB_DATABASE=........Private
DB_USERNAME=
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

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}"

MAIL_DRIVER=mailgun
MAIL_FROM_ADDRESS=projecttracker@mg.ceg.mn
MAIL_FROM_NAME="CEG Project Tracker"
MAILGUN_DOMAIN=mg.ceg.mn
MAILGUN_ENDPOINT=api.mailgun.net
MAILGUN_SECRET=..............Private

我的index.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__.'/../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__.'/../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);```



0 个答案:

没有答案