Skip to content

Instantly share code, notes, and snippets.

@CHERTS
Created January 14, 2022 11:38
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 CHERTS/52ece2043b8285ab14d1dd3754d9aace to your computer and use it in GitHub Desktop.
Save CHERTS/52ece2043b8285ab14d1dd3754d9aace to your computer and use it in GitHub Desktop.
Simple nginx vhost (only http and php-fpm)
server {
listen XX.XX.XX.XX:80;
server_name YYYY.ZZ;
root /var/www/NNNNNN;
index index.php index.html index.htm;
error_log /var/log/nginx/YYYY_error.log;
access_log /var/log/nginx/YYYY_access.log main;
set $fastcgipass unix:/run/php/BBBBB.sock;
location ~* /\.(ht|svn|hg) {
deny all;
access_log off;
log_not_found off;
}
location ~ (/\.gitignore|/\.git) {
deny all;
access_log off;
log_not_found off;
}
location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|exe|xls|doc|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|mov)$ {
expires 14d;
access_log off;
log_not_found off;
}
location ~* ^.+\.(css|js)$ {
expires 48h;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
try_files $uri = 404;
fastcgi_pass $fastcgipass;
fastcgi_param HTTPS $fastcgi_https;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment