简体   繁体   中英

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

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?

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

  • ie (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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM