随笔 - 5  文章 - 0 评论 - 0 阅读 - 4654
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

实战Nginx与PHP(FastCGI)的安装、配置与优化:http://ixdba.blog.51cto.com/2895551/806622

Nginx配置文件详细说明:http://www.cnblogs.com/xiaogangqq123/archive/2011/03/02/1969006.html

 

由于做测试用,所以通过修改hosts文件来达到对浏览器输入不同网址输出不同地址....(语言表达不强,自己能理解)

 

hosts文件配置,将域名转接

 

127.0.0.1       localhost

139.217.2.21   www.qq.com

139.217.2.21   www.baidu.com

139.217.2.21   www.sina.com.cn

 

 修改nginx的配置文件,给这三个网址分别加入一个server,如下写三遍,修改其中一些参数即可

 

server {

        listen 80;

        server_name  qq.com www.qq.com;

        root /var/www/site1;

        index index.php index.html index.htm;

 

         location / {

 

            if (!-e $request_filename){

                rewrite ^(.*)$ /index.php?s=$1 last;

                break;

             }

        }

        location ~* \.php$ {

                fastcgi_pass unix:/var/run/php5-fpm.sock;

                fastcgi_index index.php;

                include fastcgi_params;

 

                set $path_info "" ;

                set $real_script_name $fastcgi_script_name;

                if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$" ){

                        set $real_script_name $1;

                        set $path_info $2;

                }

                fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;

                fastcgi_param SCRIPT_NAME $real_script_name;

                fastcgi_param PATH_INFO $path_info;

        }

}

posted on   低调的小人物  阅读(2878)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示