Code Monkey home page Code Monkey logo

phd's Introduction

PHD

Pretty Handy Deployment™

Have you ever wished deploying to a shared Apache/PHP host could be as easy as deploying to Heroku? Well, wish no more. Follow this simple guide and your life will instantly get better.

Featuring...

  • Environment variables
  • Autamatic deployment with Git
  • Using Composer for dependency management

This setup has been confirmed to work on DreamHost. Your mileage may vary.

Installation

  1. Make sure you have SSH enabled on your hosting user
  2. SSH into your hosting account
  3. CD into your domain directory and make sure it's empty
  4. Clone this repo (git clone https://github.com/stephendavis89/PHD.git .)

Environment variables

Environment variables can be set with putenv in a root-level PHP file named environment.php. An example variable is provided. Make sure to configure your domain to use myproject.com/deploy as its web root.

TIP: If you're using a web framework such as Slim or Laravel, use myproject.com/deploy/public as the web root instead.

Deploying with Git

  1. Create a git directory (mkdir -p ~/git && cd ~/git)
  2. Create a project directory (mkdir -p myproject.git && cd myproject.git)
  3. Create an empty remote Git repository (git init --bare)
  4. Create the post-receive hook
mv hooks/post-receive.sample hooks/post-receive
chmod +x hooks/post-receive
  1. Edit the post-receive hook (nano hooks/post-receive) and insert the following content:
#!/bin/sh

echo "Deploying to production..."
GIT_WORK_TREE=~/myproject.com/deploy git checkout -f
echo "Success!"
  1. Add the remote repository to your project From your local project directory, run:
git remote add production ssh://user@host/~/git/myproject.git

To set up an SSH key for password-less deployment, follow this excellent guide.

Using Composer

To get Composer working on DreamHost, follow this guide.

To access the composer binary directly, run this from the directory you installed Composer into:

mkdir -p ~/bin
mv composer.phar ~/bin/composer

And add this to your .bashrc:

export PATH=~/bin:$PATH

Don't forget to add composer installation to your post-receive hook for maximum good times:

(cd ~/myproject.com/deploy && exec composer install --no-dev)

phd's People

Contributors

celeryclub avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.