Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bgarrant/a00e05381e91a069e55c43819de14273 to your computer and use it in GitHub Desktop.
Save bgarrant/a00e05381e91a069e55c43819de14273 to your computer and use it in GitHub Desktop.
How to setup Statamic above document root on cPanel with Git

How to setup Statamic above document root on cPanel with Git

This will install Statamic to your /home/USERNAME/ directory and have the needed public facing files files in your /home/USERNAME/public_html/ folder.

Setup your local Statamic environment to have the folder structure below

If you need help setting up above document root, please visit https://docs.statamic.com/knowledge-base/running-above-webroot.

local
public_html
|-- assets
|-- index.php
|-- .htaccess
site
statamic
please
.gitignore

Please use the revised .gitignore file below and adjust if needed to make sure any files/folders that you would like ignored are listed. I ignored all the cPanel files/folder from the default install and the Statamic files/folders from the original .gitignore file, but your needs may vary.

On Remote Terminal (LIVE or STAGING SERVER)

$ ssh -p port [email protected] (or USERNAME@IP)
$ nano ~/.bashrc (Add line "umask 022" under # User specific aliases and functions)

Then to save and exit:

^O (WriteOut)
^X (Exit)

Make a Git repo:

$ cd
$ git init
$ git config --global user.email "[email protected]"
$ git config --global user.name "Your Name"
$ git config receive.denyCurrentBranch updateInstead

On Local Terminal in your Project Directory Root

$ git init
$ git add --all
$ git commit -m "initial commit"
$ git remote add origin ssh://[email protected]/home/USERNAME/
$ git push origin master -u (pushes local repo to Server repo)

If you use a custom port for SSH then it should be "ssh://[email protected]:2222/home/USERNAME/" where 2222 is your custom port

To PUSH changes from Local to Live Server

On Local Terminal in your Project Directory Root:

$ git add --all
$ git commit -m "description of chnages made for commit"
$ git push

To PULL changes from Live Server to Local

On Live Server Remote Terminal:

$ ssh -p port [email protected] (or USERNAME@IP)
$ git add --all
$ git commit -m "modifed files from live server"

On Local Terminal in your Project Directory Root:

$ git pull
# Statamic and OS #
#################
.*
!.git*
!.htaccess
node_modules/
bower_components/
local/cache/*
local/storage/*
local/temp/*
installer.php
# cPanel #
#################
access-logs
/cache/
/etc/
/logs/
/mail/
/perl5/
/public_ftp/
/public_html/.well-known
/ssl/
/tmp/
www
cpbackup-exclude.conf
error_log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment