1

I'v uploaded a CodeIgniter application from my localhost with Apache to a server running Nginx.

Its works perfectly on my localhost and on other server with Apache.

It's under a subdomain, an domain and other subdomains are running PHP 100%.

This application in CI doesn't start, and PHP is returned without being compiled.

This is what I get on /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"

Class 'M_website' not found in /home/webroot/domain.com/cms/system/core/Loader.php

This is my subdomain conf.

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

}
5
  • "PHP is returned without being compiled" --- uhm, what? Commented Dec 5, 2013 at 20:05
  • I see the source code! :( if i remove all CI scripts etc and put a simple <?php echo 'hello'; ?> in a index.php it works... Commented Dec 5, 2013 at 20:19
  • How does your subdomain configuration look like on Ngnix? Commented Dec 5, 2013 at 22:00
  • tnks user1190992. question has been updated with it. Commented Dec 5, 2013 at 23:49
  • I was able to solve the problem. CI files were starting with <? and not with <?php Had to edit /etc/php5/fpm/php.ini and set short_open_tag from Off to ON Commented Dec 6, 2013 at 12:29

1 Answer 1

2

Why the problem?

CI files were starting with

<?

and not with

<?php

Solution

Had to edit /etc/php5/fpm/php.ini and set short_open_tag from Off to On and restart php-fpm

service php5-fpm restart
Sign up to request clarification or add additional context in comments.

1 Comment

that's why we are here :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.