Symfony2 + Capifony - 部署期间崩溃

时间:2015-01-19 21:58:09

标签: php symfony deployment capifony

我不知道我是怎么做的。我试图在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。我不知道开发人员如何能够使用此命令。

我的头号日志(在部署到服务器期间):

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更新

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

  • 的.git
  • 规范
  • 图像
  • 网络 - >这是SF项目,但在SF项目的set :repository .git文件夹中需要Capifony。

感谢@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"
        }
    }
}

1 个答案:

答案 0 :(得分:1)

通过启动上限任务来调试您的过程部署:

 cap -dv deploy

并在服务器命令行上执行自己有问题的任务(不要对capifony执行此操作,等待任务等待,否则它将回滚执行而不提示您输入错误)

然后你可以解决真正的问题。

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

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