今天进行的将zzb从apache迁移到nginx

     今天接到学校老师的电话,说我之前维护的zzb出故障了,和网管中心的老师了解了一下,才知道他们从apache迁移到nginx上面去了,因为之前apache使用了mod rewrite,在根目录使用了.htaccess文件进行了rewrite,但是nginx的配置和apache不一样,就导致直接网站出故障了。

      后面的解决方案其实很简单,在nginx的nginx.conf中添加一个server,如下:


server {
	listen  80;
	server_name  test.scu.edu.com;
	index index.html index.htm index.php;
	root xxx;
	location / {
		index index.html index.htm index.php;  
		if (!-e $request_filename){  
			rewrite ^(.*)$ /index.php?s=$1 last;  
			break;
		}
		root           xxx;
		fastcgi_pass   127.0.0.1:9000;
		fastcgi_index  index.php;
		fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
		include        fastcgi_params;
	}
}
       实际上关键点就是:



if (!-e $request_filename){  
			rewrite ^(.*)$ /index.php?s=$1 last;  
			break;
		}
     这个地方fastcgi_pass为unix:/tmp/php-cgi.sock,如果为127.0.0.1:9000,那么还需要设置:


      php-cgi -b 127.0.0.1:9000 -c xxx/php.ini

      搞完之后就没问题了!!!! 



你可能感兴趣的:(nginx,学习,明庭令,zzb)