CodeIgniter Forums
[Wiki] How to setup Codeigniter on Nginx - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: [Wiki] How to setup Codeigniter on Nginx (/showthread.php?tid=62268)



[Wiki] How to setup Codeigniter on Nginx - FlevasGR - 06-26-2015

Many users have come across this simple problem: How do i run Codeigniter with Nginx?

This might be a little bit confusing since every single tutorial uses apache and htaccess files. For that reason i'm making this post to settle this problem.

The code below uses PHP-FPM and it's the most basic snippet you can use. I'm assuming that you already have a very basic knowledge on Nginx's config but if you dont a copy/paste on the 'default' file will do the job.

Code:
server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    index index.php;

    root /var/www/vhosts/domain.tld/httpdocs;

    server_name localhost;

    location / {
        try_files $uri $uri/ =404;
    }

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

    try_files $uri $uri/ /index.php;
    if (!-e $request_filename){
        rewrite ^/(.*)$ /index.php?/$1? last;
    }
    location /index.php {
        set $script     $uri;
        set $path_info  $uri;
        if ($args ~* "^(/.+)$") {
            set $path_info  $1;
        }
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $path_info;
    }
    if ($request_uri ~* "^(.*/)index\.php$") {
        return 301 $1;
    }

}



RE: [Wiki] How to setup Codeigniter on Nginx - DaveX64 - 06-26-2015

Thanks for posting this, I'll give it a try tomorrow Smile


RE: [Wiki] How to setup Codeigniter on Nginx - rjuniod - 07-08-2015

Me is not working.
The welcome of the page appears.
If you do blog.php page test described in the documentation I get the following message "No input file specified."
Can you help me?
Tks!


RE: [Wiki] How to setup Codeigniter on Nginx - Laucian - 09-09-2015

Thanks!!, it finally works for me after a long search on google Big Grin