I installed nginx and would like to setup wordpress as a final step. I followed many howtos but am unable to get it working.

The setup is fairly straightforward, the root dir of the webserver is /data/Sites/nkr1pt.homelinux.net. In that root dir I created a symlink to the wordpress folder in /usr/local/wordpress, so in fact all wordpress files can be accessed at /data/Sites/nkr1pt.homelinux.net/wordpress. Permissions are ok.

The plan is to get wordpress working at http://sirius/wordpress, the server's name is sirius. spawn-fcgi is running and listening on port 7777.

Here you can see the relevant config:

server {
    listen       80;
listen       8080;
    server_name  sirius;

root /data/Sites/nkr1pt.homelinux.net;
passenger_enabled on;
    passenger_base_uri /redmine;

    #charset koi8-r;

    #access_log  logs/access.log  main;

location ^~ /data {
   root /data/Sites/nkr1pt.homelinux.net;
   autoindex on;
   auth_basic "Restricted";
   auth_basic_user_file htpasswd;
}

    location ^~ /dump {
        root   /data/Sites/nkr1pt.homelinux.net;
        autoindex on;
    }

location ^~ /wordpress {
       try_files $uri $uri/ /wordpress/index.php;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:7777
    location ~ \.php$ {
    #fastcgi_split_path_info ^(/wordpress)(/.*)$;
        fastcgi_pass   localhost:7777;
        #fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    #index     index.php;
    }

please note that redmine, and the locations dump and data are working perfectly, it is only wordpress that I cannot get to work.

Can you please help me to the correct wordpress configuration in nginx? All help is much appreciated!

link|improve this question
Remeber that Igor Sysoev (nginx author) strongly disagree with running apps on nginx. He is very taxative that nginx is to be used as a proxy between the outside and app servers. – coredump Feb 18 '11 at 21:18
feedback

2 Answers

From what I've seen the main thing to get wordpress working is to translate the mod_rewrite rules into nginx format. The format is:

if (!-e $request_filename)
{
    rewrite ^(.+)$ /index.php?q=$1 last;
}

You are also missing

root /path/to/wordpress

In that subsection.

Otherwise, is there a particular error you are seeing? What do the error logs show?

link|improve this answer
I added the rewrite and root parts in location ~ \.php$ error.log gives no errors, when i try to load sirius/wordpress in the browser it shows a popup to download a BIN file; file content is php source from wordpress: define('WP_USE_THEMES', true); /** Loads the WordPress Environment and Template */ require('./wp-blog-header.php'); – nkr1pt Feb 18 '11 at 21:13
with editing and trying the nginx config file I also noticed 'input file is not specified' which seems to come from wordpress – nkr1pt Feb 18 '11 at 21:17
feedback

Use a server level rewrite. You should adjust all other locations. Oh and BTW, your setup is insecure. You should use a nested location or fastcgi_split_path_info. You can check my WP config on github for a nested location approach.

Anyway here's your request answered:


 rewrite ^ http://$host/wordpress$request_uri? permanent;
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.