การ config Nginx สำหรับเว็บดาวน์โหลดไฟล์
#######################################################################
#
# This is the main Nginx configuration file.
#
# More information about the configuration options is available on
# * the English wiki - http://wiki.codemongers.com/Main
# * the Russian documentation - http://sysoev.ru/nginx/
#
#######################################################################
#----------------------------------------------------------------------
# Main Module - directives that cover basic functionality
#
# http://wiki.codemongers.com/NginxMainModule
#
#----------------------------------------------------------------------
user nginx;
worker_processes 10;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
worker_rlimit_nofile 10240;
#----------------------------------------------------------------------
# Events Module
#
# http://wiki.codemongers.com/NginxEventsModule
#
#----------------------------------------------------------------------
events {
worker_connections 1024;
}
#----------------------------------------------------------------------
# HTTP Core Module
#
# http://wiki.codemongers.com/NginxHttpCoreModule
#
#----------------------------------------------------------------------
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nodelay on;
gzip on;
# Load config files from the /etc/nginx/conf.d directory
include /etc/nginx/conf.d/*.conf;
#
# The default server
#
limit_zone one $binary_remote_addr 20m;
server {
listen 80;
#จำกัดจำนวน Connection ต่อ 1 ดาวน์โหลด
limit_conn one 5;
#ชื่อ Server ใช้ที่อยู่ IP
server_name _;
#Server Root
location / {
root /usr/share/nginx/html;
index index.php;
}
# รัน PHP
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
}
# หน้าเพจ Error 404
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
#หน้าเพจ Error 50x
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
หลังจากการตั้งค่าแล้วคุณสามารถ Restart Server Nginx ได้ด้วยคำสั่ง
/etc/init.d/nginx stop
/etc/init.d/nginx start
#หรือ
/etc/init.d/nginx restart