当先锋百科网

首页 1 2 3 4 5 6 7

安装
yum -y install nginx mysql-server php-fpm php-cli php-pdo php-mysql php-mcrypt php-mbstring php-gd php-tidy php-xml php-xmlrpc php-pear php-pecl-memcache php-eaccelerator

配置
user              root;
worker_processes  16;

error_log  /var/log/nginx/error.log;

pid        /usr/local/nginx/logs/nginx.pid;


events {
    use epoll;
    worker_connections  65535;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    charset  utf-8;         
    server_names_hash_bucket_size 128;  
    client_header_buffer_size 32k;  
    large_client_header_buffers 4 32k;  
    client_max_body_size 300m;         
    sendfile on;  
    tcp_nopush     on;
    keepalive_timeout  65;

    gzip  on;
    gzip_min_length  1k;  
    gzip_buffers 4 16k;  
    gzip_http_version 1.1;  
    gzip_comp_level 2;  
    gzip_types text/plain application/x-javascript text/css application/xml;  
    gzip_vary on;
   
    proxy_temp_path /data/var/www/html/magento/media/images_temp;
    proxy_cache_path /data/var/www/html/magento/media/images_cache levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=30g;
    log_format cache '***$time_local '  '***$upstream_cache_status '  '***Cache-Control: $upstream_http_cache_control ' '***Expires: $upstream_http_expires ' '***"$request" ($status) ' '***"$http_user_agent" ';
    server {
        listen 80;
        server_name  172.16.1.55;
        location / {
                        proxy_cache cache_one;
                        proxy_cache_valid  200 304 12h;
                        proxy_cache_key $host$uri$is_args$args;
                        proxy_set_header Host  $host;
                        proxy_set_header X-Forwarded-For  $remote_addr;
                        proxy_pass http://172.16.1.55:8080;
                        access_log  /var/log/nginx/cache.log cache;
                        expires      1d;
        }

       
        location ~ /purge(/.*) {
                    allow       127.0.0.1;
                    allow       192.168.0.0/16;
                    deny        all;
                    proxy_cache_purge    cache_one   $host$1$is_args$args;
        }

        location ~ .*\.(php|jsp|cgi)?$ {
                        proxy_set_header Host  $host;
                        proxy_set_header X-Forwarded-For  $remote_addr;
                        proxy_pass http://172.16.1.55:8080;
        }
        access_log  off;
    }

    server{
        listen 8080;
        server_name 172.16.1.55;   
        location / {
            root /data/var/www/html/magento/;
            index  index.php index.html index.htm;
        }
        location ~ \.php$ {
            root           /data/var/www/html/magento;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /data/var/www/html/magento$fastcgi_script_name;
            include        fastcgi_params;
        }

        access_log off;
    }
}