Skip to content

Instantly share code, notes, and snippets.

@adahox
Forked from lukearmstrong/nginx-vhost-php.conf
Created October 20, 2021 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adahox/93c4b516b50c235cc3b2a5a39b207bf5 to your computer and use it in GitHub Desktop.
Save adahox/93c4b516b50c235cc3b2a5a39b207bf5 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