Welcome Guest, Not a member yet? Register   Sign In
Battling Codeigniter to work with Nginx for 3 days - Need urgent help!

Hello everyone.

As I'm trying to make my switch from Apache 2 to Nginx, I faced dozens of problems, and still fixing them. anyway, I'm trying to make them work, but no-luck yet. So I'm asking here looking for help/previous experience.

I used the default configurations to run PHP, and it works great when running PHP files only. but unfortunately codeigniter URL's doesn't end in *.PHP(as everybody knows).

So, Is there any possible way to make them work togather? it seems impossible to me, I tried lots of configurations(after modifying them to fit my environment, ofcource) but non of them worked with Codeigniter.

Hopefully posting my current configurations that works with normal php files, will lead to some solutions.

server {
        server_name _;#_ to catch all requests.

        root /usr/share/nginx/www;
        index index.html index.php;

        # set expiration of assets to MAX for caching
        location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
                expires max;
                log_not_found off;

        location / {
                # Check if a file exists, or route it to index.php.
                try_files $uri $uri/ /index.php;

        location ~* \.php$ {
                fastcgi_index index.php;
                fastcgi_split_path_info ^(.+\.php)(.*)$;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
using the previous configuration for my /sites-enabled/default configuration makes PHP works but not codeigniter, all I get is white pages, and codeigniter's custom 404 when accessing non-existent files.

I also reconfigured config.php files like the following:

$config['base_url'] = "http://localhost/";
$config['index_page']  = "";
$config['uri_protocol'] = "REQUEST_URI";

I tried these configurations and lots of others, usually the same results.

Anyway, there are few points that will(hopefully) get me an answer:

1.I tried these configurations on Debian 6/Ubuntu 12.04
2.I'm running the latest php5-fpm , nginx from apt-get.
3.Something I notice, commenting out SCRIPT_NAME and SCRIPT_FILENAME(in fastcgi_params file) causes codeigniter to show an error. however commenting these on the current configuration above doesn't have any impact.
4.File permissions for all files under /usr/share is 777, I know it's insecure, but I'm using it for testing only.

Theme © iAndrew 2016 - Forum software by © MyBB