nginx的fast_cgi缓存配置

fastcgi_cache_path /var/cache levels=1:2 keys_zone=MYCACHE:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";

server {
    server_name test;
    root /webroot/test; ## <-- Your only path reference.
    listen 80;



    #Cache everything by default
    set $no_cache 0;

    #Don't cache POST requests
    if ($request_method = POST)
    {
        set $no_cache 1;
    }

    #Don't cache if the URL contains a query string
    if ($query_string != "")
    {
        set $no_cache 1;
    }

    #Don't cache the following URLs
    if ($request_uri ~* "/(administrator/|login.php)")
    {
        set $no_cache 1;
    }

    #Don't cache if there is a cookie called PHPSESSID
    if ($http_cookie = "PHPSESSID")
    {
        set $no_cache 1;
    }



    location ~ '\.php$' {
        fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
        include fastcgi_params;
        # Block httpoxy attacks. See https://httpoxy.org/.
        fastcgi_param HTTP_PROXY "";
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_intercept_errors on;
               fastcgi_pass backend;

        fastcgi_cache MYCACHE;
        fastcgi_cache_valid 200 60m;
        fastcgi_cache_bypass $no_cache;
        fastcgi_no_cache $no_cache;
        add_header X-Cache $upstream_cache_status;
    }
}
2017/3/28 posted in  Apache/Nginx

apache和nginx虚拟主机配置文件示例

apache虚拟主机配置文件示例

<VirtualHost *:80>
 ServerName  test.com
 DocumentRoot  "d:\www\test"  
 DirectoryIndex   index.php
 <Directory "d:\www\qlmall">
     Options +FollowSymLinks
     Order Allow,Deny
     allow from all
     AllowOverride All
 </Directory>
</VirtualHost>

nginx配置文件示例

server {
    server_name test.com;
    listen 80;
    root /data/webroot/test;

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

        location / {
            index index.php index.html index.htm;
                # This is cool because no php is touched for static content.
                # include the "?$args" part so non-default permalinks doesn't break when using query string
                try_files $uri $uri/ /index.php?$args;
        }

        location ~ \.php$ {
                #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                include fastcgi.conf;
                fastcgi_intercept_errors on;
            fastcgi_pass 127.0.0.1:9000;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }

    error_log /var/log/nginx/test.com.error.log;
    access_log /var/log/nginx/test.com.access.log;
}
2017/2/28 posted in  Apache/Nginx