「Php/deploy/deployer」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→DLせずにcomposerを使って環境を整える) |
(→ひな形作成) |
||
行31: | 行31: | ||
> 0 | > 0 | ||
fwを使ってなければ0に | fwを使ってなければ0に | ||
+ | |||
+ | ==こんな感じのdeployファイルができる== | ||
+ | deploy.php | ||
+ | namespace Deployer; | ||
+ | require 'recipe/common.php'; | ||
+ | // Configuration | ||
+ | set('ssh_type', 'native'); | ||
+ | set('ssh_multiplexing', true); | ||
+ | set('repository', 'git@domain.com:username/repository.git'); | ||
+ | set('shared_files', []); | ||
+ | set('shared_dirs', []); | ||
+ | set('writable_dirs', []); | ||
+ | // Servers | ||
+ | server('production', 'domain.com') | ||
+ | ->user('username') | ||
+ | ->identityFile() | ||
+ | ->set('deploy_path', '/var/www/domain.com'); | ||
+ | // Tasks | ||
+ | desc('Restart PHP-FPM service'); | ||
+ | task('php-fpm:restart', function () { | ||
+ | // The user must have rights for restart service | ||
+ | // /etc/sudoers: username ALL=NOPASSWD:/bin/systemctl restart php-fpm.service | ||
+ | run('sudo systemctl restart php-fpm.service'); | ||
+ | }); | ||
+ | after('deploy:symlink', 'php-fpm:restart'); | ||
+ | desc('Deploy your project'); | ||
+ | task('deploy', [ | ||
+ | 'deploy:prepare', | ||
+ | 'deploy:lock', | ||
+ | 'deploy:release', | ||
+ | 'deploy:update_code', | ||
+ | 'deploy:shared', | ||
+ | 'deploy:writable', | ||
+ | 'deploy:vendors', | ||
+ | 'deploy:clear_paths', | ||
+ | 'deploy:symlink', | ||
+ | 'deploy:unlock', | ||
+ | 'cleanup', | ||
+ | 'success' | ||
+ | ]); | ||
+ | // [Optional] if deploy fails automatically unlock. | ||
+ | after('deploy:failed', 'deploy:unlock'); | ||
==参考== | ==参考== | ||
http://tech.connehito.com/entry/2016/07/28/170858 | http://tech.connehito.com/entry/2016/07/28/170858 |
2017年12月12日 (火) 17:45時点における版
(作成途中)
目次
deployerのphp対応バージョン
Deployer 5.x supports only php7 and above. If you want to use older php version use Deployer 4.x
deployerのダウロード
http://deployer.org/deployer.phar
deployer4系ダウンロード
https://deployer.org/releases/v4.3.1/deployer.phar
プロジェクト直下に設置
$ wget http://deployer.org/deployer.phar $ mv deployer.phar /usr/local/bin/dep $ chmod +x /usr/local/bin/dep
DLせずにcomposerを使って環境を整える
composer require deployer/deployer --dev
ひな形作成
dep init [0] Common [1] Laravel [2] Symfony [3] Yii [4] Zend Framework [5] CakePHP [6] CodeIgniter [7] Drupal > 0
fwを使ってなければ0に
こんな感じのdeployファイルができる
deploy.php
namespace Deployer; require 'recipe/common.php'; // Configuration set('ssh_type', 'native'); set('ssh_multiplexing', true); set('repository', 'git@domain.com:username/repository.git'); set('shared_files', []); set('shared_dirs', []); set('writable_dirs', []); // Servers server('production', 'domain.com') ->user('username') ->identityFile() ->set('deploy_path', '/var/www/domain.com'); // Tasks desc('Restart PHP-FPM service'); task('php-fpm:restart', function () { // The user must have rights for restart service // /etc/sudoers: username ALL=NOPASSWD:/bin/systemctl restart php-fpm.service run('sudo systemctl restart php-fpm.service'); }); after('deploy:symlink', 'php-fpm:restart'); desc('Deploy your project'); task('deploy', [ 'deploy:prepare', 'deploy:lock', 'deploy:release', 'deploy:update_code', 'deploy:shared', 'deploy:writable', 'deploy:vendors', 'deploy:clear_paths', 'deploy:symlink', 'deploy:unlock', 'cleanup', 'success' ]); // [Optional] if deploy fails automatically unlock. after('deploy:failed', 'deploy:unlock');