LARAVEL - 将我的 Laravel 项目放到 000webhost 中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42945231/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
LARAVEL - Put my laravel project online in 000webhost
提问by D. Lopes
i already upload files in the public folder to public_html, and others to laravel.
我已经将公共文件夹中的文件上传到 public_html,并将其他文件上传到 Laravel。
i changed index.php too.
我也改变了 index.php。
but i get nothing ....
但我什么也没得到....
[
[
I get this... Some one can help me? Thanks
我明白了……有人可以帮助我吗?谢谢
EDIT: This is my index file, i think thats is good
编辑:这是我的索引文件,我认为那很好
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <[email protected]>
*/
/*
|--------------------------------------------------------------------------
| 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.
|
*/
require __DIR__.'/../laravel/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__.'/../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);
回答by user8555937
The question is quite old however others may find this answer useful. Basically what you have to do is to configure the App to work properly in the new environment.
这个问题已经很老了,但其他人可能会发现这个答案很有用。基本上你要做的就是配置应用程序以在新环境中正常工作。
Go to 000webhost cPanel > Settings > General > Reset website. You must make sure no other content is present in your site to prevent interference.
Archive your entire Laravel Project in ZIP format.
Upload the archive to 000webhost site to
/public_html
using File Manager.Move all files/folders which are on the same level with
package.json
to/
Delete
/public_html
. You won't need it anymore.Rename
/public
to/public_html
Go to
/app/Providers/AppServiceProvider.php
atregister()
method and append the following code inside it:$this -> app -> bind('path.public', function()
{
return base_path('public_html');
});
Open
/.env
. CopyAPP_KEY
value withoutbase64:
Go to
/config/app.php
, find 'key
' and replace the line with the following code:'key' => env('APP_KEY', base64_decode('%YOUR_COPIED_APPKEY%'));
If you have your project connected to a database, update the database credentials from
/config/database.php
. Lookup formysql
vector and update the database, username, password properly.
转到000webhost cPanel > 设置 > 常规 > 重置网站。您必须确保您的站点中不存在其他内容以防止干扰。
以 ZIP 格式存档您的整个 Laravel 项目。
/public_html
使用文件管理器将档案上传到 000webhost 站点。此举是在与同级别的所有文件/文件夹
package.json
到/
删除
/public_html
。你不再需要它了。重命名
/public
为/public_html
转到
/app/Providers/AppServiceProvider.php
atregister()
方法并在其中附加以下代码:$this -> app -> bind('path.public', function()
{
return base_path('public_html');
});
打开
/.env
。没有复制APP_KEY
值base64:
转到
/config/app.php
,找到“key
”并将该行替换为以下代码:'key' => env('APP_KEY', base64_decode('%YOUR_COPIED_APPKEY%'));
如果您的项目已连接到数据库,请从 更新数据库凭据
/config/database.php
。查找mysql
向量并正确更新数据库、用户名、密码。
...And this should do the trick. If you have further questions, a tutorial has been written about the entire procedure here: https://www.000webhost.com/forum/t/deploy-laravel-project-into-000webhost-site/127323/
......这应该可以解决问题。如果您还有其他问题,此处已编写了有关整个过程的教程:https: //www.000webhost.com/forum/t/deploy-laravel-project-into-000webhost-site/127323/
Hope this helps :)
希望这可以帮助 :)
回答by Manoj kumar
WRITE YOUR index.php
写你的 index.php
$app->bind('path.public', function() {
return __DIR__ ;
});