Skip to content

Instantly share code, notes, and snippets.

@somat
Last active August 29, 2015 14:05
Show Gist options
  • Save somat/07fa14dc85e9a5f4067d to your computer and use it in GitHub Desktop.
Save somat/07fa14dc85e9a5f4067d to your computer and use it in GitHub Desktop.
Nginx Configuration for Codeigniter
server {
listen 80 default_server;
server_name dev.example.com;
location / {
root /usr/share/nginx/html;
index index.php index.html;
}
location /exampleci/ {
root /usr/share/nginx/html/exampleci;
index index.php;
if (-f $request_filename) {
expires 30d;
break;
}
if (!-e $request_filename) {
rewrite ^(.+)$ /exampleci/index.php?$1 last;
}
}
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
access_log off;
expires 30d;
root /usr/share/nginx/html/;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment