Symfony 2.2.1 rsync部署 - 不在远程服务器上工作 [英] Symfony 2.2.1 rsync deploy - not working on remote server

查看:393
本文介绍了Symfony 2.2.1 rsync部署 - 不在远程服务器上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我是Symfony的新手,我尝试使用rsync自动执行部署过程,同时保持Symfony的本地和远程安装。到目前为止我做了:




  • 在我的本地机器上安装了Cygwin(Windows 7 + Apache2.2 + PHP 5.3 + MySQL 5.1)

  • 使用命令
    在我的本地机器上执行基本的Symfony安装
    php composer.phar create-project symfony / framework-standard-edition [ path] /2.2.1

  • 使用php-fpm(fastcgi)设置远程LAMP Ubuntu服务器

  • app / config / dir,parameters.yml和parameters.yml.remote中创建本地和远程的两个不同配置文件

  • 创建了一个包含文件列表的 app / config / rsync_exclude.txt 文件到远程服务器的rsync(如本页< a>)

  • 创建了一个从Cygwin运行的部署shell脚本(见下文)。



deploy script 发出命令:

  rsync -avz / cygdrive / c / / user @ server:[remote-path] / --exclude-from = / cygdrive / c / [path] /app/config/rsync_exclude.txt 
ssh user @ server'cd [remote-path] ;& php app / console --env = prod cache:clear&& php app / console cache:clear'
ssh user @ server'mv [remote-path] /app/config/parameters.yml.remote〜/ [remote-path] /app/config/parameters.yml'

rsync ssh mv 命令工作,但部署的站点总是显示HTTP 500错误(包括app.php和app_dev.php)。
查看服务器错误日志的错误是:

 致命错误:类'Composer\\\Autoload\ \ClassLoader'在第23行中的/[remote-path]/vendor/composer/autoload_real.php中找不到

任何线索都会受到欢迎。



编辑 - 这是我的 vendor / composer / autoload_real。 php 文件(对于使问题更长的对不起!):

 <?php 

//由Composer生成的autoload_real.php

class ComposerAutoloaderInit9d50f07556e53717271b583e52c7de25
{
private static $ loader;

public static function loadClassLoader($ class)
{
if('Composer\Autoload\ClassLoader'=== $ class){
require __DIR__。 '/ClassLoader.php';
}
}

public static function getLoader()
{
if(null!== self :: $ loader){
return self :: $ loader;
}

spl_autoload_register(array('ComposerAutoloaderInit9d50f07556e53717271b583e52c7de25','loadClassLoader'),true,true);
self :: $ loader = $ loader = new \Composer\Autoload\ClassLoader();
// ^^^^^^这是第23行,并给出错误^^^^^^^^^^^
spl_autoload_unregister(array('ComposerAutoloaderInit9d50f07556e53717271b583e52c7de25','loadClassLoader'));

$ vendorDir = dirname(__ DIR__);
$ baseDir = dirname($ vendorDir);

$ map = require __DIR__。 '/autoload_namespaces.php';
foreach($ map as $ namespace => $ path){
$ loader-> add($ namespace,$ path);
}

$ classMap = require __DIR__。 '/autoload_classmap.php';
if($ classMap){
$ loader-> addClassMap($ classMap);
}

$ loader-> register(true);

需要$ vendorDir。 '/kriswallsmith/assetic/src/functions.php';
需要$ vendorDir。 '/swiftmailer/swiftmailer/lib/swift_required.php';

return $ loader;
}
}


解决方案

自动加载器与编译器生成的错误,执行...

 作者更新



...将更新您的依赖关系并创建一个新的依赖关系。



如果您要部署到生产系统,请使用 -o 标志调用此命令。



  composer update -o 

我想重新生成自动加载器将解决问题:)


I'm very new to Symfony and I'm trying to automate the deploy process with rsync, while keeping both the local and remote installs of Symfony working.

What I've done so far:

The deploy script issues the commands:

rsync -avz /cygdrive/c/[path]/ user@server:[remote-path]/ --exclude-from=/cygdrive/c/[path]/app/config/rsync_exclude.txt
ssh user@server 'cd [remote-path]/ && php app/console --env=prod cache:clear && php app/console cache:clear'
ssh user@server 'mv [remote-path]/app/config/parameters.yml.remote ~/[remote-path]/app/config/parameters.yml'

The rsync, ssh and mv commands work, but the deployed site shows always a HTTP 500 error (both app.php and app_dev.php). Looking at server error log the error is:

Fatal error:  Class 'Composer\\Autoload\\ClassLoader' not found in /[remote-path]/vendor/composer/autoload_real.php on line 23

Any clue would be more than welcome.

Edit - here is my vendor/composer/autoload_real.php file (sorry for the making the question longer!):

<?php

// autoload_real.php generated by Composer

class ComposerAutoloaderInit9d50f07556e53717271b583e52c7de25
{
    private static $loader;

    public static function loadClassLoader($class)
    {
        if ('Composer\Autoload\ClassLoader' === $class) {
            require __DIR__ . '/ClassLoader.php';
        }
    }

    public static function getLoader()
    {
        if (null !== self::$loader) {
            return self::$loader;
        }

        spl_autoload_register(array('ComposerAutoloaderInit9d50f07556e53717271b583e52c7de25', 'loadClassLoader'), true, true);
        self::$loader = $loader = new \Composer\Autoload\ClassLoader();
        // ^^^^^^ this is line 23 and gives the error ^^^^^^^^^^^
        spl_autoload_unregister(array('ComposerAutoloaderInit9d50f07556e53717271b583e52c7de25', 'loadClassLoader'));

        $vendorDir = dirname(__DIR__);
        $baseDir = dirname($vendorDir);

        $map = require __DIR__ . '/autoload_namespaces.php';
        foreach ($map as $namespace => $path) {
            $loader->add($namespace, $path);
        }

        $classMap = require __DIR__ . '/autoload_classmap.php';
        if ($classMap) {
            $loader->addClassMap($classMap);
        }

        $loader->register(true);

        require $vendorDir . '/kriswallsmith/assetic/src/functions.php';
        require $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php';

        return $loader;
    }
}

解决方案

If there is an error with the autoloader generated by composer, performing ...

composer update

... will update your dependencies and create a new one.

You should invoke the command with the -o flag if you are deploying to a production system.

This way composer generates a classmap autoloader ( which performs way better ) instead of the classic autoloader.

composer update -o

I guess re-generating the autoloader will solve the issue :)

这篇关于Symfony 2.2.1 rsync部署 - 不在远程服务器上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆