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

发布于 2024-10-30 20:51:55 字数 4936 浏览 1 评论 0原文

我使用我的 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

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

从CI日志文件访问index.php/welcome示例

,使用apache访问时,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

,日志说:

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;
        }
    }

I'm using my MacBook Pro (OSX 10.6.7) as development server with this configuration

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

my CI is 1.7.2 and 1.7.3

my directory stucture is like this

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

the problem is nginx did not return/print anything when accessing any CI controllers
i test using apache from MAMP packages the controllers are working fine

sample accessing index.php/welcome

from CI logfile, the Nginx seems to be stop at this state

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

when accessing with apache, the log said:

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 --> Session Class Initialized   <-------- missing this line below <<<
DEBUG - 2011-04-07 20:40:09 --> Helper loaded: string_helper
DEBUG - 2011-04-07 20:40:09 --> Session routines successfully run
DEBUG - 2011-04-07 20:40:09 --> User Agent Class Initialized
DEBUG - 2011-04-07 20:40:09 --> Controller Class Initialized
DEBUG - 2011-04-07 20:40:09 --> Final output sent to browser
DEBUG - 2011-04-07 20:40:09 --> Total execution time: 0.0582

i try to make traps
i found the CI + nginx "did not process" anything
from system/codeigniter/CodeIgniter.php starting with line

$CI = new $class();

it work fine with apache, at least i could print_r the $CI value

please, desperately need help from the expert here

my nginx server config is

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;
        }
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一杆小烟枪 2024-11-06 20:51:55

在 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

很可能不是最好的方法,但看起来这些包之一解决了问题;)

On ubuntu, this line solved it for me:

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

Most probably not the best way, but it looks like one of these packages solves the problem ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文