1.nginx.conf
#user nobody;worker_processes1; #error_log logs/Error.log, #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid;events {worker_connections1024x768;} 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_timeout0; Keepalive_timeout $; #gzip on; Include/usr/local/nginx/conf/vhost/*. conf; # 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; # } #}}
2. Virtual host configuration, Server
server {Listen 80; server_name edu.sentiger.com; #charset Koi8-r; Access_log Logs/edu.access.log Main; Error_log Logs/edu.error.log; Root/var/www/html/fangwei; Index index.html index.htm index.php; Location/{if (!-e $request _filename) {rewrite ^ (. *) $/index.php?s=$1 last;break; }} location ~. +\.php ($|/) {set $script $uri; Set $path _info "/"; if ($uri ~ "^ (. +\.php) (/.+)") {set $script $; Set $path _info; } Fastcgi_pass 127.0.0.1:9000; Fastcgi_index index.php? if_rewrite=1; Include Fastcgi_params; Fastcgi_param path_info $path _info; Fastcgi_param script_filename $document _root$script; Fastcgi_param Script_name $script; } #error_pAge 404/404.html; # REDIRECT Server error pages to the static page/50x.html # Error_page 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$ {# ProX Y_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 # #l ocation ~/\.ht {# deny all; #} }
Nginx Configuration Virtual Host