Configuration Nginx pour WordPress

Le 18/01/2012

Cette configuration ne prend pas en compte l’utilisation du plugin w3 total cache

server {
    listen      127.0.0.1:80 default;
    server_name  _;

    location / {
        root    /var/www;
        index   index.php index.html index.htm;

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

        location = /favicon.ico {
            log_not_found off;
            access_log off;
        }

        location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;
        }

        location ~ /\. {
            deny all;
            access_log off;
            log_not_found off;
        }

        gzip on;
        gzip_types text/css application/x-javascript text/x-component text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
        location ~ \.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml)$ {
            try_files $uri $uri/ $uri.html /index.php?$args;
        }

        location ~ \.php$ {
            fastcgi_pass   php;
            fastcgi_index  index.php;
            include fastcgi_params;
            fastcgi_ignore_client_abort     off;
        }
    }
}

Si vous avez le fichier fastcgi_params de base, voici celui que j’utilise :

fastcgi_param  CONTENT_LENGTH     $content_length;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REDIRECT_STATUS    200;
fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_NAME        $server_name;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  SERVER_SOFTWARE    nginx;
fastcgi_intercept_errors on;

Articles parlant du même sujet :

Ajouter un commentaire

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>