FAQ

Page Discussion History

Difference between revisions of "Codeigniter"

 
 
(2 intermediate revisions by 2 users not shown)
Line 13: Line 13:
  
 
         location / {
 
         location / {
                 # Check if a file exists, or route it to index.php.
+
                 # Check if a file or directory index file exists, else route it to index.php.
 
                 try_files $uri $uri/ /index.php;
 
                 try_files $uri $uri/ /index.php;
 
         }
 
         }
Line 19: Line 19:
 
         location ~* \.php$ {
 
         location ~* \.php$ {
 
                 fastcgi_pass 127.0.0.1:9000;
 
                 fastcgi_pass 127.0.0.1:9000;
                 fastcgi_index index.php;
+
                 include fastcgi.conf;
                fastcgi_split_path_info ^(.+\.php)(.*)$;
+
                include fastcgi_params;
+
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+
 
         }
 
         }
 
}
 
}
Line 32: Line 29:
 
$config['index_page'] = "";
 
$config['index_page'] = "";
 
$config['uri_protocol'] = "REQUEST_URI";
 
$config['uri_protocol'] = "REQUEST_URI";
 +
</geshi>
 +
 +
An alternative configuration, production ready.
 +
You don't need to modify "config.php", except for removing "index.php"
 +
<geshi lang="php">
 +
$config['base_url'] = "";
 +
$config['index_page'] = "";
 +
$config['uri_protocol'] = "AUTO";
 +
</geshi>
 +
 +
<geshi lang="nginx">
 +
server {
 +
        listen      80;
 +
        server_name  localhost;
 +
        root  /var/www/html/ci;
 +
        autoindex on;
 +
        index index.php;
 +
 +
        location / {
 +
 +
            try_files $uri $uri/ /index.php;
 +
 +
            location = /index.php {
 +
 +
                fastcgi_pass  127.0.0.1:6969;
 +
                fastcgi_param  SCRIPT_FILENAME /var/www/html/ci$fastcgi_script_name;
 +
                include        fastcgi_params;
 +
            }
 +
        }
 +
 +
        location ~ \.php$ {
 +
            return 444;
 +
        }
 +
 +
 +
}
 +
 +
 
</geshi>
 
</geshi>

Latest revision as of 20:34, 10 July 2013

server {
        server_name domain.tld;
 
        root /var/www/codeignitor;
        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 or directory index file exists, else route it to index.php.
                try_files $uri $uri/ /index.php;
        }
 
        location ~* \.php$ {
                fastcgi_pass 127.0.0.1:9000;
                include fastcgi.conf;
        }
}

After this, make sure that your codeIgniter config.php contains the following information:

$config['base_url']	= "http://domain.tld/";
$config['index_page'] 	= "";
$config['uri_protocol']	= "REQUEST_URI";

An alternative configuration, production ready. You don't need to modify "config.php", except for removing "index.php"

$config['base_url']	= "";
$config['index_page'] 	= "";
$config['uri_protocol']	= "AUTO";
server {
        listen       80;
        server_name  localhost;
        root   /var/www/html/ci;
        autoindex on;
        index index.php;
 
        location / {
 
            try_files $uri $uri/ /index.php;
 
            location = /index.php {
 
                fastcgi_pass   127.0.0.1:6969;
                fastcgi_param  SCRIPT_FILENAME /var/www/html/ci$fastcgi_script_name;
                include        fastcgi_params;
            }
        }
 
        location ~ \.php$ {
            return 444;
        }
 
 
}