首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

装配nginx做图片服务器

2012-12-18 
安装nginx做图片服务器安装nginxWget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.13.

安装nginx做图片服务器
安装nginx
Wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.13.tar.gz
或者此地址:http://lnamp-web-server.googlecode.com/files/pcre-8.13.tar.gz
tar zxvf pcre-8.13.tar.gz

./configure    
make   
make install

由于centos没有默认的nginx软件包,需要启用REHL的附件包
rpm -Uvh http://download.Fedora.RedHat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
或者此地址:http://mirrors.ustc.edu.cn/fedora/epel//5/i386/epel-release-5-4.noarch.rpm
yum -y install nginx

添加开机启动nginx
vim /etc/rc.local
添加/usr/sbin/nginx

启动 /usr/sbin/nginx
重启 /usr/sbin/nginx -s reload
停止 /usr/sbin/nginx -s  stop
测试配置/usr/sbin/nginx -t

修改nginx配置文件/etc/nginx/nginx.conf

worker_processes  4;error_log  /var/log/nginx/error.log crit; worker_connections  51200;keepalive_timeout  120;gzip  on;gzip_min_length   1k;   gzip_buffers     4 16k;#注意此处,不是416   gzip_http_version 1.0;   gzip_comp_level 2;   gzip_types  text/plain application/x-javascript text/css text/html application/xml text/javascript;     gzip_vary on; server {        listen 80;        server_name *.frady.cn *.frady.com.cn;        set $htdocs /web/www/ROOT/;#此处定义了htdocs        root $htdocs;        location ~ ^/zanStatus/ {            stub_status on;            access_log off;         }location / {                index index.html;        }        location ~ .*.(gif|jpg|jpeg|png|bmp|swf|css|js|html)$ {                expires 30d;        }#此目录的图片不缓存location ^~ /picture/price/{expires -2;}        location ~*.(jsp|do|action|php|asp|rar|zip|txt|html|htm|shtml)$        {           deny all;}        location ~^/(WEB-INF)/{           deny all;        }}

完成
status参数解释
Active connections:145           
#nginx 正处理的活动连接数145个。
server accepts handled requests
1749 1749 3198                   
#nginx启动到现在共处理了 1749个连接 ,nginx启动到现在共成功创建 1749次握手 请求丢失数=(握手-连接),可以看出,我们没丢请求;总共处理了3198 次请求。
Reading: 0 Writing: 3 Waiting: 142
#Reading :nginx读取到客户端的Header信息数。
#Writing : nginx返回给客户端的Header信息数。
#Waiting : Nginx已经处理完正在等候下一次请求指令的驻留连接.开启keep-alive的情况下,这个值等于active–(reading+writing)。

热点排行