LoginSignup
27
36

More than 5 years have passed since last update.

【超簡易的】githubにpushで、さくらサーバーに自動デプロイ

Last updated at Posted at 2016-03-10
  • githubにリポジトリ作成済み
  • 本番サーバー:さくらのマネージドサーバーあたり

を想定してます。ここで、githubにpushしたら、
本番サーバーに自動デプロイされる流れを超簡易的に作ってみます。

さくらサーバーにgitをインストール

下記参照
http://mattintosh.blog.so-net.ne.jp/2012-09-14

さくらからgithubへのSSH接続の設定

パスワード入力なしで接続したいので設定します。
下記を参照
http://qiita.com/shizuma/items/2b2f873a0034839e47ce

github から cloneする

公開ディレクトリに移動して、その直下でgit cloneします。

cd ~/www
git clone git@github.com:git_account/project.git .

自動デプロイ用phpを作成

git pull するだけのコードです。gitはフルパスが大事です。

http//yoursite.com/deploy.php
<?
exec('/home/sakura_account/local/bin/git pull', $op, $rv);
print_r($op);
print_r($rv);
?>

githubのwebhookに上記を指定

http://yoursite.com/deploy.php
alt

以上です!簡単ですね。
セキュリティとか考えてないので、ご注意ください。

27
36
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
27
36