「Php/deploy/deployer/laravel」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→インストール) |
|||
行6: | 行6: | ||
[1 ] Laravel | [1 ] Laravel | ||
$ > 1 | $ > 1 | ||
+ | |||
+ | deploy.phpができる | ||
+ | <pre> | ||
+ | namespace Deployer; | ||
+ | require 'recipe/laravel.php'; | ||
+ | |||
+ | // Configuration | ||
+ | |||
+ | set('ssh_type', 'native'); | ||
+ | set('ssh_multiplexing', true); | ||
+ | |||
+ | set('repository', 'git@domain.com:username/repository.git'); | ||
+ | |||
+ | add('shared_files', []); | ||
+ | add('shared_dirs', []); | ||
+ | |||
+ | add('writable_dirs', []); | ||
+ | |||
+ | // Servers | ||
+ | |||
+ | server('production', 'domain.com') | ||
+ | ->user('username') | ||
+ | ->identityFile() | ||
+ | ->set('deploy_path', '/var/www/domain.com') | ||
+ | ->pty(true); | ||
+ | |||
+ | |||
+ | // 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'); | ||
+ | |||
+ | // [Optional] if deploy fails automatically unlock. | ||
+ | after('deploy:failed', 'deploy:unlock'); | ||
+ | |||
+ | // Migrate database before symlink new release. | ||
+ | |||
+ | before('deploy:symlink', 'artisan:migrate'); | ||
+ | </pre> | ||
==参考== | ==参考== | ||
http://bamboo-yujiro.hatenablog.com/entry/2017/10/07/002537 | http://bamboo-yujiro.hatenablog.com/entry/2017/10/07/002537 |
2018年2月27日 (火) 21:34時点における版
インストール
php/deploy/deployer/基本 [ショートカット]
laravel用のdeployを用意
$ dep init [1 ] Laravel $ > 1
deploy.phpができる
namespace Deployer; require 'recipe/laravel.php'; // Configuration set('ssh_type', 'native'); set('ssh_multiplexing', true); set('repository', 'git@domain.com:username/repository.git'); add('shared_files', []); add('shared_dirs', []); add('writable_dirs', []); // Servers server('production', 'domain.com') ->user('username') ->identityFile() ->set('deploy_path', '/var/www/domain.com') ->pty(true); // 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'); // [Optional] if deploy fails automatically unlock. after('deploy:failed', 'deploy:unlock'); // Migrate database before symlink new release. before('deploy:symlink', 'artisan:migrate');