Welcome Guest, Not a member yet? Register   Sign In
[Wiki] How to setup Codeigniter on Nginx
#1

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

}
Reply
#2
Wink 

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

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!
Reply
#4

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




Theme © iAndrew 2016 - Forum software by © MyBB