Skip to content

Instantly share code, notes, and snippets.

@lukearmstrong
Created October 25, 2013 14:18

Revisions

  1. lukearmstrong created this gist Oct 25, 2013.
    32 changes: 32 additions & 0 deletions nginx-vhost-php.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    server {
    listen 80;
    server_name .example.co.uk.dev;

    access_log /usr/local/var/log/nginx/example.co.uk-access.log;
    error_log /usr/local/var/log/nginx/example.co.uk-error.log error;

    root /var/www/example.co.uk/public;
    index index.php index.html;

    location / {
    try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php {
    fastcgi_index index.php;
    fastcgi_pass unix:/usr/local/var/run/php-fpm.socket;

    include fastcgi_params;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    # Prevents caching of css/less/js/images, only use this in development
    location ~* \.(css|less|js|jpg|png|gif)$ {
    add_header Cache-Control "no-cache, no-store, must-revalidate";
    add_header Pragma "no-cache";
    expires 0;
    }
    }