6
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Laravel軽量化フレームワークLumenのアプリをDeployerを使ってデプロイ

6
Last updated at Posted at 2016-05-19

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/

6
3
0

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
6
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?