nginx config set up/ Local setup I try to setup custom nginx config for site. Local setup. I use vmware virtual machine Mac OS X EL capitan 10.11. and use this tutorial 

It's my nginx.conf 

enter code here

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
   worker_connections  1024;
}


http {
   include       mime.types;
    default_type  application/octet-stream;

#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
#                  '$status $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';

#access_log  logs/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  65;

#gzip  on;

server {
  root /Users/myfolder/Documents/folder/project-folder/;
  index index.php index.html index.htm;
  server_name project.dev;
  index index.php;
  client_max_body_size 2000M;
  location / {
    try_files $uri $uri/ /index.php?$args;
  }
  # Add trailing slash to */wp-admin requests.
  rewrite /wp-admin$ $scheme://$host$uri/ permanent;
  # Directives to send expires headers and turn off 404 error logging.
  location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
      access_log off; log_not_found off; expires max;
  }
  location ~ \.php$ {
      fastcgi_pass 127.0.0.1:9000;
      fastcgi_buffer_size 128k;
      fastcgi_buffers 4 256k;
      fastcgi_busy_buffers_size 256k;
      fastcgi_index index.php;
      include fastcgi.conf;
  }
 }


project.dev configuration: 

enter code here
server {
root /Users/myfolder/Documents/folder/project/;
index index.php index.html index.htm;
server_name project.dev;
index index.php;
client_max_body_size 2000M;
location / {
  try_files $uri $uri/ /index.php?$args;
}
# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
# Directives to send expires headers and turn off 404 error logging.
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
    access_log off; log_not_found off; expires max;
}
location ~ \.php$ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 4 256k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_index index.php;
    include fastcgi.conf;
 }
}   


host: 

 ##
 # Host Database
 #
 # localhost is used to configure the loopback interface
 # when the system is booting.  Do not change this entry.
 ##
 127.0.0.1    project.dev
 255.255.255.255    broadcasthost
 ::1    


I try to setup http://project.dev - it's not working. This site can’t be reached.  What did I miss?
Your nginx.conf and your project.dev are somewhat hosed. And in my opinion your hosts is "non-standard".

I propose a different method - using a virtual hosts configuration with no standard site.

I assume nginx is already installed with brew. Instead of using the sudo brew services nginx start/stop command (which creates/loads and unloads/removes a launch daemon all the time) I use a permanent launch daemon here.


Stop nginx!
Copy the nginx' launch daemon to /Library/LaunchDaemons and modify the permissions:

sudo cp -v /usr/local/opt/nginx/*.plist /Library/LaunchDaemons/
sudo chown root:wheel /Library/LaunchDaemons/homebrew.mxcl.nginx.plist

Create following folders (if they don't already exist)

mkdir -p /usr/local/etc/nginx/logs
mkdir -p /usr/local/etc/nginx/sites-available
mkdir -p /usr/local/etc/nginx/sites-enabled

Replace the content of the current nginx.conf by

worker_processes  1;

error_log  /usr/local/etc/nginx/logs/error.log debug;

events {
    worker_connections  256;
}

http {
    include             mime.types;
    default_type        application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /usr/local/etc/nginx/logs/access.log  main;

    sendfile            on;

    keepalive_timeout   65;

    index index.html index.php;

    include /usr/local/etc/nginx/sites-enabled/*; 
}

Create your project folder:

mkdir -p ~/Development/project-folder/project.dev

Add at least a simple index.html in ~/Development/project-folder/project.dev (to be able to test nginx)
Create a file project.dev in /usr/local/etc/nginx/sites-available/ with the following content:

server {
  listen                *:80;
  server_name           project.dev;

  location / {
    root  /Users/your_username/Development/project-folder/project.dev;
    try_files  $uri  $uri/  /index.php?$args;
    index  index.html index.htm index.php;
  }

  location ~ \.php$ {
    root  /Users/your_username/Development/project-folder/project.dev;
    try_files  $uri  $uri/  /index.php?$args;
    index  index.html index.htm index.php;

    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_intercept_errors on;
    include fastcgi_params;
  }

}


Now link project.dev to sites.enabled:

ln -s /usr/local/etc/nginx/sites-available/project.dev /usr/local/etc/nginx/sites-enabled

Modify you hosts file with sudo nano /etc/hosts to:

127.0.0.1   localhost
127.0.0.1   project.dev
255.255.255.255 broadcasthost
::1             localhost 

Test the nginx config:

sudo nginx -t

Start nginx with:

sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist

Test the website with:

curl -IL http://project.dev:80

To manage nginx easily create some handy aliases in ~/.bash_profile like:

alias nginx.start='sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist'
alias nginx.stop='sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.nginx.plist'
alias nginx.restart='nginx.stop &amp;&amp; nginx.start'


Source the modified .bash_profile with source ~/.bash_profile afterwards.




After setting up a working basic website, add all necessary additional directives/locations. Check the error logs for errors afterwards!



To reach the OS X VM's website with a client (e.g the VM host - your physical computer), add an entry for project.dev in the client's hosts file:

127.0.0.1   localhost
ip_address_of_osx-vm    project.dev
255.255.255.255 broadcasthost
::1             localhost 


The most simple set up for the VM is to attach the network interface of the VM to a bridged network:

VM > Settings > Removable Devices > Network Adapter > Bridged Networking > Ethernet (or Wi-Fi)

In the Network preferences of the VM configure an IP in the same network as the VM-host's network interface. Example: if the bridged interface is Wi-Fi and the IP address of the VM host's Wi-Fi is 192.168.0.15/255.255.255.0, choose a unique IP in the same network for the OS X VM's network interface (e.g. 192.168.0.115/255.255.255.0).

A (website) client's hosts file should look like this then:

127.0.0.1   localhost
192.168.0.115   project.dev
255.255.255.255 broadcasthost
::1             localhost