Answer the question
In order to leave comments, you need to log in
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/host
added 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;
}
}
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
/etc/nginx/sites-available/mysite_nginx.conf
.
Answer the question
In order to leave comments, you need to log in
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question