Vim/etc/nginx. conf
#user nobody;worker_processes 1;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events { worker_connections 1024;}http { include 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 logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; rewrite ^(.*)/archiver/((fid|tid)-[w-]+.html)$ $1/archiver/index.php?$2 last; rewrite ^(.*)/forum-([0-9]+)-([0-9]+).html$ $1/forumdisplay.php?fid=$2&page=$3 last; rewrite ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/viewthread.php?tid=$2&extra=page%3D$4&page=$3 last; rewrite ^(.*)/profile-(username|uid)-(.+).html$ $1/viewpro.php?$2=$3 last; rewrite ^(.*)/space-(username|uid)-(.+).html$ $1/space.php?$2=$3 last; rewrite ^(.*)/tag-(.+).html$ $1/tag.php?name=$2 last; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache‘s document root # concurs with nginx‘s one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #}
# Running user
# Start the process. Generally, it is set to be equal to the number of CPUs
Worker_processes 1;
# Global error logs and PID files
# Error_log logs/error. log;
# PID/logs/nginx. PID;
# Working mode and maximum number of connections
Events {
# Use epoll;
# Epoll is a method in Multiplexing I/O multiplexing, but it is only used in Linux or later kernels, which can greatly improve nginx performance.
Worker_connections 1024;
# Maximum number of concurrent connections of a single backend Worker Process
}
# Set the HTTP server and use its reverse proxy function to provide Load Balancing support
HTTP {
# Set the MIME type, which is defined by the mime. type file.
Include/etc/nginx/mime. types;
Default_type application/octet-stream;
# Set the log format
# Access_log logs/access. log;
# The sendfile command specifies whether nginx calls the sendfile function (zero copy mode) to output files. For common applications,
# It must be set to on. If it is used for downloading and other application disk I/O heavy load applications, you can set it to off to balance the disk and network I/O processing speed and reduce the system uptime.
Sendfile on;
# Tcp_nopush on;
# Connection timeout
# Keepalive_timeout 0;
Keepalive_timeout 65;
Tcp_nodelay on;
# Enable gzip Compression
# Gzip on;
# Gzip_disable "MSIE [1-6] \. (?!. * Sv1 )";
# Set Request Buffer
# Client_header_buffer_size 1 K;
# Large_client_header_buffers 4 4 K;
# Include/etc/nginx/CONF. d/*. conf;
# Include/etc/nginx/sites-enabled /*;
# Set the Server list of Server Load balancer
# Upstream mysvr {
# The weigth parameter indicates the weight. A higher weight indicates a higher probability of being assigned.
# Enable port 3128 for squid on the local machine
# Server 192.168.8.1: 3128 Weight = 5;
# Server 192.168.8.2: 80 Weight = 1;
# Server 192.168.8.3: 80 Weight = 6;
#}
Server {
# Listening to port 80
Listen 80;
# Define localhost access
SERVER_NAME localhost;
# Set access logs for the current virtual host
# Access_log logs/www.xx.com. Access. Log main;
# Default request
Location /{
Root/root; # define the default website root directory location of the server
Index index. php index.html index.htm; # define the name of the home index file
# Fastcgi_pass www.xx.com;
# Fastcgi_param script_filename $ document_root/$ fastcgi_script_name;
# Include/etc/nginx/fastcgi_params;
}
# Define error prompt page
Error_page 500 502 503 x.html;
Location =/50x.html {
Root/root;
}
# Handle static files by nginx
# Location ~ ^/(Images | JavaScript | JS | CSS | flash | media | static )/{
# Root/var/www/virtual/htdocs;
# Static files are not updated for 30 days after they expire. You can set them to a larger value when they expire. If they are updated frequently, you can set them to a smaller value.
# Expires 30d;
#}
# PHP script requests are all forwarded to FastCGI for processing. Use the default FastCGI configuration.
# Location ~ \. Php $ {
# Root/root;
# Fastcgi_pass 127.0.0.1: 9000;
# Fastcgi_index index. php;
# Fastcgi_param script_filename/home/www/WWW $ fastcgi_script_name;
# Include fastcgi_params;
#}
# Set the address for viewing nginx status
# Location/nginxstatus {
# Stub_status on;
# Access_log on;
# Auth_basic "nginxstatus ";
# Auth_basic_user_file CONF/htpasswd;
#}
# Prohibit access to the. htxxx File
# Location ~ /\. Ht {
# Deny all;
#}
}
}
Nginx. conf