在云托管上部署Laravel 5.1 [英] Deploy Laravel 5.1 on a cloud hosting

查看:87
本文介绍了在云托管上部署Laravel 5.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在wamp上开发了laravel应用程序.我终于完成了工作,并租用了具有CPanel接口的云托管服务器.我将所有文件上传到公共html上,并尝试访问该网站.应该可以进入登录页面但不能正常工作.

I developed my laravel application on wamp. I am finally done and rent a cloud hosting server with CPanel interface. I uploaded all my files on public html and tried going to the site. It's supposed to go to login page but not working.

我曾经部署过经典的html文件,这是我第一次部署PHP laravel网站.我已经成功导入了MySQL数据库,因此已经准备就绪.我对配置等一无所知.

I used to deploy classic html file, this is the first time I'm deploying a PHP laravel site. I've successfully imported my MySQL database so it's ready. I'm just clueless of the configuration etc.

推荐答案

我将引导您完成这些步骤.由于您提到了public_html文件夹,因此我认为此解决方案将为您服务.请按照以下步骤操作,并将myapp更改为您的应用名称.

I'll walk you through the steps. Since you mentioned about public_html folder, I assume that this solution will work for you. Please follow the steps and change myapp to whatever your app name is.

  • 将项目的public文件夹复制到public_html文件夹并重命名(说myapp_public)
  • 您将在public_html文件夹中看到一个.htaccess文件.编辑该文件的内容,如下所示: RewriteEngine On RewriteCond %{REQUEST_URI} !^myapp_public RewriteRule ^(.*)$ myapp_public/$1 [L]

  • Copy your project's public folder into public_html folder and rename it (Say myapp_public)
  • You will see a .htaccess file in public_html folder. Edit the contents of that file as follows: RewriteEngine On RewriteCond %{REQUEST_URI} !^myapp_public RewriteRule ^(.*)$ myapp_public/$1 [L]

将根目录中的其他文件夹复制到另一个目录中,例如myapp

Copy other folders in the root directory inside another directory say myapp

更改require语句,如下所示:

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

按如下所示更改$app变量:

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

这应该做到.为简便起见,绘制出简单的目录结构.

And this should do it. Drawing out the simple directory structure for easiness.

~
|__ myapp
|     |____ .env
|     |____ app
|     |____ artisan
|     |____ .........so on
|
|__ public_html
          |_____ .htaccess (this is the file to edit)
          |_____ myapp_public
                     |________ .htaccess
                     |________ index.php (this is the file to edit)
                     |________ robots.txt ...... so on

如果您不了解这里发生的情况,我将详细解释.

I will explain in detail if you do not understand what is happening here.

编辑

请确保已通过cURL安装了composer,因为apt-get在共享主机上将无法工作.完成后,如果遵循上述步骤,请从项目的根目录(即myapp)运行composer install.

Make sure that you have installed composer via cURL as apt-get wont work on shared hosts. Once done, run composer install from your project's root directory i.e. myapp if you followed above steps.

这篇关于在云托管上部署Laravel 5.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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