Forum: NGINX symfony php configuration

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
shaktale (Guest)
on 2009-04-29 19:27
(Received via mailing list)
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:
http://forum.nginx.org/read.php?2,1549,1549#msg-1549
Jb j. (Guest)
on 2009-05-01 02:58
Anyone?

I would be interested in the answer to this too.
shaktale (Guest)
on 2009-05-05 12:40
(Received via mailing list)
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:
http://forum.nginx.org/read.php?2,1549,1769#msg-1769
shaktale (Guest)
on 2009-05-14 16:01
(Received via mailing list)
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:
http://forum.nginx.org/read.php?2,1549,2020#msg-2020
Igor S. (Guest)
on 2009-05-14 16:18
(Received via mailing list)
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;
shaktale (Guest)
on 2009-05-18 13:02
(Received via mailing list)
>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:
http://forum.nginx.org/read.php?2,1549,2142#msg-2142
Zheng, Wenxing (NSN - CN/Beijing) (Guest)
on 2009-05-20 10:32
(Received via mailing list)
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
Delta Y. (Guest)
on 2009-05-20 10:43
(Received via mailing list)
I think you should use handler instead of filter.
Please refer to http://www.evanmiller.org/nginx-modules-guide.html
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) 
<removed_email_address@domain.invalid>
Mikel A. (Guest)
on 2009-05-22 23:19
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.

http://dev.xxxxxx.com/admin.php/matche => No input file specified.

Merci.
Igor S. (Guest)
on 2009-05-23 00:04
(Received via mailing list)
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.
>
> http://dev.xxxxxx.com/admin.php/matche => 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)(.*)$ {
Mikel A. (Guest)
on 2009-05-23 15:12
> 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;

-----------------
Igor S. (Guest)
on 2009-05-23 19:35
(Received via mailing list)
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.
This topic is locked and can not be replied to.