当前位置 : 主页 > 网络编程 > PHP >

ngnix配置 NMP

来源:互联网 收集:自由互联 发布时间:2021-06-28
ngnix配置 NMP #user nobody;worker_processes 1;error_log "D:/Visual-NMP-x86/logs/Nginx/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.typ
ngnix配置 NMP
#user  nobody;
worker_processes  1;

error_log "D:/Visual-NMP-x86/logs/Nginx/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 "D:/Visual-NMP-x86/logs/Nginx/access.log";
    
    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    gzip  on;

    server {
        #SiteName    Default WebSite
        listen       20080;
        server_name  localhost;
        root         D:/Visual-NMP-x86/www/Default; 
        autoindex    on;
        index        index.php index.html index.htm;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            index  index.php index.html index.htm;
        }
                            
        location ~ (^/phpmyadmin|^/sql\x20buddy|^/memcache|^/memadmin|^/phpredisadmin|^/webgrind|^/eaccelerator|^/rockmongo)/.+\.php$ { 
            allow 127.0.0.1;
            deny all;
            root D:/Visual-NMP-x86/www/Apps;            
            fastcgi_pass   127.0.0.1:9001;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

        location ~ (^/phpmyadmin|^/sql\x20buddy|^/memcache|^/memadmin|^/phpredisadmin|^/webgrind|^/eaccelerator|^/rockmongo) {
            allow 127.0.0.1;
            deny all;
            root D:/Visual-NMP-x86/www/Apps;
            autoindex on;           
        }       
                                    
        #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$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$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;
        #}
    }
    
    server {
        #sitename    Demo1
        listen       20081;
        server_name  localhost;
        root         D:/Visual-NMP-x86/www/Demo1; 
        error_log    D:/Visual-NMP-x86/logs/Nginx/D__Visual-NMP_www_Demo1-error.log;
        access_log   D:/Visual-NMP-x86/logs/Nginx/D__Visual-NMP_www_Demo1-access.log;       
        autoindex    on;
        index        index.php index.html index.htm;
                        
        location  ~ \.php$ {
            fastcgi_pass   127.0.0.1:9002;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }                                       
    }
    
    server {
        #sitename    Demo2
        listen       20082;
        server_name  localhost;
        root         D:/Visual-NMP-x86/www/Demo2; 
        error_log    D:/Visual-NMP-x86/logs/Nginx/D__Visual-NMP_www_Demo2-error.log;
        access_log   D:/Visual-NMP-x86/logs/Nginx/D__Visual-NMP_www_Demo2-access.log;
        autoindex    on;
        index        index.php index.html index.htm;
                        
        location  ~ \.php$ {
            fastcgi_pass   127.0.0.1:9002;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }                                       
    }

    server {
        #SiteName    bbs
        listen       10.143.20.114:80;
        server_name  10.143.20.114;
        root         "D:/php/wamp/www/creditcat";
        error_log    "D:/Visual-NMP-x86/logs/Nginx/bbs-error.log";
        access_log   "D:/Visual-NMP-x86/logs/Nginx/bbs-access.log";
        autoindex    on;
        index        index.php index.html index.htm;
        
        rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
        rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
        rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
        rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
        rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
        rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
        rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
        rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last;
        rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last;
        if (!-e $request_filename) {
            return 404;
        }


        location  ~ \.php$ {
            fastcgi_pass   127.0.0.1:9001;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }

    server {
        #SiteName    up
        listen       127.0.0.1:8089;
        server_name  127.0.0.1;
        root         "D:/php/wamp/www/bbs";
        error_log    "D:/Visual-NMP-x86/logs/Nginx/up-error.log";
        access_log   "D:/Visual-NMP-x86/logs/Nginx/up-access.log";
        autoindex    on;
        index        index.php index.html index.htm;

        location  ~ \.php$ {
            fastcgi_pass   127.0.0.1:9001;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }

}
网友评论