How do I properly deploy my Laravel application from my local environment to my remote server?
I am new to Laravel and I have the following doubts.
I need to port a Laravel 5.4 application that I developed from my local environment to my remote server.
Can I do it like this?
-
Take the entire directory containing my local application and upload it to the / var / www / html directory of my remote server.
-
Export my local database and import to my remote database.
-
Modify the contents of the .env file .
The application should now be running on my remote server. Is this correct or am I missing something and I need to do something else?
you may need to update some packages on the remote server for Laravel to work properly. More details here: https://github.com/petehouston/laravel-deploy-on-shared-hosting/blob/master/README.md
source to share
here are the steps
Installing shared hosting
-
Unzip the main zip file and download your public_html folder (also download the vendor folder)
-
Give 777 recursive storage and download / folder permission
-
Create database in phpmyadmin and import .sql file
-
Install database in .env file
- Move all files of the shared folder to the root folder (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";
For
require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
Add this line to set the public path
$app->bind('path.public', function() { return __DIR__; });
(Add this index.php)
Site ready
Installation on Linux
-
Unzip main zip file and upload your html folder (no vendor folder)
-
Grant 777 permission on storage folder / and bootstrap
-
ie The (the Linux:
chmod -R 777 foldername
) - Run Linux command (composer install or composer update)
- Create database in phpmyadmin and import .sql file from DB folder
- Install database to .env file
- create a virtual host to remove the shared folder from the url
Done
source to share