公司以前用的是apache环境,打算换成nginx,在将禅道移到nginx遇到了一些问题,以前一直认为nginx只能用get方式访问,今天研究禅道二次开发时发现能静态友好(pathinfo)方式设置,并且这样设置访问的url比get方式访问的美观所以赶紧修改下博客,别误人!



静态友好方式(PATH_INFO)访问设置

[root@test ~]# more /data/web/zendao/zentaopms/config/my.php 
	installed       = true;
	$config->debug           = false;
	$config->requestType     = 'PATH_INFO'; // apache使用,nginx pathinfo方式路由
	//$config->requestType     = 'GET'; //nginx GET使用方式
	$config->db->host        = '192.168.1.189';
	$config->db->port        = '3306';
	$config->db->name        = 'zendao';
	$config->db->user        = 'zdadmin';
	$config->db->password    = 'zenDao.0420';
	$config->db->prefix      = 'zt_';
	$config->webRoot         = getWebRoot();
	$config->default->lang   = 'zh-cn';
	$config->mysqldump       = '/usr/local/mysql/bin/mysqldump';


    server {
        listen       80;
        rewrite_log on;
        server_name  zd.tiger.com;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
            root /data/web/zendao/zentaopms/www;
            index  index.html index.htm index.php;
	    try_files $uri $uri/ /index.php?$args;
        }  
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        location ~ \.php$ {
            root           /data/web/zendao/zentaopms/www;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
	    fastcgi_param PATH_INFO $request_uri;
            include        fastcgi_params;

        }
    }

GET访问方式设置
    
[root@test ~]# more /data/web/zendao/zentaopms/config/my.php 
	installed       = true;
	$config->debug           = false;
	//$config->requestType     = 'PATH_INFO'; //apache使用,nginx pathinfo方式路由
	$config->requestType     = 'GET'; //nginx get使用方式
	$config->db->host        = '192.168.1.189';
	$config->db->port        = '3306';
	$config->db->name        = 'zendao';
	$config->db->user        = 'zdadmin';
	$config->db->password    = 'zenDao.0420';
	$config->db->prefix      = 'zt_';
	$config->webRoot         = getWebRoot();
	$config->default->lang   = 'zh-cn';
	$config->mysqldump       = '/usr/local/mysql/bin/mysqldump';


    server {
        listen       80;
        rewrite_log on;
        server_name  zd.tiger.com;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
            root /data/web/zendao/zentaopms/www;
            index  index.html index.htm index.php;
            if (!-e $request_filename) {
                rewrite ^/(.*)$ /index.php/$1 last;
            break;
                }
        }  
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        location ~ \.php$ {
            root           /data/web/zendao/zentaopms/www;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include        fastcgi_params;

        }
    }