Laravelの軽量化フレームワークLumenのプロジェクトを作成し、php製デプロイツールDeployerでサーバーにデプロイするまでの流れです。
Lumenプロジェクト作成
composerを使って、Lumenのプロジェクトを作成します。
$ composer create-project laravel/lumen --prefer-dist lumen_sample
Deployerをダウンロード
以下からpharファイルをダウンロードして、実行できるように設定。
http://deployer.org/
$ mv deployer.phar /usr/local/bin/dep
$ chmod +x /usr/local/bin/dep
アプリをgithubにpush
$ cd lumen_sample
$ git init
$ git add .
$ git commit -m "first commit"
$ git remote add origin https://github.com/{acount_name}/{repository_name}.git
$ git push -u origin master
デプロイ
Lumenのアプリ構成はLaravelとほぼ変わらないので、deployerのLaravelレシピを使用してLaravel同様にデプロイできます。
deploy.phpを以下のように記述し、アプリのルートディレクトリに設置します。
deploy.php
<?php
// Laravelレシピ読み込み
require 'recipe/laravel.php';
server('env_name', 'example.com', 12345) // 接続サーバー
->user('deploy_user') // 接続ユーザ
->identityFile() // 認証
->env('deploy_path', '/path/to/application'); // デプロイ先のディレクトリ
// githubのリポジトリ設定
set('repository', 'git@github.com:wrbss/lumen_sample.git');
※ env_nameは環境名です。depとかstgとか適切に設定してください。
※ 上記の設定では鍵認証を使っているので、デプロイキーまたはsshキーをgithubに設定する必要があります。
その後、アプリのルートディレクトリでコマンド実行
$ dep deploy env_name
✔ Executing task deploy:prepare
✔ Executing task deploy:release
✔ Executing task deploy:update_code
✔ Executing task deploy:vendors
✔ Executing task deploy:shared
✔ Executing task deploy:symlink
✔ Executing task cleanup
➤ Executing task success
Successfully deployed!
✔ Ok
参考
Lumen公式
https://lumen.laravel.com/
Deployer公式
http://deployer.org/