如何将Laravel应用程序从本地环境正确部署到远程服务器?

问题描述:

我在 Laravel 中是个新手,并且有以下疑问.

I am pretty new in Laravel and I have the following doubt.

我必须将我从本地环境开发的Laravel 5.4应用程序迁移到我的远程服务器.

I have to migrate a Laravel 5.4 application that I have developed from my local environment to my remote server.

我可以通过以下方式做到吗?

Can I do it in the following way?

  1. 获取包含本地应用程序的整个目录,并将其上传到远程服务器的/var/www/html 目录中.

导出我的本地数据库并导入到我的远程数据库中.

Export my local database and import on my remote database.

更改 .env 文件的内容.

现在,该应用程序应该可以在我的远程服务器上运行.是正确的还是我错过了某些东西,我还需要做其他事情?

Now the application should work on my remote server. Is it correct or am I missing something and I have to do something else?

这是步骤

在共享主机上安装

  • 解压缩主要zip文件并上传您的public_html文件夹(也上传供应商文件夹)

  • Unzip the main zip file and upload your public_html folder ( upload vendor folder as well)

授予对存储/和引导程序/文件夹的777递归权限

Give 777 recursive permission to storage/ and bootstrap/ folder

在phpmyadmin中创建数据库并导入.sql文件

Create database in phpmyadmin and import .sql file

在.env文件中设置数据库

Set Database in .env file

 require __DIR__."/../bootstrap/autoload.php";
 $app = require_once __DIR__."/../bootstrap/app.php";

收件人

require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';

添加这些行以设置公共路径

Add these line for setting public path

$app->bind('path.public', function() { return __DIR__; }); (添加此index.php)

$app->bind('path.public', function() { return __DIR__; }); (Add this index.php)

网站准备就绪

在Linux上安装

  • 解压缩主要zip文件并上传您的html文件夹(无供应商文件夹)

  • Unzip the main zip file and upload your html folder (without vendor folder)

授予对存储/和引导文件夹的777权限

Give 777 permission to storage/ and bootstrap folder

即(Linux:chmod -R 777 foldername)

完成