实战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;

        }

}

相关文章:

  • 2022-01-04
  • 2021-11-20
  • 2021-11-20
  • 2021-10-12
  • 2021-05-20
  • 2021-08-28
  • 2022-12-23
猜你喜欢
  • 2021-12-27
  • 2022-01-18
  • 2021-09-29
  • 2022-12-23
  • 2021-12-29
  • 2022-12-23
  • 2021-09-26
相关资源
相似解决方案