1

I am using nginx on Mac, I installed it using Homebrew, and it used to work fine until this morning. Now, after a reboot, it doesn't read my nginx.conf (from /usr/local/etc/nginx/nginx.conf) anymore and loads its default index.html from /usr/local/var/www. If I force pass the config file explicitly using -c switch (sudo nginx -c /usr/local/etc/nginx/nginx.conf), nginx runs fine. Yesterday, I ran (python's) SimpleHTTPServer to serve a file and test something, then quit, and shut down. SimpleHTTPServer is not running anymore, I just ran it a couple of times yesterday. I don't know if the issue is related to that, but just in case. lsof does not show any process running on ports 80 or 443 except nginx.

Update:

In my nginx.conf, I serve files from different directories in a specified order (some directories are sym-linked):

location ~ ^/(js/|css/|img/|audio/|fonts/|files/|images/|video/) {
          root /Users/me/development/myCompany;
          try_files /staticFrontend/$uri /angularjsSPA/develop/$uri =404;
        }

Again sudo nginx -c /usr/local/etc/nginx/nginx.conf works fine, but sudo nginx does not.

3
  • Is the default configuration file in /usr/local… rather than /etc/nginx or someplace else? Does OS X have a "trace system calls made by this program?" When I run strace nginx on my Linux machine I get open("/etc/nginx/nginx.conf", O_RDONLY) = 3 which tells me where the default configuration file llives. Commented Jul 9, 2015 at 14:37
  • @msw yes, the default path for nginx and its configuration files is different on OS X if you install nginx using homebrew. Commented Jul 10, 2015 at 21:40
  • 1
    I had a similar issue on windows nginx. Turns out that I had multiple copies of nginx running (running with an older config). If you have this issue on windows check task manager for other nginx instances. Commented Nov 10, 2020 at 10:02

1 Answer 1

3

This would better be a comment, however, I've got not enough reputation to do so:

  • Could you clarify your problem? You wrote, that nginx is serving content from /usr/local/var/www. What do you expect instead? Did you specify a different folder? If so, which one, and in which config did you do this?

  • Normally, nginx.conf is used to specify general configuration directives.

  • Server blocks are normally specified in configs located in sites-available/, and symlinked from there to sites-enabled/. Upon startup, nginx reads these configs, where you would specify a different folder than /usr/local/var/www for example.

Sign up to request clarification or add additional context in comments.

1 Comment

In my config file, I serve files from different directories (some of them are symlinked):

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.