zoukankan      html  css  js  c++  java
  • 针对Yii框架的nginx配置

    原文链接:https://www.akii.org/nginx-config-for-yii.html

    我曾经针对yii制作了 个nginx配置,其中包括了以下几项内容:

    • rewrite规则(try_file),需要nginx0.8.6版本以上支持。
    • 针对于icon, robots.txt文件的日志优化
    • .svn, .git,等版本控制文件的忽略,以及Mac本身索引文件目录
    • Yii框架本身应该禁止web访问的目录。
    • 图片等静态文件缓存优化

    在这里分享一下demo

    server {
        listen       80;
        server_name  youdomain.com;
        index index.html index.htm index.php;
        root  /home/wwwroot/htdocs/yii-1.1.8.r3324/demos/blog;
        #charset koi8-r;
     
        # 这里的main,是nginx默认的httpd段的一个日志格式定义
        access_log  /home/wwwlogs/localhost.access.log  main;
        #error_page  404              /404.html;
     
        # redirect server error pages to the static page /50x.html
        #
        #error_page   500 502 503 504  /50x.html;
     
        location = /favicon.ico {
            log_not_found off;
            access_log off;
        }
     
        location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;
        }
     
        ################ Yii framework rule #################
        location / {
            try_files $uri $uri/ /index.php?$args;
        }
     
        location ~ /(protected|framework|nbproject|themes/\w+/views|index-test\.php) {
            deny all;
            # for production
            internal;
            log_not_found off;
            access_log off;
        }
        ################ for Yii framework end #################
     
        location ~ \.php$ {
            fastcgi_pass   php;
            fastcgi_index  index.php;
            include fastcgi.conf;
        }
     
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /(\.svn|\.git|\.ht|\.DS) {
            deny all;
            internal;
        }
     
        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
             expires max;
             log_not_found off;
        }
     
    }

    location / {
    try_files $uri $uri/ /index.php?$args;
    }
    不加$args也可以吧?

    作者答:不加的话,比如你url中含有?a=b这种get参数,可能就传递不过去了。

  • 相关阅读:
    【git hub使用】
    【struct2 第一天】
    【JSP基础 第一天】
    【Java基础学习 day01】
    网站建设 【Django】 【MTV】
    Python-Json字符串和XML解析
    Python-冒泡和快排
    Python-面向对象编程
    练习-字符串编码
    练习-统计文件中单词数量
  • 原文地址:https://www.cnblogs.com/xingkoo/p/2875958.html
Copyright © 2011-2022 走看看