Symfony2 + Capifony - 部署期间崩溃

Symfony2 + Capifony - Crash during deploying

我不知道我用那个做什么。我正在尝试在 3 天内部署 Symfony 2 应用程序。我也尝试使用 DeployBundle,但它没有用,因为 windows 和 rsync 问题。现在我正在尝试再次使用 capifony。 Capifony 有悲惨的文件...

我放弃了连接到 bitbucket 存储库,因为我在使用 ssh 密钥时遇到问题。现在我使用本地存储库,但服务器是远程的,我通过 openVPN 连接。如果我会用 cap deploycap deploy:cold (我不知道有什么区别),所以 capifony 没有说到底是什么问题。我还发现可以部署到本地文件夹 Deploy application to localhost using Capistrano

但是 capifony 说 the task local does not exist。我不知道开发人员如何能够使用此命令。

我的 capifony 日志(部署到服务器期间):

JoHn@JOHN-PC /d/Prace/Project/web/os-project/web (master)
$ git branch -D deploy
Deleted branch deploy (was 5f8a385).

JoHn@JOHN-PC /d/Prace/Project/web/os-project/web (master)
$ cap deploy:cold
DL is deprecated, please use Fiddle
  * 2015-01-19 22:33:33 executing `deploy:cold'
  * 2015-01-19 22:33:33 executing `deploy:update'
 ** transaction: start
  * 2015-01-19 22:33:33 executing `deploy:update_code'
    triggering before callbacks for `deploy:update_code'
--> Updating code base with copy strategy
    executing locally: "git ls-remote d:\Prace\Project\web\os-project\ ma
ster"
    command finished in 90ms
  * getting (via checkout) revision 5f8a385ac83bf26188b3ab58ce985a3b45dfc96f to
C:/Users/JoHn/AppData/Local/Temp/20150119213334
    executing locally: git clone -q -b master d:\Prace\Project\web\os-project\
 C:/Users/JoHn/AppData/Local/Temp/20150119213334 && cd C:/Users/JoHn/AppData/Loc
al/Temp/20150119213334 && git checkout -q -b deploy 5f8a385ac83bf26188b3ab58ce98
5a3b45dfc96f
    command finished in 2694ms
  * Compressing C:/Users/JoHn/AppData/Local/Temp/20150119213334 to C:/Users/JoHn
/AppData/Local/Temp/20150119213334.tar.gz
    executing locally: tar czf 20150119213334.tar.gz 20150119213334
    command finished in 2761ms
    servers: ["10.0.0.61"]
kunesd@10.0.0.61's password:
 ** sftp upload C:/Users/JoHn/AppData/Local/Temp/20150119213334.tar.gz -> /tmp/2
0150119213334.tar.gz
    [10.0.0.61] /tmp/20150119213334.tar.gz
    [10.0.0.61] done
  * sftp upload complete
  * executing "cd /var/www/html/project/releases && tar xzf /tmp/20150119213334
.tar.gz && rm /tmp/20150119213334.tar.gz"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 491ms
  * 2015-01-19 22:34:33 executing `deploy:finalize_update'
  * executing "chmod -R g+w /var/www/html/project/releases/20150119213334"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 264ms
--> Creating cache directory
  * executing "sh -c 'if [ -d /var/www/html/project/releases/20150119213334/app
/cache ] ; then rm -rf /var/www/html/project/releases/20150119213334/app/cache;
 fi'"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 260ms
  * executing "sh -c 'mkdir -p /var/www/html/project/releases/20150119213334/ap
p/cache && chmod -R 0777 /var/www/html/project/releases/20150119213334/app/cach
e'"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 94ms
  * executing "chmod -R g+w /var/www/html/project/releases/20150119213334/app/c
ache"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 153ms
  * 2015-01-19 22:34:34 executing `deploy:share_childs'
--> Creating symlinks for shared directories
  * executing "mkdir -p /var/www/html/project/shared/app/logs"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 292ms
  * executing "sh -c 'if [ -d /var/www/html/project/releases/20150119213334/app
/logs ] ; then rm -rf /var/www/html/project/releases/20150119213334/app/logs; f
i'"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 320ms
  * executing "ln -nfs /var/www/html/project/shared/app/logs /var/www/html/anim
alco/releases/20150119213334/app/logs"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 292ms
  * executing "mkdir -p /var/www/html/project/shared/web/uploads"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 160ms
  * executing "sh -c 'if [ -d /var/www/html/project/releases/20150119213334/web
/uploads ] ; then rm -rf /var/www/html/project/releases/20150119213334/web/uplo
ads; fi'"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 210ms
  * executing "ln -nfs /var/www/html/project/shared/web/uploads /var/www/html/a
nimalco/releases/20150119213334/web/uploads"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 310ms
--> Normalizing asset timestamps
  * executing "find /var/www/html/project/releases/20150119213334/web/css /var/
www/html/project/releases/20150119213334/web/images /var/www/html/project/rele
ases/20150119213334/web/js -exec touch -t 201501192134.36 {} ';' &> /dev/null ||
 true"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 303ms
    triggering after callbacks for `deploy:finalize_update'
  * 2015-01-19 22:34:36 executing `symfony:composer:install'
    triggering before callbacks for `symfony:composer:install'
  * 2015-01-19 22:34:36 executing `symfony:composer:get'
  * executing "if [ -e /var/www/html/project/releases/20150119213334/composer.p
har ]; then echo 'true'; fi"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 290ms
--> Downloading Composer
  * executing "sh -c 'cd /var/www/html/project/releases/20150119213334 && curl
-s http://getcomposer.org/installer | php'"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
 ** [out :: 10.0.0.61] #!/usr/bin/env php
 ** [out :: 10.0.0.61] All settings correct for using Composer
 ** [out :: 10.0.0.61] Downloading...
 ** [out :: 10.0.0.61]
 ** [out :: 10.0.0.61] Composer successfully installed to: /var/www/html/animalc
o/releases/20150119213334/composer.phar
 ** [out :: 10.0.0.61]
 ** [out :: 10.0.0.61] Use it: php composer.phar
    command finished in 11613ms
--> Installing Composer dependencies
  * executing "sh -c 'cd /var/www/html/project/releases/20150119213334 && SYMFO
NY_ENV=prod php composer.phar install --no-dev --verbose --prefer-dist --optimiz
e-autoloader --no-progress'"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 314ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /var/www/html/project/releases/20150119213334; true"
    servers: ["10.0.0.61"]
    [10.0.0.61] executing command
    command finished in 320ms
failed: "sh -c 'sh -c '\''cd /var/www/html/project/releases/20150119213334 &&
SYMFONY_ENV=prod php composer.phar install --no-dev --verbose --prefer-dist --op
timize-autoloader --no-progress'\'''" on 10.0.0.61

我发现了很多命令及其组合,所以我的 deploy.rb 有很多命令的注释供以后使用。

set :application, "project"
set :domain,      "10.0.0.61"
set :deploy_to,   "/var/www/html/project"
set :app_path,    "app"
set :user,        "kunesd"

#ssh_options[:forward_agent] = true
#ssh_options[:port] = "22"
set :branch, "master"

# set :symfony_env_prod, "dev"

set   :scm,           :git
set   :repository,    "d:\Prace\Project\web\os-project\"
set   :deploy_via,    :copy
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `subversion`, `mercurial`, `perforce`, or `none`

set :model_manager, "doctrine"
# Or: `propel`

role :web,        domain                         # Your HTTP server, Apache/etc
role :app,        domain, :primary => true       # This may be the same as your `Web` server

# Composer settings
# set :use_composer, true
#set :use_composer_tmp, true
# set :update_vendors, false
#set :vendors_mode, "install"

# General settings
#set :shared_files,    ["app/config/parameters.yml"]
#set :shared_children, [app_path + "/logs", web_path + "/uploads"]
set :keep_releases,  3
set :use_sudo, false
#set :writable_dirs,     [app_path + "/logs", app_path + "/cache", web_path + "/uploads"]
#set :webserver_user,    "www-data"
#set :permission_method, :acl
#set :use_set_permissions, true

# Be more verbose by uncommenting the following line
 logger.level = Logger::TRACE

感谢您的回答。

#1更新

错误在我的文件夹结构中:

感谢@Matteo,它成功了,但是有一个新的错误:

  * Installing dependencies from lock file
  * Your requirements could not be resolved to an installable set of packages.
  * Problem 1
  * - Installation request for sensiolabs/security-checker v2.0.0 -> satisfiable
 by sensiolabs/security-checker[v2.0.0].
  * - sensiolabs/security-checker v2.0.0 requires ext-curl * -> the requested PH
P extension curl is missing from your system.
  * Problem 2
  * - sensiolabs/security-checker v2.0.0 requires ext-curl * -> the requested PH
P extension curl is missing from your system.
  * - sensio/distribution-bundle v3.0.8 requires sensiolabs/security-checker ~2.
0 -> satisfiable by sensiolabs/security-checker[v2.0.0].
  * - Installation request for sensio/distribution-bundle v3.0.8 -> satisfiable
by sensio/distribution-bundle[v3.0.8].

#2更新

我的composer.json:

{
    "name": "symfony/framework-standard-edition",
    "license": "MIT",
    "type": "project",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-0": {
            "": "src/",
            "SymfonyStandard": "app/"
        }
    },
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.5.*",
        "doctrine/orm": "~2.2,>=2.2.3",
        "doctrine/doctrine-bundle": "~1.2",
        "twig/extensions": "~1.0",
        "symfony/assetic-bundle": "~2.3",
        "symfony/swiftmailer-bundle": "~2.3",
        "symfony/monolog-bundle": "~2.4",
        "sensio/distribution-bundle": "~3.0",
        "sensio/framework-extra-bundle": "~3.0",
        "incenteev/composer-parameter-handler": "~2.0",
        "components/jquery": "1.9.*",
        "oyejorge/less.php": "~1.5",
        "components/font-awesome": "4.2.0",
        "doctrine/doctrine-fixtures-bundle": "2.2.*",
        "symfony/serializer": "v2.5.7",
        "jms/serializer-bundle": "~0.13",
        "twbs/bootstrap": "3.3.*"
    },
    "require-dev": {
        "sensio/generator-bundle": "~2.3"
    },
    "scripts": {
        "post-root-package-install": [
            "SymfonyStandard\Composer::hookRootPackageInstall"
        ],
        "post-install-cmd": [
            "Incenteev\ParameterHandler\ScriptHandler::buildParameters",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::removeSymfonyStandardFiles"
        ],
        "post-update-cmd": [
            "Incenteev\ParameterHandler\ScriptHandler::buildParameters",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::removeSymfonyStandardFiles"
        ]
    },
    "config": {
        "bin-dir": "bin"
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": {
            "dev-master": "2.5-dev"
        }
    }
}

通过启动 cap 任务来调试您的程序部署:

 cap -dv deploy

并在服务器命令行上自己执行有问题的任务(不要对 capifony 这样做,让任务等待一段时间,否则它会回滚执行而不提示你错误)

然后你就可以理解真正的问题了。

详细来说,真正的问题是共享服务器上缺少 php 扩展 ext-curl。安装部署工作正常。

现在的问题是正确的 Web 文件夹上的 Web 服务器配置