Symfony2 - Nginx / FPM与Apache

时间:2012-04-30 19:30:06

标签: apache symfony nginx php

我遇到Symfony缓存问题。当我使用Apache和Nginx PHP-FPM测试相同的项目(在dev env中)。 Apache速度提高了10倍。 (4900ms vs 500ms)

我在几个进程上做了一些“strace”,我已经看到了Apache Symfony对缓存的关注。但是使用Nginx / FPM,Symfony似乎可以执行所有代码。 (不使用应用程序缓存)

symfony对Apache使用正确缓存而不使用Nginx有什么区别?

或者,在DEV环境中是否有一些与Nginx / FPM有关的特殊配置?

谢谢

= NGINX配置=

location / { 
    index app.php;
    if (-f $request_filename) {
        break;
    }   
    rewrite ^(.*)$ /app.php last;
}
location ~ (app|app_dev).php {
    include /etc/nginx/nginx-fpm.conf;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    fastcgi_param HTTPS off;
}

= /etc/nginx/nginx-fpm.conf ==

fastcgi_pass   unix:/tmp/php-fpm.sock;
fastcgi_index  index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;
fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        80;
fastcgi_param  SERVER_NAME        $server_name;
fastcgi_param  REDIRECT_STATUS    200;

== PHP-FPM ==

[global]
pid = /var/run/php5-fpm.pid
error_log = /var/log/php5-fpm.log
include=/etc/php5/fpm/pool.d/*.conf

= /etc/php5/fpm/pool.d/www.conf =

[www]
user = www-data
group = www-data
listen = /tmp/php-fpm.sock
pm = dynamic
pm.max_children = 10
pm.start_servers = 4
pm.min_spare_servers = 2
pm.max_spare_servers = 6
pm.status_path = /status
access.log = /var/log/fpm/www.access.log
access.format = %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%%
chdir = /

== APC ==

extension=apc.so
apc.shm_segments=1
apc.shm_size=512M
apc.enable_cli=1
apc.include_once_override=1
apc.canonicalize=1
apc.stat="0" ; OR 1 it's the same result

==其他扩展名==

apc.ini
curl.ini
gd.ini
imagick.ini
intl.ini
memcached.ini
memcache.ini
mysqli.ini
mysql.ini
pdo.ini
pdo_mysql.ini
pdo_sqlite.ini
sqlite3.ini
sqlite.ini

0 个答案:

没有答案