Skip to content

Instantly share code, notes, and snippets.

@nissicreative
Last active August 18, 2024 05:04
Show Gist options
  • Save nissicreative/33e2b20fa5f02efa2e134cffd5fd32c0 to your computer and use it in GitHub Desktop.
Save nissicreative/33e2b20fa5f02efa2e134cffd5fd32c0 to your computer and use it in GitHub Desktop.
Deploy to DreamHost using Git

DreamHost Git Deployment

On Local Server

Enable password-less ssh access:

cat ~/.ssh/id_rsa.pub | ssh username@server "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"
# shortcut: copyrsa

Verify password-less login. (If unsuccessful, make sure the .ssh directory has 700 permissions, and authorized_keys has 600 permissions.)

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

On Remote Server

Create directory for repository and initialize bare git repository:

mkdir ~/git && cd ~/git
mkdir [myrepo].git && cd [myrepo].git
git init --bare
#shortcut ggitrepo

Create/edit post-receive hook:

nano hooks/post-receive

post-receive

#!/bin/bash
GIT_WORK_TREE=../../[working_directory] git checkout -f master
# shortcut: gpostrec

Make sure post-receive has 755 permissions:

chmod +x hooks/post-receive

(Repeat for staging repository/working directory.)

On Local Server

Add a production (and staging) remote:

git remote add [production/staging] ssh://user@server.tld/path/to/repo.git
# shortcut: ggra

Push to production remote:

git push production HEAD:master

On Remote Server

Install composer dependencies

composer install --no-dev
#shortcut ccind

Change .env.example to .env file and generate an application key

mv .env.example .env
php artisan key:generate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment