Posted on • Updated on

Deploy Laravel Application on linux server with Github

author

Kai

Prerequisites

  • GitHub repository (public) with Laravel project.

Step 1 - Clone your repository

#cd into your directory where you want to clone your gitHub repository
$ cd ~/repositories
[repositories]$ git clone https://github.com/username/my-laravel-app.git

Clone Successful 🥳

Step 2 - cd into the project

[repositories]$ cd my-laravel-app

Step 3 - Change Permissions

[my-laravel-app]$ sudo chmod 777 -R bootstrap
[my-laravel-app]$ sudo chmod 777 -R storage

Step 4 -  List of commands to set up your laravel project

$ composer install --optimize-autoloader
#OR
$ composer install --optimize-autoloader --no-dev
$ mv .env.example .env
#edit you .env file
$ nano .env
$ php artisan key:generate
$ php artisan migrate --seed
$ php artisan storage:link
$ php artisan config:cache
$ php artisan route:cache
$ php artisan view:cache
$ php artisan optimize:clear
$ php artisan optimize

Step 5 - Error Fix

Error : SQLSTATE[HY000] [2002] Permission denied

Edit .env and change DB_HOST=127.0.0.1 to DB_HOST=localhost

Step 6 - Link (symlink) domain root directory to ~/repositories/my-laravel-app/public folder.

$ ln -s /repositories/my-laravel-app/public /var/www/example.com

YAY! 🥳 Setup is complete. 

Conclusion

In this tutorial, I'll walk you through how to deploy laravel project on any Linux server using GitHub.

end of article

Related Posts

Join Our Newsletter

Want the latest & greatest from our blog straight to your inbox with some exclusive offers from our partners and sponsors?

We won't spam. Promise.