Skip to content

Nginx version 1.0.0 stable

  • by

Nginx version 1.0.0 stable was just released and during the upgrade I encountered some problems and had to change several things about my setup to get everything running again.

1. Errors trying to upgrade Nginx

There is a problem when you add the stable ppa and try to upgrade to 1.0.0, as referenced in this bug tracked here:

https://bugs.launchpad.net/nginx/+bug/726408

I managed to get round it by doing a autoremove – f on all the mentioned entries, e.g.

$ apt-get autoremove -f nginx-common nginx-full nginx

And then installed normally.

2. Changes to site setup and fastcgi.conf

I moved all the fastgi params out into fastcgi.conf to tidy things up a bit. I also had to completely change my sites-available/default config. I’ve updated my original post with the example below:

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx;
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  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

sites-enabled/default is now a symlink to sites-available/default

upstream php {
        server 127.0.0.1:9000;
}

server {
     listen   80;
     server_name  mywebsite.com;
     rewrite   ^  http://www.mywebsite.com$request_uri? permanent;
}

server
{
    listen   80;
    server_name  www.mywebsite.com;
    access_log  /var/log/nginx/localhost.access.log;
    server_name_in_redirect off;
    index index.php;
    root /var/www;

    location / {
    # This is cool because no php is touched for static content
        try_files $uri $uri/ /index.php;
        }

    #send php requests to fast cgi
    location ~ .php$ {
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        fastcgi_pass php;
        include fastcgi.conf;
        }


    #rewrite rule for files
     location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
        expires max;
        log_not_found off;
        }

    #rewrite rule for sitemap under the lines that handles upload files
    rewrite ^(.*/)?sitemap.xml wp-content/sitemap.php;

}
Tags: