主持人如何在共享托管上托管Laravel 5.6
个应用。
有人可以给我一个想法
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';
/*
\#########my index.php file
答案 0 :(得分:2)
您有两种方法可用,一种需要ssh访问。在任何情况下,您都不会将整个Laravel目录放入public_html
目录。
如果您有SSH访问权限,则需要执行以下操作;
cd ~
public_html
目录~/laravel
cd ~ && ln -s laravel/public public_html
如果您没有SSH访问权限,则需要执行以下操作;
~/laravel
(在public_html上方)~/laravel/public
目录的内容复制到public_html
您的新~/public_html/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/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/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);
答案 1 :(得分:0)
require __DIR__.'/<project_folder_name>/vendor/autoload.php'
和$app = require_once __DIR__.'/<project_folder_name>/bootstrap/app.php';
也会更新你的.env文件并检查它应该是工作如果它不是你必须使用php artisan cache:clear
和php artisan route:clear
清除缓存和路由,你可以使用ssh或在web.php中定义函数,然后点击链接
答案 2 :(得分:0)
嗯。共享主机不支持larave 5.6所依赖的php 7。你们找到解决方法了吗?我已经在bluehost上使用laravel 4.x停留了几个月。
答案 3 :(得分:0)
Laravel 5.6
需要PHP 7
。
首先在Cpanel(PHP选择器)中检查共享的托管支持PHP 7
,如果可以,但是您还有其他PHP 5
项目,并且您不想更改默认的php版本,则在其中使用它.htaccess
个文件
例如: public_html / abc / .htaccess
RewriteEngine on
AddHandler application/x-httpd-php71 .php
然后PHP 7
工作,您就可以在共享主机上使用Laravel 5.6
答案 4 :(得分:0)
max_created = Entity.objects.filter(
identifier=OuterRef('identifier')
).order_by('-created').values('created')[:1]
Entity.objects.filter(
created=Subquery(max_created)
)
别忘了将您的php版本更改为7.2
答案 5 :(得分:0)
在共享主机上托管的最简单方法
注意:如果您遇到任何由于缓存删除目录 bootstrap/cache 中的文件 config.php。
答案 6 :(得分:-2)
您可以在共享主机
的public_html(root)中尝试以下结构创建一个名为laravel的文件夹,并将除公共文件夹以外的所有文件和文件夹放在其中。
将公共目录的所有文件和文件夹直接复制到public_html根目录。您的文件夹结构应如下所示
public_html
- Laravel (Folder with all the laravel files and folders except public)
- css (from public folder)
- js (from public folder)
- .htaccess(from public folder)
- index.php (from public folder)
- robots (from public folder)
将index.php编辑为以下
require __DIR__.'/laravel/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/bootstrap/app.php';
/*