This address http://comexchan.cnblogs.com/, author Comex Chan, respecting intellectual property rights, reproduced please specify the source, thank you!
Back up the relevant files first:
CP /comexhome/nginx/conf/nginx.conf/comexhome/nginx/conf/Nginx.conf.bak.comexCP / comexhome/nginx/conf/mime_types/comexhome/nginx/conf/Mime_types.bak.comexCP /comexhome/nginx/ conf/fastcgi_conf/comexhome/nginx/conf/Fastcgi_conf.bak.comexCP /comexhome/nginx/conf/proxy_ Conf/comexhome/nginx/conf/proxy_conf.bak.comex
Then replace the default configuration
Cat<< EOF >/comexhome/nginx/conf/nginx.conf################################################### Desc:/comexhome/nginx/conf/nginx.conf# Modified from Nginx conf Sample by Comex chan# http://comexchan.cnblogs.com/# ------------------------------------------------# Ver. Date ModifiedBy tips#1.0 .- ,- -Comex Chan Init version#------------------------------------------------################################################# #user Comex comexgroup; # # Default:nobodyworker_processes8; # # Default:1. The same with the CPU Coreserror_log/comexlog/nginx/Error.log; PID/comexhome/nginx/Nginx.pid;worker_rlimit_nofile8192; events {Worker_connections4096; # # Default:1024x768}http {include/comexhome/nginx/conf/mime_types; Include/comexhome/nginx/conf/proxy_conf; Include/comexhome/nginx/conf/fastcgi_conf; Index index.html index.htm index.php; Default_type Application/octet-stream; Log_format Main' - [] ' '"" "" ' '"" ""'; Access_log/comexlog/nginx/Access.log Main; Sendfile on; Tcp_nopush on; Server_names_hash_bucket_size -; # This seems-be required forsome vhosts server {# PHP/fastcgi Listen10080; server_name domain1.com www.domain1.com; Access_log/comexlog/nginx/Domain1.access.log Main; root HTML; Location~\.php\$ {fastcgi_pass127.0.0.1:1025; }} server {# simple reverse-Proxy Listen the; server_name domain2.com www.domain2.com; Access_log/comexlog/nginx/Domain2.access.log Main; # serve static files location~ ^/(images|javascript|js|css|flash|media|static)/{root/var/www/virtual/big.server.com/Htdocs; Expires 30d; } # Pass Requests forDynamic content to rails/turbogears/Zope, et al location/{proxy_pass http://127.0.0.1:8080;}} Upstream big_server_com {server127.0.0.3:8000weight=5; Server127.0.0.3:8001weight=5; Server192.168.0.1:8000; Server192.168.0.1:8001; } server {# Simple load Balancing Listen the; server_name big.server.com; Access_log/comexlog/nginx/Big.server.access.log Main; Location/{proxy_pass http://big_server_com;}}}################################## TCP Proxy conf################################ #stream {upstream Backen d {Server127.0.0.1:12345weight=5; #server backend1.example.com:12345weight=5; #server127.0.0.1:12345max_fails=3fail_timeout=30s; #server Unix:/tmp/Backend3; } Upstream DNS {server127.0.0.1:53535; #server192.168.0.1:53535; #server dns.example.com: -; } Server {Listen12345; Proxy_connect_timeout 1s; Proxy_timeout 3s; Proxy_pass backend; } Server {Listen127.0.0.1: -UDP; Proxy_responses1; Proxy_timeout 20s; Proxy_pass DNS; } Server {Listen127.0.0.1:12345; Proxy_pass Unix:/tmp/Stream.socket; }}eofCat<< EOF >/comexhome/nginx/conf/mime_types################################################### Desc:/comexhome/nginx/conf/mime_types# Modified from Nginx Conf Sample by Comex chan# http://comexchan.cnblogs.com/# ------------------------------------------------# Ver. Date ModifiedBy tips#1.0 .- ,- -Comex Chan Init version#------------------------------------------------################################################# #types {text/html HTML htm shtml; Text/CSS CSS; Text/XML XML RSS; Image/gif gif; Image/jpeg jpeg jpg; Application/x-JavaScript js; Text/Plain txt; Text/x-component HTC; Text/MathML MML; Image/PNG PNG; Image/x-icon ico; Image/x-Jng Jng; Image/vnd.wap.wbmp wbmp; Application/java-archive jar War ear; Application/mac-binhex40 hqx; Application/PDF PDF; Application/x-Cocoa CCO; Application/x-java-archive-diffJardiff; Application/x-java-jnlp-fileJNLP; Application/x-MakeSelf Run; Application/x-PerlPL pm; Application/x-pilot PRC PDB; Application/x-rar-compressed RAR; Application/x-redhat-package-Manager rpm; Application/x-Sea Sea; Application/x-shockwave-Flash SWF; Application/x-StuffIt sit; Application/x-tcl Tcl tk; Application/x-x509-ca-cert der Pem crt; Application/x-Xpinstall xpi; Application/Zip Zip; Application/octet-Stream Deb; Application/octet-Stream bin exe dll; Application/octet-stream DMG; Application/octet-Stream EoT; Application/octet-stream ISO img; Application/octet-Stream MSI MSP MSM; Audio/MPEG mp3; Audio/x-RealAudio RA; Video/MPEG MPEG mpg; Video/QuickTime mov; Video/x-flv flv; Video/x-Msvideo avi; Video/x-ms-wmv wmv; Video/x-ms-asf ASX ASF; Video/x-mng MNG;} EOFCat<< EOF >/comexhome/nginx/conf/fastcgi_conf################################################### Desc:/comexhome/nginx/conf/fastcgi_conf# Modified from Nginx conf Sample by Comex chan# http://comexchan.cnblogs.com/# ------------------------------------------------# Ver. Date ModifiedBy tips#1.0 .- ,- -Comex Chan Init version#------------------------------------------------################################################# #fastcgi_param script_filename \ $document _root\ $fastcgi _ Script_name;fastcgi_param query_string \ $query _string;fastcgi_param request_method \ $request _method;fastcgi_pa Ram content_type \ $content _type;fastcgi_param content_length \ $content _length;fastcgi_param script_name \ $fastcgi _script_name;fastcgi_param request_uri \ $request _uri;fastcgi_param document_uri \ $document _uri;f Astcgi_param document_root \ $document _root;fastcgi_param server_protocol \ $server _protocol;fastcgi_param GATEWA Y_interface CGI/1.1; Fastcgi_param server_software nginx/\ $nginx _version;fastcgi_param remote_addr \ $remote _addr;fastcgi_param remote_port \ $remote _PORT;FASTCG I_param server_addr \ $server _addr;fastcgi_param server_port \ $server _port;fastcgi_param server_name \ $server _name;fastcgi_index Index.php;fastcgi_param redirect_status $; EOFCat<< EOF >/comexhome/nginx/conf/proxy_conf################################################### Desc:/comexhome/nginx/conf/proxy_conf# Modified from Nginx conf Sample by Comex chan# http://comexchan.cnblogs.com/# ------------------------------------------------# Ver. Date ModifiedBy tips#1.0 .- ,- -Comex Chan Init version#------------------------------------------------################################################# #proxy_redirect Off;proxy_set_header Host \ $host;p Roxy_set_header X-real-IP \ $remote _addr;proxy_set_header X-forwarded-For \ $proxy _add_x_forwarded_for;client_max_body_size 10m;client_body_buffer_size 128k;proxy_connect_timeout -;p roxy_send_timeout -;p roxy_read_timeout -;p roxy_buffers +4k; EOF
Finally test whether the configuration file is ok
/comexhome/nginx/sbin/nginx–t
That is OK:
Modification of Nginx initialization configuration under Linux (CentOS6.5)