mac brew services start nginx not working

Recently I need to use the native development environment, found that using the brew command to start nginx, the prompt is successful, but the actual process is not started.

➜  ~ brew services restart nginx
 Stopping nginx… (might take a while)
 ==> Successfully stopped nginx (label: homebrew.mxcl.nginx)
 ==> Successfully started nginx (label: homebrew.mxcl.nginx)

➜  ~ ps -ef | grep nginx
  501 40713 10608   0  9:54PM ttys000    0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn nginx

But you can start it with the sudo nginx command.

➜  ~ sudo /usr/local/Cellar/nginx/1.15.12/bin/nginx -c /usr/local/etc/nginx/nginx.conf

But you can use the sudo nginx command to start without using sudo to report no permissions.

Therefore, the suspicion is a permission issue.

So, check the nginx startup configuration file separately.

  • Nginx configuration file permissions
  • Nginx error log file permissions
  • Nginx access log permissions
  • Nginx command to execute file permissions

As a result, the nginx configuration file is root and the error log is root. After the chown is modified, the brew can be started normally.

➜  ~ brew services restart nginx
Stopping `nginx`... (might take a while)

==> Successfully stopped `nginx` (label: homebrew.mxcl.nginx)
==> Successfully started `nginx` (label: homebrew.mxcl.nginx)
➜  ~
➜  ~ ps -ef | grep nginx | grep -v grep
  501 42528     1   0 10:13PM ??         0:00.02 nginx: master process /usr/local/opt/nginx/bin/nginx -g daemon off;
  501 42529 42528   0 10:13PM ??         0:00.00 nginx: worker process

Add a Comment

Your email address will not be published. Required fields are marked *