我已经设置了一个暂存环境(uat)。目的是将所有电子邮件重定向到一个电子邮件地址或最坏情况下禁用电子邮件功能。 我的问题是,尽管进行了以下设置,但应用程序仍然会在prod环境中发送电子邮件。
# config_uat.yml
imports:
- { resource: config.yml }
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
swiftmailer:
transport: smtp
host: 127.0.0.1
port: 25
encryption: null
sender_address: info@gpsc.cwtwebpem.com
logging: "%kernel.debug%"
delivery_address: 'bastien@vial-collet.fr'
disable_delivery: true
并且:
#config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: "@psmdbBundle/Resources/config/services.yml" }
- { resource: "@psmdbBundle/Resources/config/version.yml" }
# Swiftmailer Configuration
swiftmailer:
transport: smtp
host: 127.0.0.1
port: 25
encryption: null
sender_address: info@domain.com
logging: "%kernel.debug%"
[编辑]
我已经设置了app_uat.php。它基于app.php:
<?php
use Symfony\Component\ClassLoader\ApcClassLoader;
use Symfony\Component\HttpFoundation\Request;
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
// Use APC for autoloading to improve performance.
// Change 'sf2' to a unique prefix in order to prevent cache key conflicts
// with other applications also using APC.
/*
$loader = new ApcClassLoader('sf2', $loader);
$loader->register(true);
*/
//require_once __DIR__.'/../app/AppKernel.php';
//require_once __DIR__.'/../app/AppCache.php';
$kernel = new AppKernel('uat', false);
$kernel->loadClassCache();
//$kernel = new AppCache($kernel);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
[编辑2] 我检查过并且prod环境正在运行而不是uat。 我无法设置我的apache配置来运行uat ......这是:
<VirtualHost *:80>
ServerName uat.gpsc.domain.com
DocumentRoot /var/www/vhosts/uat.gpsc.domain.com/current/web
<Directory /var/www/vhosts/uat.gpsc.domain.com/current/web>
AllowOverride All
Require all granted
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app_uat.php [QSA,L]
</IfModule>
</Directory>
ErrorLog /var/log/apache2/uat.project_error.log
CustomLog /var/log/apache2/uat.project_access.log combined
</VirtualHost>
答案 0 :(得分:1)
您是否通过 app_uat.php 访问该网站? (你应该已经在web目录中创建了一个新的前端控制器文件)并且在那个文件中,你应该设置:
$kernel = new AppKernel('uat', true);//or 'uat', false
这是http://symfony.com/doc/current/configuration/environments.html
中描述的过程如果您创建了app_uat.php,请使用app_uat.php更新您的答案。
编辑:这是您设置Apache 的方式的问题,因为您的app_uat文件似乎是正确的。但是我会留下我的答案的前一部分,万一其他人需要它(这是一个很好的第一步)。
从查看您的apache配置文件,一切似乎都很好。但请确保:
删除行<IfModule mod_rewrite.c>
及其结束标记...所以你不得不打开重写模块! sudo a2enmod rewrite
激活Apache的重写模块。
确保重新启动apache sudo service apache2 restart
AllowOverride All
表示任何htaccess文件都可以覆盖该行为。确保没有发生这种情况。通过执行ls -a