Nginx学习总结【第二篇】: Nginx部署及使用

Nginx部署及使用

$ cat nginx.conf
worker_processes  8;

error_log  logs/error.log;
error_log  logs/error.log  notice;
error_log  logs/error.log  info;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen  80;
        server_name xxxx;
        
        root    /data0/www;
        index   index.html index.htm index.php;

        location / {
            if (!-e $request_filename) {
                rewrite ^/topic/(.*)$ /topic/index.php/$1;
            }
        }
        
        location ~ \.php$ {
            include fastcgi_params;
            fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_pass    unix:/tmp/php-cgi.sock;
        }
        
        # ThinkPHP pathinfo * URL Rewrite
        location ~ ^(.+\.php)(.*)$ {
            include fastcgi_params;
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            fastcgi_param   PATH_INFO $fastcgi_path_info;
            fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_pass    unix:/tmp/php-cgi.sock;
        }

        location ~ /\.(ht|svn|git) {
            deny    all;
        }
    }
}

 

posted @ 2016-07-16 18:06  每天进步一点点!!!  阅读(142)  评论(0)    收藏  举报