Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Nginx to build a download server in CentOS

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

How to use Nginx to build a download server in CentOS? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.

Use nginx to build download function on the server

Install Nginx,pcre

Mkdir / usr/local/nginx

Tar zxvf pcre-8.12.tar.gz

Cd pcre-8.12

. / configure-- prefix=/usr/local/pcre

Make & & make install

Tar zxvf nginx-1.0.12.tar.gz

Tar zxvf nginx-1.0.12.tar.gz

Cd nginx-1.0.12

. / configure-prefix=/usr/local/nginx/-with-pcre=/opt/pcre-8.12

Make & & make install

Vi / usr/local/nginx/conf/nginx.conf

# user www www;worker_processes 8 errorists log / usr/local/nginx/logs/error.log crit;pid / usr/local/nginx/logs/nginx.pid; worker_cpu_affinity 00000001 00000010 00000100 00001000 000 10000 00000 01000000 10000000bot workerworkers rushing problems nofile 51200; events {use epoll; worker_connections 51200;} http {include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k Client_max_body_size 8m; access_log off; sendfile on; tcp_nodelay on; tcp_nopush on; keepalive_timeout 30; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 32k; fastcgi_buffers 8 32k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 256k; fastcgi_intercept_errors on; open_file_cache max=51200 inactive=20s; open_file_cache_valid 30s Open_file_cache_min_uses 1; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; # if you modify nginx source,please hidden follow # server_tokens off Log_format access'$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;}

Virtual host configuration

Mkdir / usr/local/nginx/conf/vhost

Cd / usr/local/nginx/conf/vhost

Vi hosts.conf

Server {listen 80; server_name 42.62.XX. Index index.html index.htm index.php; root / game/; error_page 502 = / 502.html; location ~ * ^ / upload/.*\. (php | php5) ${deny all;} # location ~. *\. (php | php5)? ${# fastcgi_pass unix:/tmp/php-cgi.sock;# fastcgi_pass 127.0.0.1 index index.html index.htm index.php; root 9000 # fastcgi_index index.php;# include fastcgi.conf;#} location ~. *\. (gif | jpg | jpeg | png | bmp | mp3) ${expires 30d;} location ~. *\. (js | css)? ${expires 12h;} # access_log / data/webroot/nginx/logs/access.log access;#error_log / data/webroot/nginx/logs/error.log error;}

# / 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

# / usr/local/nginx/sbin/nginx-s reload

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report