zoukankan      html  css  js  c++  java
  • (Yii)使用nginx的配置

    yii在nginx下的配置,特别是限制文件的地方一定要注意。

    yii在nginx下的配置,特别是限制文件的地方一定要注意。
    
    upstream phpfpm {
    #server unix:/var/run/php5-fpm.sock;
    server 127.0.0.1:9000;
    }
    
    server {
    listen 80;
    # Specify this vhost's domain name
    server_name guxing.info;
    root /home/guxing.info/public;
    index index.php index.html index.htm;
    
    # Specify log locations for current site
    access_log /home/guxing.info/log/access.log;
    error_log /home/guxing.info/log/error.log warn;
    
    # Typically I create a restrictions.conf file that I then include across all of my vhosts
    #include conf.d/restrictions.conf;
    
    # BEGIN restrictions.conf
    # Disable logging for favicon
    location = /favicon.ico {
    log_not_found off;
    access_log off;
    }
    
    # Disable logging for robots.txt
    location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
    }
    
    # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
    location ~ /\. {
    deny all;
    access_log off;
    log_not_found off;
    }
    # END restrictions.conf
    
    # Typically I create a yiiframework.conf file that I then include across all of my yii vhosts
    #include conf.d/yiiframework.conf;
    # I've included the content of my yiiframework.conf in-line for this example
    
    # BEGIN yiiframework.conf
    # Block access to protected, framework, and nbproject (artifact from Netbeans)
    location ~ /(protected|framework|nbproject) {
    deny all;
    access_log off;
    log_not_found off;
    }
    
    # Block access to theme-folder views directories
    location ~ /themes/\w+/views {
    deny all;
    access_log off;
    log_not_found off;
    }
    
    # Attempt the uri, uri+/, then fall back to yii's index.php with args included
    # Note: old examples use IF statements, which nginx considers evil, this approach is more widely supported
    location / {
    try_files $uri $uri/ /index.php?$args;
    }
    # END yiiframework.conf
    
    # Tell browser to cache image files for 24 hours, do not log missing images
    # I typically keep this after the yii rules, so that there is no conflict with content served by Yii
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
    expires 24h;
    log_not_found off;
    }
    
    # Block for processing PHP files
    # Specifically matches URIs ending in .php
    location ~ \.php$ {
    try_files $uri =404;
    
    # Fix for server variables that behave differently under nginx/php-fpm than typically expected
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    # Include the standard fastcgi_params file included with nginx
    include fastcgi_params;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_index index.php;
    # Override the SCRIPT_FILENAME variable set by fastcgi_params
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    # Pass to upstream PHP-FPM; This must match whatever you name your upstream connection
    fastcgi_pass phpfpm;
    }
    }
  • 相关阅读:
    远程监控基础知识和故障排除
    感慨颇多
    物联网操作系统Hello China移植mile stone之一:移植基础版本V1.76发布
    iOS5系统API和5个开源库的JSON解析速度测试
    (译)iPhone: 用公开API创建带小数点的数字键盘 (OS 3.0, OS 4.0)
    [工具]Mac平台开发几个网络抓包工具(sniffer)
    [工具]Mac下非常好用的快捷终端Dterm
    【IOS】在SDK中打开其他接入应用的解决方案
    [开源]在iOS上实现Android风格的控件Toast
    [技巧]使用Xcode集成的HeaderDoc自动生成注释和开发文档
  • 原文地址:https://www.cnblogs.com/xingkoo/p/2874122.html
Copyright © 2011-2022 走看看