LNMP配置——Nginx配置 —— 配置静态文件不记录日志并添加过期时间

一、配置

#vi /usr/local/nginx/conf/vhost/test.com.conf

写入;

server

{

        listen 80;

        server_name test.com test1.com test2.com;

        index index.html index.htm index.php;

        root /data/nginx/test.com;

        if ($host != 'test.com' ){

                rewrite ^(.*)$ http://test.com/$1 permanent;

        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

        {

        expires 7d;

        access_log off;

        }

        location ~ .*\.(js|css)$

        {

        expires 12h;

        }

        access_log /tmp/1.log combined_realip;

}

 

#/usr/local/nginx/sbin/nginx -t

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

 

 

#echo "11111" > /data/nginx/test.com/1.js

//创建js文件

#echo "22222" > /data/nginx/test.com/2.jpg

//创建jpg文件

#touch /data/nginx/test.com/1.jss

//创建一个对比的文件

2.5.2检验测试

#curl -I -x127.0.0.1:80 test.com/1.js

状态码200

#curl -I -x127.0.0.1:80 test.com/2.jpg

状态码200

 

#curl -I -x127.0.0.1:80 test.com/1.jss

状态码200

 

 

 

#cat /tmp/1.log

查看日志

显示以上图片显示成功

posted @ 2021-03-10 11:24  清空。  阅读(104)  评论(0)    收藏  举报