如何将Laravel 5.5应用程序部署到Godaddy cPanel共享主机 [英] How to deploy Laravel 5.5 app to Godaddy cPanel shared hosting

查看:78
本文介绍了如何将Laravel 5.5应用程序部署到Godaddy cPanel共享主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Laravel的新手.我对将Laravel 5.5应用程序部署到Godaddy cPanel共享主机的正确方法感到困惑.我已经阅读了多篇有关该主题的文章,它们给出了相互矛盾的建议.

I'm relatively new to Laravel. I'm confused on what is the proper way to deploy a Laravel 5.5 app to a Godaddy cPanel shared hosting. I've read multiple posts on the subject and they give conflicting advice.

我不清楚的部分原因是我是否将所有文件复制到服务器,然后运行以下composer命令?:

Part of what I'm not clear on is do I copy all my files to the server and then run the following composer commands?:

composer install --optimize-autoloaderphp artisan config:cache

我得到的部分是应该在服务器上的public_html文件夹之外创建一个文件夹,将所有应用程序文件放置在那里,除了应用程序的公共子文件夹中的内容.

I get the part where I should create a folder on the server outside of the public_html folder, placing all of the app files there except what is in the app's public subfolder.

如果我想从子文件夹运行该应用程序,该怎么办?为了 例如,www.mysite.com/laravelapp

If I want to run the app from a subfolder how would I do that? For example, www.mysite.com/laravelapp

我找到的示例仅在public_html文件夹本身中运行它.仅涉及更改www/index.php中的文件路径吗?

The examples I found where for only running it from the public_html folder itself. Would it just involve changing the file paths in the www/index.php?

推荐答案

在阅读了有关该主题的更多帖子之后,我想出了如何在Lars共享托管计划上部署Laravel.这是我采取的步骤:

I figured out how to deploy Laravel on a Godaddy shared hosting plan after reading more posts about the subject. Here are the steps I took:

  1. 在public_html文件夹之外创建了一个新文件夹,并将所有应用程序文件上载到供应商文件夹之外的该文件夹中.
  2. 使用SSH访问,我在服务器上新创建的应用程序文件夹中运行了curl -sS https://getcomposer.org/installer | php命令.
  3. 我从Laravel应用程序文件夹中删除了公共文件夹,将其放置在public_html文件夹中,并将其重命名为我的项目名称.
  4. 我修改了项目文件夹中index.php中的文件路径,因此它们指向laravel应用程序文件夹,如下所示:

  1. Created a new folder outside the public_html folder and uploaded all of the app files to that folder except the vendor folder.
  2. Using SSH access, I ran the command curl -sS https://getcomposer.org/installer | php in the newly created app folder on the server.
  3. I removed the public folder from the Laravel app folder, placed it inside the public_html folder and renamed it to the name of my project.
  4. I modified the file paths in the index.php in the project folder so they pointed to the laravel app folder like so:

require __DIR__.'/../../laravel/bootstrap/autoload.php';

$app = require_once __DIR__.'/../../laravel/bootstrap/app.php';

我通过在SSH中运行命令来安装依赖项:php composer.phar install,然后通过运行以下命令来添加必需的缓存:php artisan config:cache

I installed the dependencies by running the command in SSH: php composer.phar install, then adding the necessary cache by running: php artisan config:cache

就是这样.我使用Godaddy cPanel共享托管做到了.在尝试执行此操作之前,请确保将PHP版本设置为7.1.我想发布自己的步骤,因为我发现与此主题有关的一些教程令人困惑,给出了相互矛盾的建议或者没有提供所有必要的步骤.

That was it. I did it using Godaddy cPanel shared hosting. Before attempting this make sure the PHP version is set to 7.1. I wanted to post my steps because I found some of the tutorials on this subject either were confusing, gave conflicting advice or didn't provide all the necessary steps.

这篇关于如何将Laravel 5.5应用程序部署到Godaddy cPanel共享主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆