diff --git a/recipe/provision/Caddyfile b/recipe/provision/Caddyfile new file mode 100644 index 000000000..2b485c612 --- /dev/null +++ b/recipe/provision/Caddyfile @@ -0,0 +1,22 @@ +{{domain}} { + + root * {{deploy_path}}/current/{{public_path}} + file_server + php_fastcgi * unix//run/php/php{{php_version}}-fpm.sock { + resolve_root_symlink + } + + log { + output file {{deploy_path}}/log/access.log + } + + handle_errors { + @404 { + expression {http.error.status_code} == 404 + } + rewrite @404 /404.html + file_server { + root /var/dep/html + } + } +} diff --git a/recipe/provision/website.php b/recipe/provision/website.php index 938b6129d..812f1eea0 100644 --- a/recipe/provision/website.php +++ b/recipe/provision/website.php @@ -11,43 +11,17 @@ desc('Provision website'); task('provision:website', function () { + set('deploy_path', run("realpath {{deploy_path}}")); + run("[ -d {{deploy_path}} ] || mkdir -p {{deploy_path}}"); run("chown -R deployer:deployer {{deploy_path}}"); - $domain = get('domain'); - $phpVersion = get('php_version'); - $deployPath = run("realpath {{deploy_path}}"); - $publicPath = get('public_path'); - - cd($deployPath); + cd('{{deploy_path}}'); run("[ -d log ] || mkdir log"); run("chgrp caddy log"); - $caddyfile = << Caddyfile.new"); @@ -68,12 +42,12 @@ run("echo $'$caddyfile' > Caddyfile"); } - if (!test("grep -q 'import $deployPath/Caddyfile' /etc/caddy/Caddyfile")) { - run("echo 'import $deployPath/Caddyfile' >> /etc/caddy/Caddyfile"); + if (!test("grep -q 'import {{deploy_path}}/Caddyfile' /etc/caddy/Caddyfile")) { + run("echo 'import {{deploy_path}}/Caddyfile' >> /etc/caddy/Caddyfile"); } run('service caddy reload'); - info("Website $domain configured!"); + info("Website {{domain}} configured!"); })->limit(1); desc('Shows caddy logs');