Recently I had to install nginx on my OSX machine for some testing…. And I ran into some permission issues.
First I am using brew to install nginx on OSX. The Brew website is located at http://brew.sh/ . The command line install ‘one liner’ is located at the bottom of the page
To install run this command
> ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
After brew is installed you can now use it to install nginx.
> brew install nginx
Then to start nginx you can run
> sudo nginx
Or to stop it run
> sudo nginx -s stop
However... I want to update the nginx.conf file to run using a nginx user, and do a few more settings.
For my test I created a folder on my desktop and I called it www. In the www file I placed a very simple index.html file to test. I also placed a log folder within the www folder.
Now edit the nginx.conf.
> sudo vi /usr/local/etc/nginx/nginx.conf
I edited mine to the following (make sure to user your folder structure not mine :)
user nginx staff;
log_format main_fmt '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
access_log /Users/PBailey-MBPro/Desktop/www/logs/access.log main_fmt;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
Create the nginx user
I found this site that goes over a few quick commands that can set up a new user in OSX https://www.gibixonline.com/post/2013/04/29/auto-start-nginx-as-daemon-on-osx-10-8 
Run the following commands
> sudo dscl . create /Groups/nginx PrimaryGroupID 390
> sudo dscl . create /Users/nginx UniqueID 390
> sudo dscl . create /Users/nginx PrimaryGroupID 390
> sudo dscl . create /Users/nginx UserShell /bin/false
> sudo dscl . create /Users/nginx RealName nginx
> sudo dscl . create /Users/nginx NFSHomeDirectory /usr/local/var/run/nginx
> sudo dscl . create /Groups/nginx GroupMembership nginx
> sudo dseditgroup -o edit -a nginx -t user staff
This will create the nginx user and add them to the "staff" group.
At this point if I start the nginx server
> sudo nginx
And open up http://127.0.0.1:8080/
I get the following 403 forbidden Error
Update permissions in the www directory
> cd ~/www
> sudo chown -R nginx:staff *
> sudo chown -R nginx:staff .
This almost gets us there but we have one last issue to fix the. The Desktop folder that contains the www folder needs to allow the staff group to read it.
> sudo chmod g+x ..
Now nginx is working !
 Brew Homepage
 Automatically start Nginx as a daemon on Mac OS X Mountain Lion 10.8