CentOS利用Nginx搭建下载功能服务器
利用nginx在服务器搭建下载功能,
安装Nginx,pcre
mkdir/usr/local/nginx
tarzxvfpcre-8.12.tar.gz
cdpcre-8.12
./configure--prefix=/usr/local/pcre
make&&makeinstall
tarzxvfnginx-1.0.12.tar.gz
tarzxvfnginx-1.0.12.tar.gz
cdnginx-1.0.12
./configure--prefix=/usr/local/nginx/--with-pcre=/opt/pcre-8.12
make&&makeinstall
vi/usr/local/nginx/conf/nginx.conf
#userwwwwww; worker_processes8; error_log/usr/local/nginx/logs/error.logcrit; pid/usr/local/nginx/logs/nginx.pid; worker_cpu_affinity000000010000001000000100000010000001000000100000010000 0010000000; worker_rlimit_nofile51200; events{ useepoll; worker_connections51200; } http{ includemime.types; default_typeapplication/octet-stream; server_names_hash_bucket_size128; client_header_buffer_size32k; large_client_header_buffers432k; client_max_body_size8m; access_logoff; sendfileon; tcp_nodelayon; tcp_nopushon; keepalive_timeout30; fastcgi_connect_timeout300; fastcgi_send_timeout300; fastcgi_read_timeout300; fastcgi_buffer_size32k; fastcgi_buffers832k; fastcgi_busy_buffers_size128k; fastcgi_temp_file_write_size256k; fastcgi_intercept_errorson; open_file_cachemax=51200inactive=20s; open_file_cache_valid30s; open_file_cache_min_uses1; gzipon; gzip_min_length1k; gzip_buffers416k; gzip_http_version1.0; gzip_comp_level2; gzip_typestext/plainapplication/x-javascripttext/cssapplication/xml; gzip_varyon; #ifyoumodifynginxsource,pleasehiddenfollow #server_tokensoff; log_formataccess'$remote_addr-$remote_user[$time_local]"$request"' '$status$body_bytes_sent"$http_referer"' '"$http_user_agent"$http_x_forwarded_for'; include/usr/local/nginx/conf/vhost/*.conf; }
虚拟主机配置
mkdir/usr/local/nginx/conf/vhost
cd/usr/local/nginx/conf/vhost
vihosts.conf
server{ listen80; server_name42.62.XX. indexindex.htmlindex.htmindex.php; root/game/; error_page502=/502.html; location~*^/upload/.*\.(php|php5)${ denyall; } #location~.*\.(php|php5)?${ ##fastcgi_passunix:/tmp/php-cgi.sock; #fastcgi_pass127.0.0.1:9000; #fastcgi_indexindex.php; #includefastcgi.conf; #} location~.*\.(gif|jpg|jpeg|png|bmp|swf|mp3)${ expires30d; } location~.*\.(js|css)?${ expires12h; } #access_log/data/webroot/nginx/logs/access.logaccess; #error_log/data/webroot/nginx/logs/error.logerror; }
#/usr/local/nginx/sbin/nginx-t
nginx:theconfigurationfile/usr/local/nginx//conf/nginx.confsyntaxisok
nginx:configurationfile/usr/local/nginx//conf/nginx.conftestissuccessful
#/usr/local/nginx/sbin/nginx-sreload
此时在服务器上创建/game目录,把需要被下载的资源放目录里面就可以了。