Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Nginx: Codeigniter virtual host
server {
listen [port];
server_name [web url];
access_log [access_log_location];
error_log [error_log_location];
root [where_to_serve from];
index index.html index.php;
# If file is an asset, set expires and break
location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
expires max;
break;
}
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
# Serve the directory/file if it exists, else pass to CodeIgniter front controller
location / {
try_files $uri $uri/ @codeigniter;
}
# CodeIgniter Front Controller
location @codeigniter {
internal;
root [where_to_serve_from];
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass php5-fpm-sock;
fastcgi_index index.php;
include fastcgi_config;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
}
location ~* \.php$ {
fastcgi_pass php5-fpm-sock;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
include fastcgi_params;
include fastcgi_config;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
@ekariz

This comment has been minimized.

Copy link

commented Apr 28, 2016

thanks , helped me alot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.