Forum: NGINX drupal try_files php fastcgi

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.
Otto Bretz (Guest)
on 2009-03-14 12:22
(Received via mailing list)
Hi,

I'm having trouble getting $subject to work. I'm running 0.6.35 with
the try_files patch. I tried to follow the config posted in [1]. My
current config can be found at [2].

I'm also not able to get a simple phpinfo page to work,
http://themansion.mine.nu/test1/. Drupal is installed in
http://themansion.mine.nu/test2/

I launched my fcgi process with:
spawn-fcgi -a 127.0.0.1 -p 10005 -u www -g www -f
/usr/local/bin/php-fastcgi

Php is from the OpenBSD ports tree.
#php-fastcgi -v
PHP 5.2.9 with Suhosin-Patch 0.9.6.3 (cgi-fcgi) (built: Mar 12 2009
18:35:04)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
    with Suhosin v0.9.27, Copyright (c) 2007, by SektionEins GmbH

Any hints as to what I'm missing?

[1] http://www.ruby-forum.com/topic/173439
[2] http://www.giuntilabs.net/files/nginx/nginx.conf
[3] http://www.giuntilabs.net/files/nginx/error.log
[4] http://www.giuntilabs.net/files/nginx/build.txt

cheers,
Otto
Igor S. (Guest)
on 2009-03-14 17:58
(Received via mailing list)
On Sat, Mar 14, 2009 at 11:14:00AM +0100, Otto Bretz wrote:

> Hi,
>
> I'm having trouble getting $subject to work. I'm running 0.6.35 with
> the try_files patch. I tried to follow the config posted in [1]. My
> current config can be found at [2].
>
> I'm also not able to get a simple phpinfo page to work,
> http://themansion.mine.nu/test1/. Drupal is installed in
> http://themansion.mine.nu/test2/

This line

2009/03/14 10:59:00 [error] 17863#0: *31 directory index of
"/var/www/htdocs/tes
t1/" is forbidden, client: 90.227.72.67, server: _, request: "GET
/test1/ HTTP/1
.1", host: "themansion.mine.nu"

means that you have no index file in /test1/ - /test1/index.html
(default
index file):

        location / {
            root   /var/www/htdocs;
            #index  index.html index.htm;
            try_files      $uri  $uri/  @drupal;
        }

What file should handle index of /test1/ ?
Otto Bretz (Guest)
on 2009-03-16 11:15
(Received via mailing list)
On Sat, Mar 14, 2009 at 4:44 PM, Igor S. <removed_email_address@domain.invalid> 
wrote:
> What file should handle index of /test1/ ?

index.php. I changed the index directive and now I only get these
messages and a page temporarily unavailable page:
2009/03/16 08:30:16 [error] 27364#0: *37 could not find named location
"@drupal", client: 10.0.1.10, server: _, request: "GET /test1/
HTTP/1.1", host: "10.0.1.11"
2009/03/16 08:30:46 [error] 27364#0: *39 could not find named location
"@drupal", client: 10.0.1.10, server: _, request: "GET /test2/
HTTP/1.1", host: "10.0.1.11"

Could it be something wrong with the fcgi setup?

/Otto
Igor S. (Guest)
on 2009-03-16 12:48
(Received via mailing list)
On Mon, Mar 16, 2009 at 10:03:41AM +0100, Otto Bretz wrote:

> On Sat, Mar 14, 2009 at 4:44 PM, Igor S. <removed_email_address@domain.invalid> wrote:
> > What file should handle index of /test1/ ?
>
> index.php. I changed the index directive and now I only get these

Then you probably need:

        location / {
            root   /var/www/htdocs;
            try_files      $uri  $uri/index.php  @drupal;
        }

> messages and a page temporarily unavailable page:
> 2009/03/16 08:30:16 [error] 27364#0: *37 could not find named location
> "@drupal", client: 10.0.1.10, server: _, request: "GET /test1/
> HTTP/1.1", host: "10.0.1.11"
> 2009/03/16 08:30:46 [error] 27364#0: *39 could not find named location
> "@drupal", client: 10.0.1.10, server: _, request: "GET /test2/
> HTTP/1.1", host: "10.0.1.11"
>
> Could it be something wrong with the fcgi setup?

Have you @drupal location ?
mike (Guest)
on 2009-03-16 18:38
(Received via mailing list)
2009/3/16 Igor S. <removed_email_address@domain.invalid>:

> Have you @drupal location ?

This is one thing I want to get up on the wiki cookbook, a simple

@wordpress
@drupal

etc.

Simple being the key word.

A lot of people do wordpress crap with wp-content/*.js and all these
other filters and all you need is a simple

if (!-e $request_filename) {}
or
try_files $uri $uri/ @wordpress
or
try_files $uri $uri/ /path/to/main/wordpress/index.php

etc.

right now i run my blog using this:

error_page 404 = /wordpress/index.php?q=$request_uri;

works like a charm. i do want to start using try_files as I assume
that is more efficient and not kind of a silly hack "hey, if it's a
404, use -this- as the page handler!"
Cliff W. (Guest)
on 2009-03-16 19:00
(Received via mailing list)
http://wiki.nginx.org/NginxJoomla

I find that basic recipe works for a lot of PHP frameworks.

Cliff
Igor S. (Guest)
on 2009-03-16 19:24
(Received via mailing list)
On Mon, Mar 16, 2009 at 09:51:55AM -0700, Cliff W. wrote:

> http://wiki.nginx.org/NginxJoomla
>
> I find that basic recipe works for a lot of PHP frameworks.

Does Joomla require "/index.php?q=$request_uri" ?
When I have checked on their site, just /index.php was enough.

It's better to use try_files:

root  /path/to/root;

location / {
    try_files      $uri  $uri/  @fallback;
}

location ~ \.php$ {
    try_files      $uri  @fallback;

    fastcgi_pass   ...;

    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    # or just
    #    fastcgi_param  SCRIPT_FILENAME  $document_root$uri;
    # as here $fastcgi_script_name == $uri
    fastcgi_param  QUERY_STRING     $query_string;

    # other fastcgi_param's
}

location @fallback {
    fastcgi_pass   ...;

    fastcgi_param  SCRIPT_FILENAME  $document_root/index.php;
    fastcgi_param  QUERY_STRING     q=$request_uri;

    # other fastcgi_param's
}

Probably, you can use omit @fallback:

location / {
    try_files      $uri  $uri/  /index.php?q=$request_uri;
}

location ~ \.php$ {
    try_files      $uri  /index.php?q=$request_uri;
    ...
}
Igor S. (Guest)
on 2009-03-16 19:26
(Received via mailing list)
On Mon, Mar 16, 2009 at 09:26:52AM -0700, mike wrote:

>
> Simple being the key word.

Yes. I have some configuration (Russain):
http://sysoev.ru/nginx/docs/http/ngx_http_core_mod...

It should be tested thoroughly by PHP and Mongrel users and included in
wiki.
Cliff W. (Guest)
on 2009-03-16 19:29
(Received via mailing list)
On Mon, 2009-03-16 at 20:12 +0300, Igor S. wrote:
> On Mon, Mar 16, 2009 at 09:51:55AM -0700, Cliff W. wrote:
>
> > http://wiki.nginx.org/NginxJoomla
> >
> > I find that basic recipe works for a lot of PHP frameworks.
>
> Does Joomla require "/index.php?q=$request_uri" ?
> When I have checked on their site, just /index.php was enough.

No idea.  I've only installed it for a few sites and with limited
testing (I quit testing when it worked ;-)

>
>
>
> location / {
>     try_files      $uri  $uri/  /index.php?q=$request_uri;
> }
>
> location ~ \.php$ {
>     try_files      $uri  /index.php?q=$request_uri;
>     ...
> }

Thanks,

I'll give this a try and update the wiki.

Cliff
Mark A. (Guest)
on 2009-03-16 22:55
(Received via mailing list)
Igor S. wrote:
> Probably, you can use omit @fallback:
>
> location / {
>     try_files      $uri  $uri/  /index.php?q=$request_uri;
> }
>
> location ~ \.php$ {
>     try_files      $uri  /index.php?q=$request_uri;
>     ...
> }

==> System: Drupal 6.10 + Ubuntu 8.10

==> Using:
(...)
  listen clinica.0:80;
  server_name clinica.0;
  root /var/www/drupal-cgm;
(...)
  location / {
    try_files $uri $uri/ /index.php?q=$request_uri;
  }

  location ~ \.php$ {
    try_files $uri /index.php?q=$request_uri;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass unix:/tmp/php-fastcgi.socket;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }


==> going to: http://clinica.0/index.php
Gets to Drupal's intro page but, clicking
at the login button gets a "500 Internal Server Error" and the error
log:
"2009/03/16 20:30:25 [error] 11343#0: *3 rewrite or internal redirection
cycle while internal redirect to "/index.php?q=/node?destination=node",
client: 127.0.0.1, server: clinica.0, request: "POST
/node?destination=node HTTP/1.1", host: "clinica.0", referrer:
"http://clinica.0/index.php""

==> going to: http://clinica.0/
gives a "403 Forbidden" and the error log:
"2009/03/16 20:34:04 [error] 11343#0: *4 directory index of
"/var/www/drupal-cgm/" is forbidden, client: 127.0.0.1, server:
clinica.0, request: "GET / HTTP/1.1", host: "clinica.0""

==> going to: http://clinica.0/benchtest.php
correctly executes the php script

==> going to: http://clinica.0/test
Should give a "Page not found", but instead gives: "500 Internal Server
Error" and the error log:
2009/03/16 20:39:14 [error] 11343#0: *15 rewrite or internal redirection
cycle while internal redirect to "/index.php?q=/test", client:
127.0.0.1, server: clinica.0, request: "GET /test HTTP/1.1", host:
"clinica.0"
This topic is locked and can not be replied to.