CodeIgniter和Nginx - 找不到类

时间:2013-12-05 20:04:28

标签: php codeigniter nginx

我已将本地主机上的CodeIgniter应用程序 Apache 上传到运行 Nginx 的服务器。

它在我的localhost和Apache的其他服务器上完美运行。

它位于子域下,域和其他子域正在运行PHP 100%。

CI中的此应用程序无法启动,并且在未经编译的情况下返回PHP。

这是我在/var/log/nginx/error.log上的内容:

2013/12/05 14:50:31 [error] 20139#0: *1 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Class 'M_website' not found in /home/webroot/domain.com/cms/system/core/Loader.php on line 303" while reading upstream, client: 84.91.4.220, server: cms.domain.com, request: "GET /websites HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "cms.domain.com"

在/home/webroot/domain.com/cms/system/core/Loader.php

中找不到“M_website”类

这是我的子域名。

server
{
    server_name cms.domain.com;
    access_log /var/log/nginx/cms.domain.access.log;
    root /home/webroot/domain.com/cms;

    index index.php index.html index.htm;

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

    # enforce NO www
    if ($host ~* ^www\.(.*))
    {
        set $host_without_www $1;
        rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
    }

    # canonicalize codeigniter url end points
    # if your default controller is something other than "welcome" you should change the following
    if ($request_uri ~* ^(/websites/(/index)?|/index(.php)?)/?$)
    {
        rewrite ^(.*)$ / permanent;
    }

    # removes trailing "index" from all controllers
    if ($request_uri ~* index/?$)
    {
        rewrite ^/(.*)/index/?$ /$1 permanent;
    }

    # canonicalize codeigniter url end points
    # if your default controller is something other than "welcome" you should change the following
    if ($request_uri ~* ^(/websites/(/index)?|/index(.php)?)/?$)
    {
        rewrite ^(.*)$ / permanent;
    }

    # removes trailing "index" from all controllers
    if ($request_uri ~* index/?$)
    {
        rewrite ^/(.*)/index/?$ /$1 permanent;
    }

    # removes trailing slashes (prevents SEO duplicate content issues)
    if (!-d $request_filename)
    {
        rewrite ^/(.+)/$ /$1 permanent;
    }

    # removes access to "system" folder, also allows a "System.php" controller
    if ($request_uri ~* ^/system)
    {
        rewrite ^/(.*)$ /index.php?/$1 last;
        break;
    }

    # unless the request is for a valid file (image, js, css, etc.), send to bootstrap
    if (!-e $request_filename)
    {
        rewrite ^/(.*)$ /index.php?/$1 last;
        break;
    }

    # catch all
    error_page 404 /index.php;

    # use fastcgi for all php files
    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
    }

    # deny access to apache .htaccess files
    location ~ /\.ht
    {
        deny all;
    }

}

1 个答案:

答案 0 :(得分:2)

为什么会出现问题?

CI文件以

开头
<?

而不是

<?php

解决方案

必须编辑 /etc/php5/fpm/php.ini 并将 short_open_tag 从关闭设置为开启并重新启动php-fpm < / p>

service php5-fpm restart