Symfony php configuration

Hi all.

In a previous post, Igor says:

“If you have “if ($uri” in configuration, this means that your
configuraiton
is far from optimal and has hidden agendas.”

I’m using nginx + phpfpm + symfony framework and it’s working fine.

I take my configuration from this list, from an older post related to
symfony.

location / {

# If the file exists as a static file serve it directly without
# running all the other rewite tests on it
if (-f $request_filename) {
  expires max;
  break;
}

if ($request_filename !~ "\.(js|htc|ico|gif|jpg|png|css)$") {
  rewrite ^(.*) /index.php last;
}

}

location /sf/ {
root /usr/share/pear/data/symfony/web/;
}

location ~ .php($|/) {
set $script $uri;
set $path_info “”;

if ($uri ~ "^(.+\.php)(/.+)") {
  set  $script     $1;
  set  $path_info  $2;
}

fastcgi_pass   127.0.0.1:9000;

include /usr/local/nginx/conf/fastcgi_params;

fastcgi_param  PATH_INFO        $path_info;
fastcgi_param  SCRIPT_FILENAME  $document_root$script;
fastcgi_param  SCRIPT_NAME      $script;

}

Please, is there a more optimal configuration without “if $uri”, using
try_files ?

Thanks in advance.

Posted at Nginx Forum:

Anyone?

I would be interested in the answer to this too.

Anyone, please ?

I think that symfony, is an emergent framework, an optimal configuration
for nginx will be much appreciated for the symfony comunity.

Thanks again

Posted at Nginx Forum:

Hi again,

If anyone is still interested, finally I have changed the following:

location / {

If the file exists as a static file serve it directly without

running all the other rewite tests on it

if (-f $request_filename) {
expires max;
break;
}

if ($request_filename !~ “.(js|htc|ico|gif|jpg|png|css)$”) {
rewrite ^(.*) /index.php last;
}
}

For:

location / {
try_files $uri /index.php;

expires max;

}

AFAIK the block related to if ($uri ~ “^(.+.php)(/.+)”) must to be set
as such, because is related to symfony’s url routing, ie:

mysite.com/debugger.php/myaction/show/33

Hope this helps.

Posted at Nginx Forum:

location ~ ^(.+.php)(.)$ {
fastcgi_split_path_info ^(.+.php)(.
)$;
fastcgi_param SCRIPT_FILENAME /path/to/php$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;

Works like a charm, but I need to include:

fastcgi_param SCRIPT_NAME $fastcgi_script_name;

Thank you Igor.

Posted at Nginx Forum:

On Thu, May 14, 2009 at 07:52:21AM -0400, shaktale wrote:

   break;

mysite.com/debugger.php/myaction/show/33

location ~ ^(.+.php)(.)$ {
fastcgi_split_path_info ^(.+.php)(.
)$;
fastcgi_param SCRIPT_FILENAME /path/to/php$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;

I think you should use handler instead of filter.
Please refer to Emiller’s Guide to Nginx Module Development – Evan Miller
We can discuss the detail at
http://groups.google.com/group/cnginx?hl=zh-CN
in Chinese.

2009/5/20 Zheng, Wenxing (NSN - CN/Beijing) [email protected]

Dear all,

I am a newbie to Nginx.

I plan to implement a WEB Service based on the Nginx. After the WEB
Service
receiving the request with XML over https, it would parse the request,
process
the request and then send back the response.

What is the best way to implement this service? using the body filter?

Appreciated for your kindly help

Thanks

Best regards, Zheng wenxing

shaktale wrote:

location ~ ^(.+.php)(.)$ {
fastcgi_split_path_info ^(.+.php)(.
)$;
fastcgi_param SCRIPT_FILENAME /path/to/php$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;

Works like a charm, but I need to include:

fastcgi_param SCRIPT_NAME $fastcgi_script_name;

Thank you Igor.
Bonjour ^^

Can you give your configuration.


server {
    listen       80;
    server_name  dev.xxxx.com www.dev.xxxxx.com;
    access_log  /var/log/nginx/dev.xxxxxx_access.log combined;
    root /data/www/dev/web;
    index  index.html index.htm index.php;

location / {
try_files $uri /index.php;
expires max;}

location ~ .php$ {
fastcgi_pass unix:/dev/shm/php.socket;}

location ~ ^(.+.php)(.)$ {
fastcgi_split_path_info ^(.+.php)(.
)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass unix:/dev/shm/php2.socket;}

location /sf/ {
root /usr/share/php/data/symfony/web;}

location ~ /.ht {
deny all;}}


It does not work with these parameters.

xxxxx.com => No input file specified.

Merci.

Igor S. wrote:
You did not set

fastcgi_param SCRIPT_FILENAME /path/to/php$fastcgi_script_name;

and some other probably needed parameters inside
location ~ .php$ {
and
location ~ ^(.+.php)(.*)$ {
Yet I have the settings in the file fastcgi_params, includes nginx.conf:


events {
worker_connections 1024;
use epoll;}

http {



include fastcgi_params;


k26:nginx/conf# cat fastcgi_params

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $request_uri;
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;


On Sat, May 23, 2009 at 01:12:49PM +0200, Mikel Arteta wrote:

include fastcgi_params;

fastcgi_param DOCUMENT_ROOT $document_root;


The silnge
fastcgi_param PATH_INFO $fastcgi_path_info;
overrides all inherited fastcgi_param’s. Threfore you should include it
inside “location ~ ^(.+.php)(.*)$”.

Also, note wrong
fastcgi_param PATH_INFO $request_uri;
in the file.

On Fri, May 22, 2009 at 09:19:39PM +0200, Mikel Arteta wrote:

    listen       80;

fastcgi_pass unix:/dev/shm/php.socket;}
deny all;}}


It does not work with these parameters.

xxxxx.com => No input file specified.

You did not set

fastcgi_param SCRIPT_FILENAME /path/to/php$fastcgi_script_name;

and some other probably needed parameters inside
location ~ .php$ {
and
location ~ ^(.+.php)(.*)$ {