How correctly deploy a Laravel application from my local environment to my remote server?

坚强是说给别人听的谎言 提交于 2019-12-23 04:31:13

问题


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

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. Take the entire directory containing my local application and upload it into the /var/www/html directory of my remote server.

  2. Export my local database and import on my remote database.

  3. Change the content of the .env file.

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


回答1:


here is the steps

Installation On Shared Hostings

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

  • Give 777 recursive permission to storage/ and bootstrap/ folder

  • Create database in phpmyadmin and import .sql file

  • Set Database in .env file

  • Move all public folder files to root folder in(public_html or your website folder)
  • open index.php

Replace these lines with

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

To

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__; }); (Add this index.php)

Site is ready

Installation On Linux

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

  • Give 777 permission to storage/ and bootstrap folder

  • i.e (Linux: chmod -R 777 foldername)

  • Run Linux command (composer install or composer update)
  • Create database in phpmyadmin and import .sql file from DB folder
  • Set Database in .env file
  • create vertual host for removing public folder from url

Done




回答2:


you'll maybe have to update some packages on your remote server so Laravel can work properly. More details here : https://github.com/petehouston/laravel-deploy-on-shared-hosting/blob/master/README.md



来源:https://stackoverflow.com/questions/43388814/how-correctly-deploy-a-laravel-application-from-my-local-environment-to-my-remot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!