溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

如何在CentOS中使用Nginx搭建一個下載服務(wù)器

發(fā)布時間:2020-12-22 15:42:16 來源:億速云 閱讀:303 作者:Leah 欄目:服務(wù)器

如何在CentOS中使用Nginx搭建一個下載服務(wù)器?很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。

利用nginx在服務(wù)器搭建下載功能,

安裝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;
error_log /usr/local/nginx/logs/error.log crit;
pid    /usr/local/nginx/logs/nginx.pid;
 
worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 010000
00 10000000;
worker_rlimit_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;
}

虛擬主機(jī)配置

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:9000;
#    fastcgi_index index.php;
#    include fastcgi.conf;
#  }
 
 
  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|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

看完上述內(nèi)容是否對您有幫助呢?如果還想對相關(guān)知識有進(jìn)一步的了解或閱讀更多相關(guān)文章,請關(guān)注億速云行業(yè)資訊頻道,感謝您對億速云的支持。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI