Nginx 上的 symfony 2.8 pre prod 部署错误 500

symfony 2.8 preprod deployement error 500 on nginx

我试图在 nginx prepod 服务器上部署我的 symfony 2.8 应用程序。 项目在本地 nginx 服务器和其他 nginx 测试服务器上运行良好。

我关注了:

git clone the project
composer install --optimize-autoloader
cache:clear --env=prod

我在我的项目中没有使用学说,我使用的是 api。

我的 nginx error.log 出现了几个错误,因为我尝试多次启动 composer install 和 composer update,因为我认为这是供应商安装问题。

这是我遇到的不同错误:

Cannot redeclare class Symfony\Component\Config\Resource\SelfCheckingResourceChecker in /home/l4mmobile/public_html/v2/vendor/symfony/symfony/src/Symfony/Component/Config/Resource/SelfCheckingResourceChecker.php on line 24 Cannot redeclare class symfony\component\classloader\apcclassloader Interface 'Symfony\Component\EventDispatcher\EventDispatcherInterface' not found in /home/l4mmobile/public_html/v2/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php on line 29" Interface 'Symfony\Component\Config\Resource\ResourceInterface' not found in /home/l4mmobile/public_html/v2/vendor/symfony/symfony/src/Symfony/Component/Config/Resource/SelfCheckingResourceInterface.php on line 21" Interface 'Symfony\Component\Routing\Matcher\RequestMatcherInterface' not found in /home/l4mmobile/public_html/v2/app/cache/prod/classes.php Interface 'Symfony\Component\Routing\RequestContextAwareInterface' not found in home/l4mmobile/public_html/v2/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php on line 24"

app.php

use Symfony\Component\ClassLoader\ApcClassLoader;
use Symfony\Component\HttpFoundation\Request;
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
$apcLoader = new ApcClassLoader('l4m_site_mobile_v2', $loader);
$loader->unregister();
$apcLoader->register(true);
require_once __DIR__.'/../app/AppKernel.php';
$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);

composer.json

{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
    "psr-4": {
        "": "src/",
        "SymfonyStandard\": "app/SymfonyStandard/"
    }
},
"require": {
    "php": ">=5.4.4",
    "symfony/symfony": "~2.8",
    "doctrine/orm": "~2.2,>=2.2.3,<2.5",
    "doctrine/dbal": "<2.5",
    "doctrine/doctrine-bundle": "~1.4",
    "symfony/assetic-bundle": "~2.4",
    "symfony/swiftmailer-bundle": "~2.3",
    "symfony/monolog-bundle": "~2.4",
    "sensio/distribution-bundle": "~4.0",
    "sensio/framework-extra-bundle": "~3.0,>=3.0.2",
    "incenteev/composer-parameter-handler": "~2.0",
    "guzzle/guzzle": "3.9.*",
    "guzzlehttp/guzzle" : "5.3.1",
    "keeguon/oauth2-php": "1.3.6",
    "facebook/php-sdk": "3.2.0",
    "friendsofsymfony/facebook-bundle": "1.3.0",
    "symfony/intl": "^2.8",
    "monolog/monolog": "^1.20",
    "twig/extensions": "^1.4"
},
 "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",
        "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::prepareDeploymentTarget"
    ],
    "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",
        "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::prepareDeploymentTarget"
    ]
},
"config": {
    "bin-dir": "bin"
},
"extra": {
    "symfony-app-dir": "app",
    "symfony-web-dir": "web",
     "symfony-assets-install": "relative",
    "incenteev-parameters": {
        "file": "app/config/parameters.yml"
    },
    "branch-alias": {
        "dev-master": "2.8-dev"
    }
}

}

希望我的努力可以帮助到其他开发者。 我使用 this bundle 清除 apc 缓存,一切恢复正常