2015-05-28 70 views
0

我是nginx的新手,所以很抱歉如果这个问题之前已经被问过了。在nginx上启用CACHE,CentOS 7

我想在nginx上启用缓存。我发现解决方案NGINX Cache

问题是我在/etc/nginx/ngin.conf找到的nginx.conf看起来不像是贴在那里的东西。所以我有点困惑,不知道该怎么做。

这里是我的nginx.conf

#user nginx; 
worker_processes 1; 

#error_log /var/log/nginx/error.log; 
#error_log /var/log/nginx/error.log notice; 
#error_log /var/log/nginx/error.log info; 

#pid  /var/run/nginx.pid; 


events { 
    worker_connections 1024; 
} 


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; 

    sendfile  on; 
    #tcp_nopush  on; 

    #keepalive_timeout 0; 
    keepalive_timeout 65; 
    #tcp_nodelay  on; 

    #gzip on; 
    #gzip_disable "MSIE [1-6]\.(?!.*SV1)"; 

    server_tokens off; 

    include /etc/nginx/conf.d/*.conf; 
} 

所以我应该怎么申请我已经找到了解决方案,或者我应该做点别的?

请帮

回答

1

看到你nginx.conf底部的include /etc/nginx/conf.d/*.conf;线?这是符号链接或保存实际主机配置文件的地方..您在其他帖子中看到的文件,通常由server {...}包围。

您可以更改路径或添加在任何时候另外一个和nginx的一次可以成功解析所包含的配置文件(nginx -t将测试文件),你会nginx的正常使用重启nginx -s reload

UPDATE:

类似下面就进入你的filename.conf文件

server { 
    listen 80; 
    root /somewhere/on/your/machine; 

    location/{ 
     expires 1d; 
     # other caching related directives 

     gzip   on; 
     gzip_min_length 1000; 
     gzip_proxied expired no-cache no-store private auth; 
     gzip_types  text/plain application/xml; 
     # replace with your own gzip config 

    } 
} 

http://nginx.org/en/docs/进行更详细的文档

+0

感谢您的回答,我已经在那里为gzip创建了一个文件,我是否需要为缓存创建另一个文件?如果我这样做,那么我需要输入什么文件? – AlexB

+0

感谢您的支持,请尝试在几分钟后回到这里 – AlexB