如何在共享 cPanel 主机上部署 Laravel 5

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29587829/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 11:20:27  来源:igfitidea点击:

How to Deploy Laravel 5 on shared cPanel hosting

laravellaravel-5laravel-4cpanel

提问by Dipendra Gurung

I've been successful in deploying Laravel 4 applications on shared hosts by simply editing the paths here at /bootstrap/paths.php.

通过简单地编辑 /bootstrap/paths.php 中的路径,我已经成功地在共享主机上部署 Laravel 4 应用程序。

However, Laravel 5 does not have that file. How does Laravel 5 manage paths? I have access to the root directory with public_html. I can upload all the files to root and public directories, but confused where to look for the paths to be maintained?

但是,Laravel 5 没有那个文件。Laravel 5 如何管理路径?我可以使用 public_html 访问根目录。我可以将所有文件上传到根目录和公共目录,但不知道在哪里寻找要维护的路径?

采纳答案by Dipendra Gurung

Laravel 5 is smart enough to detect all it's path. I was missing some of the files during upload. :)

Laravel 5 足够聪明,可以检测到它的所有路径。我在上传过程中丢失了一些文件。:)

What I did was upload all the files as it is structured and the content of public folder was uploaded into the www directory, that's it!

我所做的就是按照结构上传所有文件,并将公共文件夹的内容上传到www目录中,就是这样!

回答by Andrea

If you have cPanel in your shared hosting you can try these easier methods before trying to move the Laravel's publicfolder:

如果您的共享主机中有 cPanel,您可以在尝试移动 Laravelpublic文件夹之前尝试这些更简单的方法:

  1. Often you also have an SSH access when you have cPanel on shared hostings, so you can replace the wwwfolder (i.e. the website document root) with a symbolic linkto [app]/public, then deploy your Laravel app inside the [app]folder.
  2. If you are deploying on a subdomain, e.g. [app].example.com, usually with cPanel you can choose the document root, then you can simply set it to [app]/public.
  1. 通常你也有一个SSH访问时,你必须在共享hostings的cPanel,所以你可以更换www文件夹(即网站文档根目录用)符号链接[app]/public,然后部署内您Laravel应用程序[app]文件夹中。
  2. 如果您在子域上部署,例如[app].example.com,通常使用 cPanel,您可以选择文档根目录,然后您可以简单地将其设置为[app]/public.

I think the two methods above are both easier and safer than moving the publicfolder. I would keep this as the last option.

我认为上述两种方法都比移动public文件夹更容易也更安全。我会把它作为最后的选择。

Take a look here for some more info: http://blog.netgloo.com/2016/01/29/deploy-laravel-application-on-shared-hosting/

在这里查看更多信息:http: //blog.netgloo.com/2016/01/29/deploy-laravel-application-on-shared-hosting/

回答by Margus Pala

You can play with creating new Application() in bootstrap/app.php. Its constructor takes argument which tells where is rest of the application related to public/index.php

您可以在 bootstrap/app.php 中创建新的 Application()。它的构造函数接受参数,该参数告诉与 public/index.php 相关的应用程序的其余部分

Currently app.php has

目前 app.php 有

$app = new Illuminate\Foundation\Application(
    realpath(__DIR__.'/../')
);

Change the /../ to something else if rest of the application folders for example in ../laravel/ compared to index.html

如果应用程序文件夹的其余部分(例如在 ../laravel/ 中与 index.html 相比),请将 /../ 更改为其他内容