Welcome Guest, Not a member yet? Register   Sign In
codeigniter + nginx + php-fpm
#1

[eluser]luisfmgoncalves[/eluser]
Hey guys.

I developed a webpage with codeigniter and apache. I use Ubuntu in the computer I developed the application.
After that and when I try to upload to the production server, the system administration told me that the application should run in nginx and with php-fpm. Oh, and he told me that the Linux distribuiton is CentOS.
Since that moment I realized that I will get problems for sure.

So, after I upload the project to the server, I get a 504 Gateway Timeout . And the good thing is that I don't have access to the nginx error.log... O.O

Anyway, after this, I decided to install the same version of nginx and php in the computer I developed (with Ubuntu) and make it work and after that upload the project the server. I make it work in my computer but was still not working in the server.

I decided to upload a clean version of codeigniter and started to had code till I get the error. With this method I realized that something was not working properly.

In the project I have a template view with the following code:

Code:
<?php
$this->load->view('include/header_view');
$this->load->view($main_content);
$this->load->view('include/footer_view');
?>

where $main_content is a variable that I assign with whatever I want.

But, the problem is that in the server this line:

Code:
$this->load->view('include/header_view');

simple don't work! Looks like I can't load a view from another view. I don't know if this is something related with paths...
Maybe is a CentOS thing, because in my Ubuntu everything works good with nginx and php-fpm. I'm not a Red Hat user, so maybe I'm missing something...

I also tried to load the header from the same folder:

Code:
$this->load->view('header_view');

But doesn't work.
If I call directly the header_view file, than works fine!

This is something I can change... I just need to rewrite some views and I make it work...
But I'm curious about what is wrong!

My nginx.conf file is like this:

Code:
server {
access_log  /var/log/nginx/localhost.access.log;
root /var/www/project;
server_name domain.com;

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

if ($request_uri ~* ^(/home(/index)?|/index(.php)?)/?$){
    rewrite ^(.*)$ / permanent;
}

if ($request_uri ~* index/?$){
    rewrite ^/(.*)/index/?$ /$1 permanent;
}

if (!-d $request_filename){
    rewrite ^/(.+)/$ /$1 permanent;
}

error_page 404 /index.php;

location / {
    root   /var/www/project;
    index  index.php;
}

location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
  access_log        off;
  expires           30d;
  root /var/www/project;
}

## Parse all .php file in the /var/www directory
    location ~ .php$ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /var/www/project$fastcgi_script_name;
    include fastcgi_params;
    fastcgi_connect_timeout 60;
    fastcgi_send_timeout 180;
    fastcgi_read_timeout 180;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 4 256k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_temp_file_write_size 256k;
    fastcgi_intercept_errors on;
}

## Disable viewing .htaccess & .htpassword
     location ~ /\.ht {
         deny  all;
     }
}
upstream backend {
        server 127.0.0.1:9000;
}

Is the problem related with this configuration?
Any of you had this problem before?

Thanks,

Luis

P.S.:
PHP 5.3.3 (php modules from remi repositories)
CentOS 5.5
mysql
Codeigniter 1.7.2


Messages In This Thread
codeigniter + nginx + php-fpm - by El Forum - 11-24-2010, 07:23 AM
codeigniter + nginx + php-fpm - by El Forum - 11-24-2010, 12:10 PM
codeigniter + nginx + php-fpm - by El Forum - 11-30-2010, 09:52 AM



Theme © iAndrew 2016 - Forum software by © MyBB