Laravel 5共享主机部署问题 [英] Laravel 5 shared hosting deployment issues
问题描述
我正在尝试在共享主机上部署laravel 5.2.
I am trying to deploy laravel 5.2 on shared hosting.
我将laravel核心应用程序文件夹安装在public_html文件夹(/../public_html或/home/username)上方.
I installed the laravel core app folder a level above the public_html folder (/../public_html or /home/username ).
我提取了laravel核心公共文件夹(公共)中的文件,并将index.php文件指向laravel核心应用文件夹中位于//../laravel-app/bootstrap/autoload.php和/.上方的根. /laravel-app/bootstrap/app.php).
I extracted the files in the laravel core public folder (public) and pointed the index.php file to the laravel core app folder a root above (/../laravel-app/bootstrap/autoload.php and /../laravel-app/bootstrap/app.php).
网站首页正在运行,但页面链接返回404,并且没有拉入任何CSS或JS.
The website homepage is working but pages links are returning a 404 and it isnt pulling in any css or js.
关于如何解决此问题的任何想法?
Any ideas on how I can fix this?
注意事项: 我在php ver 5.6上 我将laravel-app/storage中的文件权限更改为777 我删除了public_html文件夹中的.htaccess文件 服务器是apache
Points to note: I am on php ver 5.6 I changed the file permission in laravel-app/storage to a 777 I deleted the .htaccess fil in the public_html folder Server is apache
推荐答案
Buddy只需按照本教程进行操作,我尝试了一下,它的工作正常!
Buddy just follow this tutorial, I tried it and it's working just fine!
Btw, you don't even need the last part after this sentence
如果您的服务器上尚未安装composer,则可以轻松地将其抓到项目目录中.
If you don’t have composer installed already on your server, you can easily grab it to the project directory then.
就我而言,我执行了以下操作:
将laravel项目放置在public_html外部,作为lara
文件夹
In my case I did the following:
placing laravel project outside of public_html as lara
folder
然后我有了这个htaccess:
then I had this htaccess in it:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
在public_html里面,我有.htacess:
and inside public_html I had .htacess with:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^awesome
RewriteRule ^(.*)$ awesome/$1 [L]
awesome
是包含htacess(在下面列出)以及index.php,favicon和robots.txt的目录:
Where awesome
is the directory that contains htacess (listed down) and index.php, favicon and 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中:
final change is in 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);
这篇关于Laravel 5共享主机部署问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!