Created
August 9, 2012 18:48
-
-
Save tmaiaroto/3307058 to your computer and use it in GitHub Desktop.
Nginx Virtual Host Setup for OS X using Homebrew
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
# | |
# A virtual host using mix of IP-, name-, and port-based configuration. | |
# This is based on using Homebrew for OS X. You can use this in other | |
# cases though, but you'll likely need to adjust some of the paths below. | |
# | |
server { | |
# Replace this port with the right one for your requirements | |
# listen 80 [default|default_server]; #could also be 1.2.3.4:80 | |
# This is set to 8080 because this conf is for Nginx running on OS X via brew. | |
# Without root permissions you can not run an app and bind it to a lower port like 80. | |
# That's ok, we have a solution. | |
# Go here: https://github.com/coverall/nginx and look down at step 8a. | |
listen 8080; | |
# Multiple hostnames separated by spaces. Replace these as well. | |
server_name dev.local *.dev.local; | |
# Extracts the subdomain to a variable | |
# But sets the default to be 'mysite' for dev.local | |
# ie. /usr/local/sites/mysite | |
set $sub 'mysite'; | |
if ($host ~ "^(.*).dev.local") { | |
set $sub $1; | |
} | |
# and even better... | |
# this allows Lithium apps to have their webroot set | |
# and leaves everything else as www... more flexible. | |
set $li3root ''; | |
if (-f $document_root/webroot/index.php) { | |
set $li3root '/webroot'; | |
} | |
# CHANGE THIS to where ever you want to keep your sites. | |
# I recommend this if you're using brew on OS X. | |
root /usr/local/sites/$sub/www$li3root; | |
# ENSURE sendfile IS OFF. IT'S A PIECE OF JUNK. | |
# The idea is to optimize the sending of files, | |
# but it's causing more problems than it's worth. | |
# Enable it if you want, but don't say I didn't warn ya. | |
sendfile off; | |
# I haven't seen the need, but it may be worth setting these higher. | |
# client_max_body_size 24M; | |
# client_body_buffer_size 128k; | |
# error_page 404 errors/404.html; | |
# UNCOMMENT TO ENABLE ACCESS LOGGING | |
# again, you may need to adjust the path... | |
# a few conditions for logging (it can be global or PER site) | |
# set $access_log_path logs/access.log; | |
# if (-d /usr/local/sites/$sub/logs) { | |
# set $access_log_path $sub/logs/access.log; | |
# } | |
# access_log /usr/local/sites/$access_log_path; | |
access_log off; | |
# PHP ERROR LOG PATH IS SET AT /usr/local/etc/php/5.4/php-fpm.conf if using brew and php 5.4 | |
# Otherwise, check your php config. | |
index index.php index.html index.htm; | |
# for Lithium to work, /index.php?$args | |
try_files $uri $uri/ /index.php?$args; | |
# location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ { | |
# access_log off; | |
# expires max; | |
# } | |
location ~ \.php$ { | |
fastcgi_intercept_errors on; | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
# Again, you may need to change this path, it's based on a brew install. | |
include /usr/local/etc/nginx/fastcgi_params; | |
} | |
location ~ /\.ht { | |
deny all; | |
} | |
} |
it should be in /opt/homebrew/etc/nginx/servers
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
But where that file needs to create ?