Laravel 5共享主机部署问题

我正在尝试在共享主机上部署laravel 5.2。

我将laravel core app文件夹安装在public_html文件夹(/../public_html或/ home / username)的上面。

我提取了laravel核心公共文件夹(public)中的文件,并将index.php文件指向上面的根目录(/../laravel-app/bootstrap/autoload.php和/../laravel-应用程序/引导/ app.php)。

网站主页正在工作,但网页链接正在返回一个404,它不是拉任何CSS或JS。

任何想法如何我可以解决这个问题?

注意事项:我在PHP版本5.6我更改了laravel-app / storage中的文件权限到777我删除了public_html文件夹中的.htaccess文件夹服务器是apache

巴迪只是按照这个教程,我试了一下,它工作得很好!

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

顺便说一句,你甚至不需要这句话后的最后一部分

如果你的服务器上没有安装Composer,那么你可以很容易地把它拿到项目目录。

在我的情况下,我做了以下工作:把laravel项目放在public_html之外作为lara文件夹

那么我有这个htaccess:

 <Ifmodulee mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_URI} !^public RewriteRule ^(.*)$ public/$1 [L] </Ifmodulee> 

和public_html里面我有.htacess与:

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

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

 <Ifmodulee mod_rewrite.c> <Ifmodulee mod_negotiation.c> Options -MultiViews </Ifmodulee> 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}] </Ifmodulee> 

最后的改变是在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\coreel::class); $response = $kernel->handle( $request = Illuminate\Http\Request::capture() ); $response->send(); $kernel->terminate($request, $response);