Skip to content

Instantly share code, notes, and snippets.

@bendo01
Created February 7, 2012 16:56
Show Gist options
  • Save bendo01/1760725 to your computer and use it in GitHub Desktop.
Save bendo01/1760725 to your computer and use it in GitHub Desktop.
nginx cakephp
#user nobody;
worker_processes 1;
#error_log /opt/local/logs/error.log;
#pid /opt/local/logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#access_log /opt/local/logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
root /opt/local/www;
access_log /opt/local/var/log/nginx/access.log;
error_log /opt/local/var/log/nginx/error.log;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
# server_name_in_redirect off;
location / {
autoindex on;
# This is cool because no php is touched for static content
try_files $uri $uri/ /index.php;
}
# rewrite rules for cakephp
location /ikuliner {
if (!-e $request_filename) {
rewrite ^/ikuliner(.+)$ /ikuliner/app/webroot/$1 last;
break;
}
}
location /ikuliner/app/webroot {
if (!-e $request_filename) {
rewrite ^/ikuliner/app/webroot/(.+)$ /ikuliner/app/webroot/index.php?url=$1 last;
break;
}
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
#root /var/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
#include ikulinerApp.conf;
}
//in cake
App/Config/core.php
/**
* To configure CakePHP *not* to use mod_rewrite and to
* use CakePHP pretty URLs, remove these .htaccess
* files:
*
* /.htaccess
* /app/.htaccess
* /app/webroot/.htaccess
*
* And uncomment the App.baseUrl below:
*/
//Configure::write('App.baseUrl', env('SCRIPT_NAME'));
Configure::write('App.base', '/ikuliner');
Configure::write('App.baseUrl', '/ikuliner/');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment