Categories
Laravel Samuel

Notes on installing Laravel Site

Installing the site:

Deployment Script: Create a folder called “deploy” above the public_html directory. Update the URL paths inside our deploy script to use the URL paths of your local machine then chmod +x the script after uploading it.

Deploy Keys:

To allow the server to connect to the bitbucket repo we need to get our servers public key and add it to bitbucket, to do this we can run (cd ~/.ssh). Then run (cat id_rsa.pub) and copy the pub key file (control + insert + c to copy from terminal). If no public key file is present run (ssh-keygen) then copy the file. Next we will copy the key into Bitbucket, maximize the SSH terminal window if getting invalid key warning from bitbucket, spacing effects this. Next step is login to bitbucket, hit the settings page, then hit access keys > add key > past key into this window and save.

Manually Clone:

Navigate to one level above the public_html folder and create a new folder called (git). Inside this folder run: git clone repo-name (pull repo from bitbucket SSH repo clone)

*Please note, check to see if the repo name matches the project name inside the deploy script. These must match for the deploy script to work.

Run Composer:

If composer has been installed on the server already, you can navigate to the project root and run: (composer install). This will pull in all of the project dependencies and store them in the vendor folder.

Create Database:

Create an empty database and then add the credentials into the .enf file located in the projects root

Update .ENV File:

The ENV file is not version controlled and is unique to each host its on. This file has defaults for the URL, Database Connection, Spark Post Email Connection, & Google Maps Key.

Create Backup Scripts + CronJobs

  • backups -> daily/weekly/monthly folders
  • backupscripts -> daily/weekly/monthly scripts
  • cpanel -> crong jobs -> daily/weekly/monthly timing with the command pointed at each separate script

Commands to run once all files are present:

1.) Navigate to the deploy script and run it (./deploy-script). The first time this script runs it will create backup folders on the server along with a db connection file.

2.) After the deploy script runs, from the project root you will want to manually run: (php artisan migrate & php artisan db:seed). This will add all the database tables and default user information to the site.

Create Symlink:

The actual Laravel files live above the public_html folder for added security. For this to work we will need to create a symlink from public_html to the public Laravl Folder.

***Please note: If you are planning to have the site use a Let’s Encrypt SSL you will need to copy the .well-known folder into the Laravel Public folder. Before doing this you must add the following lines to the gitignore file:

/public/.well-known
/public/.htaccess

To Create the symlink run:

ln -s /home/user/git/repo-name/public /home/user/public_html

or if you want to go with the shorthand you can use:

ln -s ~/git/repo-name/public ~/public_html

*Please note you will need to change the file paths above to match your actual file paths