Rewrite help needed

Hi All

I am trying to set up a wordpress site using nginx, and I am running
into trouble. Started with the page at
Wordpress as CMS tutorial ~ Robert Basic, software developer making web applications better but things are
not working. I think that my translation
oh an .htaccess file is wrong.

This is the Apache .htaccess file I wish to replace…

RewriteEngine On RewriteBase /blog/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /blog/index.php [L]

This is the file in sites-available. / gives an empty reply, /blog gives
a 404, and index.php?p=1 gives a url of
http://www.domain.com/blog/http:/www.domain.com/blog/hello-world/ and
the page contains “No input file specified”.

Statements for domain.com

server {
listen 80;
#
server_name domain.com www.domain.com ;
root /var/www/domain.com/htdocs;
access_log /var/www/domain.com/access.log combined;
index index.php index.html index.htm;
#
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
# serve static files
if (-f $request_filename) {
# expires 30d;
break;
}
# send all non-existing file or directory requests to index.php
if (!-e $request_filename) {
rewrite ^/blog/(.+)$ index.php?q=$1 last;
}
# password protect /usage
location ^~ /usage/ {
auth_basic “Please login”;
auth_basic_user_file /var/www/domain.com/passwords;
}
# all .php requests to fastcgi using uri.
location ~ .php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
}

I suspect that the solution is really simple, but I can’t see it.
Help much appreciated.

Ian

On Wed, Aug 26, 2009 at 01:57:15PM +0100, Ian H. wrote:

the page contains "No input file specified". # redirect server error pages to the static page /50x.html } }

I suspect that the solution is really simple, but I can’t see it.
Help much appreciated.

location /blog/ {
    try_files  $uri  $uri/  /index.php;
}

location ~ \.php$ {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
}

Igor S. wrote:

This is the file in sites-available. / gives an empty reply, /blog gives
access_log /var/www/domain.com/access.log combined;

send all non-existing file or directory requests to index.php

   include /etc/nginx/fastcgi_params;
}

location ~ \.php$ {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
}

Thanks Igor for your super fast response.

I should have mentioned that I’m on ubuntu and therefore nginx 0.5.33
! No try-files.

So I must either compile nginx on (unfamilar) ubuntu, or work round the
missing try-files.

Regards

Ian

On Wed, Aug 26, 2009 at 02:35:17PM +0100, Ian H. wrote:

oh an .htaccess file is wrong.

root /var/www/domain.com/htdocs;
}
location ~ .php$ {
try_files $uri $uri/ /index.php;
I should have mentioned that I’m on ubuntu and therefore nginx 0.5.33
! No try-files.

So I must either compile nginx on (unfamilar) ubuntu, or work round the
missing try-files.

location /blog/ {
    error_page  404 = /index.php;
}

location ~ \.php$ {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
}

I should have mentioned that I’m on ubuntu and therefore nginx 0.5.33 !
No try-files.

So I must either compile nginx on (unfamilar) ubuntu, or work round the
missing try-files.

Suffer no more:

Jeff Waugh's PPA : Jeff Waugh (for 0.7.x stable branch)
https://launchpad.net/~jdub/+archive/devel (for 0.8.x devel branch)

Built for hardy (8.04 LTS), running in production environments.

  • Jeff

I should have mentioned that I’m on ubuntu and therefore nginx 0.5.33 Â ! Â No
try-files.

So I must either compile nginx on (unfamilar) ubuntu, or work round the
missing try-files.

And i thought Debian Sid was slow keeping up to date with nginx
(latest is 0.7.61 [1]).

The source comes with a configure script, it’s (almost) as simple as
running it. Search the nginx wiki for the modules you want to
add/remove and pertinent configuration/installation and you should do
fine. If you run into trouble the Ubuntu forums are a vast source of
help.

If it’s in the Ubuntu repos, i recommend using “checkinstall” ([2]?)
instead of “make install”, that way you’ll end up with a .deb to
install, which makes things much more clean.

HTH,
Nuno Magalhães

[1] Debian -- Details of package nginx in sid
[2] http://packages.ubuntu.com/dapper/checkinstall

Jeff W. wrote:

Suffer no more:

Jeff Waugh's PPA : Jeff Waugh (for 0.7.x stable branch)
https://launchpad.net/~jdub/+archive/devel (for 0.8.x devel branch)

Built for hardy (8.04 LTS), running in production environment

Hi Jeff,

I installed your repository and public key, and the apt-get update gave
an error…

… $ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys
565B38F9
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring
–secret-keyring /etc/apt/secring.gpg --trustdb-name
/etc/apt/trustdb.gpg --keyring /etc/apt/trusted.gpg --keyserver
keyserver.ubuntu.com --recv-keys 565B38F9
gpg: requesting key 565B38F9 from hkp server keyserver.ubuntu.com
gpg: key 565B38F9: “Jeff W. (jdub) <jdub@ --removed-- .org>” not
changed
gpg: Total number processed: 1
gpg: unchanged: 1
…$ sudo apt-get update
Get: 1 http://ppa.launchpad.net hardy Release.gpg [307B]
Ign http://ppa.launchpad.net hardy/main Translation-en_GB
Get: 2 http://ppa.launchpad.net hardy Release [65.9kB]
Ign http://ppa.launchpad.net hardy Release
Hit http://ppa.launchpad.net hardy/main Packages
…snip…
Fetched 308B in 4s (70B/s)
Reading package lists… Done
W: GPG error: http://ppa.launchpad.net hardy Release: The following
signatures couldn’t be verified because the public key is not available:
NO_PUBKEY ADFBF428E9EEF4A1
W: You may want to run apt-get update to correct these problems

What does this mean?

Regards

Ian

Nuno Magalhães wrote:

Thanks Nuno for the information.

That is the latest stable.

The source comes with a configure script, it’s (almost) as simple as
running it. Search the nginx wiki for the modules you want to
add/remove and pertinent configuration/installation and you should do
fine. If you run into trouble the Ubuntu forums are a vast source of
help.

I managed to configure it to debian default, and then make and make
install on a test machine. I rather suspect that is it now too late for
checkinstall, although it does exist.

Now to release it to the server. Is this right?

Move /usr/local/smin/nginx to the same place, owner root:root, chmod
755.

From /etc/nginx move the files koi-win, koi-utf, win-utf, mine.types,
and fastcgi_params (checking the last for possible edits) to the same
place, all owned root:root, chmod 644.

How to check this before I do the copies and mess up the other 7 sites
on the server?

If it’s in the Ubuntu repos, i recommend using “checkinstall” ([2]?)
instead of “make install”, that way you’ll end up with a .deb to
install, which makes things much more clean.

indeed, installing a deb is nice.

HTH,
Nuno Magalhães

[1] Debian -- Details of package nginx in sid
[2] Ubuntu – Error

Regards

Ian

I installed your repository and public key, and the apt-get update gave
an error…

Looks like you’re trying to give apt my personal key rather than that of
the
PPA. The ID of the PPA is mentioned in the error (and is different from
the
one in your apt-key command).

That said, you don’t need to do any of this. It just makes apt-get
update
quieter (and might avoid a MITM attack, however unlikely).

  • Jeff

Hello!

On Wed, Aug 26, 2009 at 05:44:46PM +0400, Igor S. wrote:

[…]

Thanks Igor for your super fast response.

location ~ \.php$ {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
}

BTW, isn’t error_page fallback actually better in this case as it
doesn’t introduce race condition - while try_files do?

Maxim D.

Jeff W. wrote:

That said, you don’t need to do any of this. It just makes apt-get update
quieter (and might avoid a MITM attack, however unlikely).

  • Jeff

Hi Jeff,

Thanks for the explanation. Perhaps the instructions could be clearer.

I clicked on the “read about installing” link to open the box and found

Step 1: On the PPA’s overview page you’ll see the PPA’s OpenPGP key
id. It’ll look something like this: /1024/12345678/. Copy it, or make a
note of, the portion after the slash, e.g: /12345678/.”

so I clicked the “overview” link in that page, and used the key I found
there.

I suspect I should have used the “Build dependencies signing key” on the
original page.

Regards

Ian