Skip to content

Instantly share code, notes, and snippets.

@lukearmstrong
Created October 25, 2013 14:18
Show Gist options
  • Save lukearmstrong/7155390 to your computer and use it in GitHub Desktop.
Save lukearmstrong/7155390 to your computer and use it in GitHub Desktop.
Example vhost config for Nginx (PHP)
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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment