Ownership and permissions for nginx local webserver
<p>I'm having trouble setting up my local nginx environment. I've been reading countless tutorials online and everything seems to have jumbled my brain a little.</p>

<p>OS: OSX 10.11.4 El Capitan
Nginx: 1.8.1
PHP-FPM: 5.5.31</p>

<p>My web root's file directory is as follows for now:</p>

<pre><code>/webserver
/webverver/phpinfo.php
/webserver/example
/webserver/example/index.php
</code></pre>

<p>I can access the default "Welcome to Nginx" page using curl or in a web browser accessing localhost. If I then browse I get the indexing of files, yet the PHP files will attempt to download rather than execute. If I try to access the example site that I have created at <code>local.example.com</code> (which I have added to my hosts file) then I get 403 Forbidden header return using curl and a nice, simple 'Access Denied' using the web browser.</p>

<p>I'm not so clued up on file permissions and directory ownership, could someone advise as to how I should be configuring everything? I was advised to run the following command, but it changed nothing as of yet:</p>

<p><code>sudo chmod -R 755 /Users/nickcorin/webserver</code></p>

<p>There aren't any logs in my error log besides 'signal started' logs.</p>

<p>Here's my configuration at the moment:</p>

<p><code>nginx.conf</code></p>

<pre><code>#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  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        location / {
            root   /Users/nickcorin/webserver;
        autoindex on;
        }

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

    include servers/*;
}
</code></pre>

<p><code>servers/example</code></p>

<pre><code>upstream php {
    server 127.0.0.1:9000;
}

server {
    listen 80;

    root /Users/nickcorin/webserver/example;
    server_name local.example.com;

    index index.php index.html index.htm;
    autoindex on;

     location ~ \.php$ {
            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;
        }
}
</code></pre>

<p>** EDIT - NGINX Folder Permissions &amp; Process Owners **</p>

<p>I ran <code>ls -la</code> on my log folder <code>/usr/local/var/nginx</code> and this was the result:</p>

<pre><code>drwxr-xr-x  4 nickcorin  admin   136 Apr 20 23:53 .
drwxr-xr-x  5 nickcorin  admin   170 Apr 20 21:47 ..
-rw-r--r--  1 root       admin  4718 Apr 21 08:06 access.log
-rw-r--r--  1 nickcorin  admin   480 Apr 21 10:28 error.log
</code></pre>

<p>And this was the result on my webserver root:</p>

<pre><code>drwxr-xr-x   4 nickcorin  staff   136 Apr 22 12:23 .
drwx-----x+ 54 nickcorin  staff  1836 Apr 22 10:01 ..
drwxr-xr-x   3 nickcorin  staff   102 Apr 20 22:14 example
-rw-r--r--@  1 nickcorin  staff    23 Apr 19 11:58 info.php
</code></pre>

<p>This was the result of <code>ps aux | grep nginx</code>:</p>

<pre><code>root              756   0.0  0.0  2466616    480   ??  Ss   12:24PM   0:00.00 nginx: master process nginx
nickcorin         759   0.0  0.0  2445080    820 s000  S+   12:24PM   0:00.00 grep nginx
nobody            757   0.0  0.0  2475832   1044   ??  S    12:24PM   0:00.00 nginx: worker process
</code></pre>

<p>** EDIT #2 - Virtual Host Config File **</p>

<p>I managed to fix my problem and things seem to be working smoothly now. I had to edit my Virtual Host configuration file to this:</p>

<pre><code>server {
    listen 80;
    listen [::]:80 ipv6only=on;

    server_name local.example.com;

    root /Users/nickcorin/webserver/example;
    index index.php index.html index.htm;

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}
</code></pre>

<p>I also fixed my permissions with the following two lines:</p>

<pre><code>sudo chown -R nickcorin /Users/nickcorin/webserver (Web Server Root)
sudo chmod 755 /Users/nickcorin/webserver/example (Virtual Host Root)
</code></pre>

<p>Thank you to everyone that helped me figure this out :)</p>