lnmp环境下的nginx站点,首先在/usr/local/nginx/conf/nginx.conf中开启vhost:

include  vhost/*.conf;

开启后,在'/usr/local/nginx/conf/vhost/'目录下建立conf文件,内容如下:

server
    {
            listen     80;
            server_name www.xxxxx.com;
            root /data/www;
            index index.html index.php ;

            if ( !-e $request_filename ) {
                   rewrite  ^/(.*)$  /index.php?s=/$1  last;
                   break;
            }
            location ~* ^.+\.php($|/)
            {
                    set $script     $uri;
                    set $path_info  "/";
                    if ($uri ~ "^(.+\.php)(/.+)") {
                            set $script     $1;
                            set $path_info  $2;
                    }
                    fastcgi_pass 127.0.0.1:9000;
                    fastcgi_connect_timeout 900;
                    fastcgi_send_timeout 900;
                    fastcgi_read_timeout 900;
                    fastcgi_buffer_size 1024k;
                    fastcgi_buffers 8 1024k;
                    fastcgi_busy_buffers_size 2048k;
                    fastcgi_temp_file_write_size 2048k;
                    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;
                    fastcgi_param SCRIPT_NAME $script;
            }

            location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
            {
                    expires      30d;
            }

            location ~ .*\.(js|css)?$
            {
                    expires      1h;
            }
    }

保存后,执行重启nginx命令:

/usr/local/nginx/sbin/nginx -s reload

站点立即生效