Forked from stefan-vatov/nginx_codeigniter_virtualhost.nginxconf
Created
May 30, 2016 11:43
-
-
Save funyx/21f87dbda9a4c56ac6cecf5fee5e78e8 to your computer and use it in GitHub Desktop.
Nginx: Codeigniter virtual host
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment