A
A
Alexander Fadeev2015-05-24 15:51:13
Nginx
Alexander Fadeev, 2015-05-24 15:51:13

What's wrong with configuring Nginx on MacOS X?

Friends, good afternoon.
Please help me figure it out, I've already broken my head. I'm setting up virtual hosts on a macbook to test a couple of CMSs locally. I follow the instructions to link via Homebrew: nginx+php-fpm+mysql
Localhost works fine:

localhost:~ user$ curl -IL http://localhost:80
HTTP/1.1 200 OK
Server: nginx/1.8.0
Date: Sun, 24 May 2015 12:39:19 GMT
Content-Type: text/html
Content-Length: 853
Last-Modified: Sun, 24 May 2015 08:15:56 GMT
Connection: keep-alive
ETag: "556188bc-355"
Accept-Ranges: bytes

But the virtual hosts configured according to the instructions are not:
localhost:~ user$ curl -IL http://site.local:80
HTTP/1.1 403 Forbidden
Server: nginx/1.8.0
Date: Sun, 24 May 2015 12:43:52 GMT
Content-Type: text/html
Content-Length: 168
Connection: keep-alive

nginx.conf:
worker_processes  1;
 
error_log  /usr/local/etc/nginx/logs/error.log debug;
 
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  /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/*;
}

Virtual host config:
server {
    listen       80;
    server_name  site.local www.site.local;
    root      /Users/user/Dropbox/Sites/site.local;
 
# Enable compression, this will help if you have for instance advagg module
        # by serving Gzip versions of the files.
        gzip_static on;

        # Block access to "hidden" files and directories whose names begin with a
        # period. This includes directories used by version control systems such
        # as Subversion or Git to store control files.
        location ~ (^|/)\. {
                return 403;
        }
 
        location / {
                # This is cool because no php is touched for static content
        include   /usr/local/etc/nginx/conf.d/php-fpm;
                try_files $uri @rewrite;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }
}

127.0.0.1 site.local was added to hosts, symlinks were added, nginx was rebooted. In general, this is not the first time I have done this, but on a poppy for the first time. I don’t want to use MAMP and others, because I don’t like Apache, and then the server will be on nginx, as I would like reliability.
In general, everything is according to the instructions. But it doesn't plow. Where am I lol? =(

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
asd111, 2015-05-24
@AlexFadeev

server {
    charset utf-8;
    client_max_body_size 128M;

    listen 80; ## listen for ipv4
    #listen [::]:80 default_server ipv6only=on; ## listen for ipv6

    server_name site.local www.site.local;
    root        /Users/user/Dropbox/Sites/site.local;;
    index       index.php;

    #Если нужно хранить логи nginx в папке проекта 
    #то создать указанные ниже файлы и раскомментировать 
    #access_log  /Users/user/Dropbox/Sites/site.local/log/access.log; 
    #error_log   /Users/user/Dropbox/Sites/site.local/error.log;

    location / {
        # Redirect everything that isn't a real file to index.php
        try_files $uri $uri/ /index.php?$args;
    }

    # uncomment to avoid processing of calls to non-existing static files by
    #location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
    #    try_files $uri =404;
    #}
    #error_page 404 /404.html;

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
        #fastcgi_pass   127.0.0.1:9000;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        try_files $uri =404;
    }

    location ~ /\.(ht|svn|git) {
        deny all;
    }
}

A
Andrey Burov, 2015-05-24
@BuriK666

enable error_log and see why 403.

E
evnuh, 2015-05-24
@evnuh

no location @rewrite or it's in conf.d/php-fpm show it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question