Install composer if not already installed, check composer --version or composer2 --version in cli skip to step 2 if it is.
Some Installations come preinstalled with both composer and newer versions of composer with alias composer2, in which case use composer2 for all comopser tasks
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bashecho 'export NVM_DIR="$HOME/.nvm"' >> ~/.profile
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> ~/.profile
echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"' >> ~/.profilesource ~/.profilegit config --global user.name ""
git config --global user.email ""Check if you already have SSH keys
ls -la ~/.sshIf no keys exist, generate a new one
ssh-keygen -t ed25519 -C "<email here>"When you get the prompt "Enter file in which to save the key", you can either:
- Press Enter to accept the default location (
~/.ssh/id_ed25519) - Or specify a custom path if you want to store it elsewhere or use a different name
The default location is typically fine for most users.
- Enter a secure passphrase (recommended for better security)
- Press Enter twice to use no passphrase (less secure but more convenient)
Once complete, your SSH key pair will be generated - a private key (id_ed25519) and a public key (id_ed25519.pub).
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519Add the SSH key to your Git provider:
- Go to your Git provider (GitHub, GitLab, Bitbucket, etc.)
- Find the "SSH Keys" section in account settings
- https://github.com/settings/keys for GitHub
- Add the public key you just displayed
cd domains/<domain name here>
git clone [email protected]:username/repo-name.git <any dir name>This step will reset public_html directory, ensure all important files are backed up elsewhere
cd ~
rm domains/<domain name here>/public_html -rf
cd domains/<domain name here>/<dir name> # dir name used in git clone at the end of step 3
touch deploy.shPaste the contents contents of 2.deploy.sh into deploy.sh using hostinger's file manager or nano in the terminal.
nano deploy.shMake the file executable
chmod +x deploy.shcomposer install
# or
composer2 installcp .env.example .env
php artisan key:generate --ansi
php artisan storage:link # if this command fails, run If the last command fails, run:
cd public
ln -s ../storage/app/public storage
cd ..Update the .env
nano .env- Update
APP_NAME APP_ENV=productionAPP_DEBUG=falseAPP_URL=<domain here>- Update DB connection details
Create link to laravel's public directory from domain's public_html
cd .. # Go to the domains/<domain name> directory, ls command should show the <dir name> we git cloned into
ln -s <dir name>/public public_html
cd <dir name>
./deploy.shThe deploy.sh script will pull the latest commit from the git origin and run all the composer, laravel and npm update steps.
You can manually run the deployment using ssh in the future by running the deploy.sh script or set up a auto deployment pipeline from github.
Sources: