Skip to content

Instantly share code, notes, and snippets.

@robertlemke
Created July 23, 2013 17:37
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save robertlemke/6064401 to your computer and use it in GitHub Desktop.
Save robertlemke/6064401 to your computer and use it in GitHub Desktop.
My very rudimentary nginx.conf file which I use for development on my Mac. I use a special setup with dnsmasq which redirects all URLs like foo.dev, foo.prod etc. to my localhost. I use Nginx in combination with PHP-FPM. You can do the same with Apache, see: https://gist.github.com/robertlemke/4951820
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
root /Users/robert/Sites;
server {
listen 80;
server_name localhost;
location / {
index index.php index.html;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_index index.php;
try_files $uri =404;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
server {
listen 80;
server_name ~^(?<project>.*)\.dev$;
root /Users/robert/Sites/$project/Web;
client_max_body_size 50M;
index index.php;
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
try_files $uri $uri/ /index.php?$args;
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param FLOW_CONTEXT Development;
fastcgi_param FLOW_REWRITEURLS 1;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~ "^/_Resources/Persistent/" {
rewrite "(.{40})/.+\.(.+)" /_Resources/Persistent/$1.$2 break;
rewrite "([a-z0-9]+/(.+/)?[a-f0-9]{40})/.+\.(.+)" /_Resources/Persistent/$1.$2 break;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~* \.(jpg|jpeg|gif|css|png|js|ico)$ {
access_log off;
expires max;
}
}
server {
listen 80;
server_name ~^(?<project>.*)\.prod$;
root /Users/robert/Sites/$project/Web;
client_max_body_size 50M;
index index.php;
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
try_files $uri $uri/ /index.php?$args;
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param FLOW_CONTEXT Production;
fastcgi_param FLOW_REWRITEURLS 1;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~ "^/_Resources/Persistent/" {
rewrite "(.{40})/.+\.(.+)" /_Resources/Persistent/$1.$2 break;
rewrite "([a-z0-9]+/(.+/)?[a-f0-9]{40})/.+\.(.+)" /_Resources/Persistent/$1.$2 break;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~* \.(jpg|jpeg|gif|css|png|js|ico)$ {
access_log off;
expires max;
}
}
server {
listen 80;
server_name ~^(?<project>.*)\.l$;
root /Users/robert/Sites/$project;
client_max_body_size 50M;
index index.php;
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
try_files $uri $uri/ /index.php?$args;
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~* \.(jpg|jpeg|gif|css|png|js|ico)$ {
access_log off;
expires max;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment