簡體   English   中英

Laravel 5共享主機部署問題

[英]Laravel 5 shared hosting deployment issues

我正在嘗試在共享主機上部署laravel 5.2。

我將laravel核心應用程序文件夾安裝在public_html文件夾(/../public_html或/ home / username)上方。

我提取了laravel核心公共文件夾(public)中的文件,並將index.php文件指向laravel核心應用文件夾中的根目錄(/../laravel-app/bootstrap/autoload.php和/../laravel- app / bootstrap / app.php)。

網站首頁正在運行,但頁面鏈接返回404,並且沒有拉入任何CSS或JS。

關於如何解決此問題的任何想法?

注意點:我在php ver 5.6上,我將laravel-app / storage中的文件權限更改為777,我刪除了public_html文件夾中的.htaccess fil服務器是apache

Buddy只需按照本教程進行操作,我嘗試了一下,它的工作正常!

https://medium.com/laravel-news/the-simple-guide-to-deploy-laravel-5-application-on-shared-hosting-1a8d0aee923e#.5lywcjmnn

順便說一句,你甚至不需要這句話的最后一部分

如果您的服務器上尚未安裝composer,則可以輕松地將其抓到項目目錄中。

就我而言,我執行了以下操作:將laravel項目放置在public_html之外作為lara文件夾

然后我有這個htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

在public_html中,我有.htacess與:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^awesome
RewriteRule ^(.*)$ awesome/$1 [L]

awesome的目錄是包含htacess(列出)和index.php,favicon和robots.txt的目錄:

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

    RewriteEngine On

    # 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中:

<?php

/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <taylorotwell@gmail.com>
 */

/*
|--------------------------------------------------------------------------
| 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 nice to relax.
|
*/

/* die(__DIR__);  /home/{YOURHOST}/public_html/awesome */
require __DIR__.'/../../lara/bootstrap/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__.'/../../lara/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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM