Skip to content

Instantly share code, notes, and snippets.

@52cik
Created April 13, 2016 16:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save 52cik/8bc570cd9a9874269be03a0a594afd42 to your computer and use it in GitHub Desktop.
Save 52cik/8bc570cd9a9874269be03a0a594afd42 to your computer and use it in GitHub Desktop.
nginx yii2 通用配置
listen 80;
charset utf-8;
index index.html index.php;
error_page 404 /404.html;
# 开启 php 并支持 pathinfo
include enable-php-pathinfo.conf;
# yii2 rewrite
location / {
try_files $uri $uri/ /index.php?$args;
}
# 静态资源缓存 30天
location ~ .*\.(js|css|gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
}
# 禁止访问 . 开头的文件
location ~ /\. {
deny all;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment