• I run WordPress 2.5 under Apache 2.2 on a RedHat 5 ES server with no
    problems, and use Nginx to serve images, but I can’t seem to get the
    right configuration to run WordPress under Nginx 0.6.29. I have a script that launches /usr/bin/spawn-fcgi on localhost IP 127.0.0.1 using port 7741, and runs the process as php-cgi.

    Once I switch over WordPress to Nginx I can view and interact with the
    Wordpress control panel, which means PHP is working fine, but I can’t
    view the web site home page, or any articles. I get a grey blank page,
    not even a 404 error. I am unable to figure this out without help. I do not use wp-cache, supercache, or any caching plugins. I do use XCache to pre-compile php. My configuration is below.

    server {
    listen my-ip-address:80;
    server_name https://www.mydomain.com mydomain.com;
    index index.php;
    root /var/www/mydomain;
    location ~ .php$ {
    include /usr/local/nginx/conf/fcgi.conf;
    fastcgi_pass 127.0.0.1:7741;
    fastcgi_index /index.php;
    }
    if (!-e $request_filename) {
    rewrite ^(.+)$ /index.php?q=$1 last;
    }
    }

    The fcgi.conf file contains:

    fastcgi_param QUERY_STRING $query_string;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param CONTENT_TYPE $content_type;
    fastcgi_param CONTENT_LENGTH $content_length;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    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;
    fastcgi_param SERVER_PROTOCOL $server_protocol;
    fastcgi_param GATEWAY_INTERFACE CGI/1.1;
    fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
    fastcgi_param REMOTE_ADDR $remote_addr;
    fastcgi_param REMOTE_PORT $remote_port;
    fastcgi_param SERVER_ADDR $server_addr;
    fastcgi_param SERVER_PORT $server_port;
    fastcgi_param SERVER_NAME $server_name;
    # PHP only, required if PHP was built with –enable-force-cgi-redirect
    fastcgi_param REDIRECT_STATUS 200;

Viewing 1 replies (of 1 total)
  • Try this, it’s a clean configuration for WordPress with SEO friendly URLs included:

    Open your nginx configuration file:

    # nano /etc/nginx/nginx.conf

    Locate your domain (example.com) virtual hosting configuration and before “location ~ \.php$ {” add following lines:

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

    At the end your configuration should look as follows:

    server {
        server_name     example.com;
        index           index.php;
        root            /var/www/example.com;
    
        if (!-e $request_filename) {
          rewrite  ^(.*)$  /index.php?q=$1  last;
          break;
        }  
    
        location ~ .php$ {
           fastcgi_pass  localhost:9999;
           fastcgi_index index.php;
           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;
           fastcgi_param REMOTE_ADDR $remote_addr;
           fastcgi_param REMOTE_PORT $remote_port;
           fastcgi_param SERVER_ADDR $server_addr;
           fastcgi_param SERVER_PORT $server_port;
           fastcgi_param SERVER_NAME $server_name;
           fastcgi_param SCRIPT_FILENAME  /var/www/example.com$fastcgi_script_name;
           fastcgi_param QUERY_STRING $query_string;
           fastcgi_param REQUEST_METHOD $request_method;
           fastcgi_param CONTENT_TYPE $content_type;
           fastcgi_param CONTENT_LENGTH $content_length;
        }
    }

    Save and close the file. Restart nginx:

    # /etc/init.d/nginx restart

    Hope this helps. Quoted from this blog.

Viewing 1 replies (of 1 total)
  • The topic ‘Need Help Configuring Nginx to run WordPress 2.5’ is closed to new replies.