CI + OSX 10.6.7 + nginx + php-cgi渲染输出问题

时间:2011-04-07 15:23:52

标签: macos codeigniter nginx fastcgi

我正在使用我的MacBook Pro(OSX 10.6.7)作为具有此配置的开发服务器

nginx 0.8.54_0
php5 @5.3.6_0+fastcgi
fcgi @2.4.0_3 
spawn-fcgi @1.6.3_0

我的CI是1.7.2和1.7.3

我的目录结构就像这样

my document root is /Users/nuri/Sites
my CI system located in /Users/nuri/frameworks/CI/system
my CI application located in /Users/nuri/project/apps1/application

问题是当访问任何CI控制器时,nginx没有返回/打印任何内容 我使用来自MAMP包的apache进行测试,控制器工作正常

访问index.php / welcome

的示例

从CI日志文件中,Nginx似乎停止在此状态

DEBUG - 2011-04-07 20:39:36 --> Config Class Initialized
DEBUG - 2011-04-07 20:39:36 --> Hooks Class Initialized
DEBUG - 2011-04-07 20:39:36 --> URI Class Initialized
DEBUG - 2011-04-07 20:39:36 --> Router Class Initialized
DEBUG - 2011-04-07 20:39:36 --> Output Class Initialized
DEBUG - 2011-04-07 20:39:36 --> Input Class Initialized
DEBUG - 2011-04-07 20:39:36 --> Global POST and COOKIE data sanitized
DEBUG - 2011-04-07 20:39:36 --> Language Class Initialized
DEBUG - 2011-04-07 20:39:36 --> Loader Class Initialized
DEBUG - 2011-04-07 20:39:36 --> Helper loaded: form_helper
DEBUG - 2011-04-07 20:39:36 --> Helper loaded: url_helper
DEBUG - 2011-04-07 20:39:36 --> Database Driver Class Initialized

用apache访问时,日志说:

DEBUG - 2011-04-07 20:40:09 --> Config Class Initialized
DEBUG - 2011-04-07 20:40:09 --> Hooks Class Initialized
DEBUG - 2011-04-07 20:40:09 --> URI Class Initialized
DEBUG - 2011-04-07 20:40:09 --> Router Class Initialized
DEBUG - 2011-04-07 20:40:09 --> Output Class Initialized
DEBUG - 2011-04-07 20:40:09 --> Input Class Initialized
DEBUG - 2011-04-07 20:40:09 --> XSS Filtering completed
DEBUG - 2011-04-07 20:40:09 --> XSS Filtering completed
DEBUG - 2011-04-07 20:40:09 --> Global POST and COOKIE data sanitized
DEBUG - 2011-04-07 20:40:09 --> Language Class Initialized
DEBUG - 2011-04-07 20:40:09 --> Loader Class Initialized
DEBUG - 2011-04-07 20:40:09 --> Helper loaded: form_helper
DEBUG - 2011-04-07 20:40:09 --> Helper loaded: url_helper
DEBUG - 2011-04-07 20:40:09 --> Database Driver Class Initialized
DEBUG - 2011-04-07 20:40:09 --&gt; Session Class Initialized   <-------- missing this line below <<<
DEBUG - 2011-04-07 20:40:09 --&gt; Helper loaded: string_helper
DEBUG - 2011-04-07 20:40:09 --&gt; Session routines successfully run
DEBUG - 2011-04-07 20:40:09 --&gt; User Agent Class Initialized
DEBUG - 2011-04-07 20:40:09 --&gt; Controller Class Initialized
DEBUG - 2011-04-07 20:40:09 --&gt; Final output sent to browser
DEBUG - 2011-04-07 20:40:09 --&gt; Total execution time: 0.0582

我试图制作陷阱 我发现CI + nginx“没有处理”任何东西 来自system / codeigniter / CodeIgniter.php,以行

开头
$CI = new $class();

它可以正常使用apache,至少我可以print_r $ CI值

请尽快得到专家的帮助

我的nginx服务器配置是

server {
        listen       8080;
        server_name  jupiter;

        index index.php index.html index.htm;
        root /Users/nuri/Sites;
        access_log  /tmp/jupiter.access.log  webalizer;
        error_log  /tmp/jupiter.error.log debug;

        client_max_body_size       5m;
        client_body_buffer_size    256k;

        #error_page 404 /index.php;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        error_page   404 /40x.html;
        location = /50x.html {
            root   /opt/local/html;
        }

        location = /40x.html {
            root   /opt/local/html;
        }

        location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
            access_log        off;
            expires           30d;
            #expires max;
            add_header Pragma public;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            break;
        }

        location ^/project/apps1/ {
            if (!-e $request_filename) {
                  rewrite ^/project/apps1/(.*)$ /project/apps1/index.php/$1 last;
              }
        }


        location /project/apps1/index.php {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_param SCRIPT_FILENAME /Users/nuri/Sites/project/apps1/index.php; 
            include        /opt/local/etc/nginx/fastcgi_params;            
        } 

        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        /opt/local/etc/nginx/fastcgi_params;            
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
            deny  all;
        }
    }

1 个答案:

答案 0 :(得分:1)

在ubuntu上,这条线为我解决了这个问题:

sudo apt-get install php5-cgi php5-dev php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ps php5-pspell php5-recode php5-snmp php5-tidy php5-xmlrpc php5-xsl php5-common php5-mysql

最有可能不是最好的方法,但看起来其中一个软件包可以解决问题;)