N
N
nurzhannogerbek2017-10-24 13:36:31
Nginx
nurzhannogerbek, 2017-10-24 13:36:31

Correct Nginx setup on Mac OS?

Hello, please help me figure it out!
I'm trying to set up Nginx on Mac OS.
I /usr/local/etc/nginx/servers/create a file mysite_nginx.conf. In /private/etc/hostadded 127.0.0.1 mysite. I start Nginx, go to url mysite:8888 , but the static is not displayed.
mysite_nginx.conf:

server {
    listen 80;
    server_name mysite;

    proxy_pass_request_headers on;
    proxy_pass_request_body on;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_read_timeout 120s;

    location = /favicon.ico { access_log off; log_not_found off; }

    location /static/ {
        root /Applications/Projects/web/mysite/;  <-- НЕ РАБОТАЕТ (путь до проекта)
    }

    location / {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://127.0.0.1:8888;
    }
}

Team nginx -t:
nginx: [alert] could not open error log file: open() "/usr/local/var/log/nginx/error.log" failed (13: Permission denied)
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
2017/10/24 16:40:18 [emerg] 1063#0: open() "/usr/local/var/run/nginx.pid" failed (13: Permission denied)
nginx: configuration file /usr/local/etc/nginx/nginx.conf test failed

PS Before that, I used Nginx only in Ubuntu 16.04, where custom settings for my project were created in the /etc/nginx/sites-available/mysite_nginx.conf.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lynn "Coffee Man", 2017-10-25
@nurzhannogerbek

Your nginx is listening on port 80 and you keep accessing port 8888 i.e. go not to nginx, but directly to the application.
Errors from nginx -t , because in nginx it checks not only the syntax, but also the availability of log files, and your user apparently does not have permission to write to the usr/local/var/log/nginx/error.log file . Therefore, checking the config, as well as rebooting, must be done with sudo .
sudo nginx -t

D
Danil Sapegin, 2017-10-24
@ynblpb_spb

I give you a hint :)
mysite:8888

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question