Skip to content

Instantly share code, notes, and snippets.

@pyrmont
Created August 26, 2013 15:40
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pyrmont/6342870 to your computer and use it in GitHub Desktop.
Save pyrmont/6342870 to your computer and use it in GitHub Desktop.
This configuration file is designed to run the CMS Koken. If you just want a simple config file, use this instead: https://gist.github.com/pyrmont/6342859
daemon off;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include /usr/local/etc/nginx/mime.types; # Update if necessary
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name localhost;
root /path/to/your/dev/site; # Replace with the correct path
index index.html index.php;
# Directives to send expires headers and turn off 404 error logging.
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 24h;
log_not_found off;
}
# this prevents hidden files (beginning with a period) from being served
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
### Koken ###
# Set expires header for console CSS and JS.
# These files are timestamped with each new release, so it is safe to cache them agressively.
location ~ "console_.*\.(js|css)$" {
expires max;
}
# Catch image requests and pass them back to PHP if a cache does not yet exist
location ~ "^/storage/cache/images(/[0-9]{3}/[0-9]{3}/.*)$" {
try_files $uri /i.php?path=$1;
}
# Catch settings.css.lens requests and serve cache when possible
location ~ settings.css.lens$ {
default_type text/css;
try_files /storage/cache/site/${uri} /app/site/site.php?url=/settings.css.lens;
}
# Standard site requests are cached with .html extensions
set $cache_ext 'html';
# PJAX requests contain the _pjax GET parameter and are cached with .phtml extensions
if ($arg__pjax) {
set $cache_ext 'phtml';
}
# Catch root requests
location ~ ^/?$ {
try_files /storage/cache/site/index/cache.$cache_ext /app/site/site.php?url=/;
}
# All other requests get passed back to Koken unless file already exists
location / {
try_files $uri $uri/ /storage/cache/site/${uri} /storage/cache/site/${uri}cache.$cache_ext /app/site/site.php?url=$uri;
}
error_page 404 /index.php/error/404;
location ~ \.php$ {
client_max_body_size 25M;
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /usr/local/etc/nginx/fastcgi_params; # Update if necessary
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}
}
@pyrmont
Copy link
Author

pyrmont commented Aug 26, 2013

My URL rewriting skills are pretty wonky and on the initial installation, you’ll get a 404 error if you try to go to localhost:8080/. The solution is just to stick localhost:8080/index.php. Once Koken is installed, you’ll have no problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment