Create a deployment script
The following deployment script performs the following steps
Creates a new deployment folder
Clones the repository into this deployment folder
Copies the .env file from the master folder
Runs Composer Install so that the project has the same dependencies as your committed version (see note below regarding Composer version)
Creates links for storage to the master storage folder and from storage/app/public to the public/storage folder
Finally creates a symlink from Live to the deployment folder
Copy the above code and create the file in your websites folder using nano
or the SiteGround file manager.
Configuring the script for your repo
On line 9, you will need to replace this with the git clone equivalent for your repository and branch.
The parameter --depth 1
ensures that we don't waste time cloning git history. We only need the latest version of the code.
The parameter -b main
is the git branch that you would like to deploy.
The project name is the SSH
version of the clone command for your specific repo.
php version for Artisan
You can see that this is a PHP8.1 project and all artisan commands must specify the php version to be used. You may create a bashrc alias for this to revert it to just php
Make your script executable
When you create a file, it will not have the execute flag set. You cannot change this from the Site Tools file manager, you must do it from the command line with;
You also, cannot run a bash script with just its name, it must be preceded with ./
So to run the build script, run ./build.sh
migrating your database
After running the build script for the first time, you will want to migrate your database so that it is ready for action!
All artisan commands should be run from the Live
folder
Composer Version issues
If you are following this guide and NOT using SiteGround, you may run into an issue where the version of composer available to you is not up to date enough for a Laravel installation. If this is the case, follow the advice at https://stackoverflow.com/questions/20894518/how-do-i-install-composer-on-a-shared-hosting/29436655#29436655
Last updated