Categories
Laravel

Setting Up Laravel Staging Environment

In this post we are going to cover setting up a Laravel staging environment. We are going to assume that a live environment has been setup on this account following these steps previously covered.

1.) Create A new folder for the staging site, this will live in /git/staging/repo-name

2.) Manually Clone The repo into this new staging folder then checkout the staging branch

3.) Create A symlink to this folder for the staging subdomain:
ln -s ~/git/staging/repo-name/public ~/public_html/staging

*Please note, in order for this to work symlinks to the files in the live sites public folder must be setup as symlinks instead of setting up the entire public_html folder as a symlink to the lives sites /public folder. In practice the code to do this looks like:

ln -s ~/git/live/repo-name/public/css ~/public_html/css
ln -s ~/git/live/repo-name/public/fonts ~/public_html/fonts
ln -s ~/git/live/repo-name/public/images ~/public_html/images
ln -s ~/git/live/repo-name/public/js ~/public_html/js
ln -s ~/git/live/repo-name/public/.htaccess ~/public_html/.htaccess
ln -s ~/git/live/repo-name/public/favicon.ico ~/public_html/favicon.ico
ln -s ~/git/live/repo-name/public/index.php ~/public_html/index.php
ln -s ~/git/live/repo-name/public/robots.txt ~/public_html/robots.txt

4.) Create a staging subdomain with document root of public_html/staging

5.) Create new database and add credentials to .env file

6.) run migrations and seeds