Reputation: 6755
I have OSX El Capitan. I installed Nginx-Full via homebrew. I am supposed to be able to start and stop services with
brew services Nginx-Full Start
I run that command and it seems to start no problem. I check the running services with
brew services list
That indicates that the Nginx-Full services is running. When i run
htop
to look at everything that is running Nginx does not show up and the server is not handling requests.
Upvotes: 17
Views: 34795
Reputation: 1
If it not starting with brew services start nginx
it means you need to use some administrative user right on your terminal.
So use sudo brew services start nginx
, then enter the password. to get service running
Upvotes: 0
Reputation: 369
this works for me:
start nginx:
sudo nginx
stop nginx:
sudo nginx -s stop
Upvotes: 1
Reputation: 1141
Running sudo nginx
worked for me, it initially gave some error stating certain file in certain directory is missing, creating that file, and then another file is asked for to be created and then it runs properly.
I had similar problem, running it brew services start nginx
used to show nginx running.
but brew services list
used to show error.
running with sudo nginx
solved my issue
Upvotes: 1
Reputation: 8688
Running it with sudo
, as other users have suggested, is just masking the problem. If you just run nginx
directly, you may see that there is actually a configuration or permissions issue that is causing nginx to abort. In my case, it was because it couldn't write to the error log:
nginx: [alert] could not open error log file: open() "/usr/local/var/log/nginx/error.log" failed (13: Permission denied)
2020/04/02 13:11:53 [warn] 19989#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /usr/local/etc/nginx/nginx.conf:2
2020/04/02 13:11:53 [emerg] 19989#0: open() "/usr/local/var/log/nginx/error.log" failed (13: Permission denied)
The last error is causing nginx to fail to launch. You can make yourself the owner of the logs with:
sudo chown -R $(whoami) /usr/local/var/log/nginx/
This should cause subsequent config errors to be written to the error log, even if homebrew services is not reporting them in stderr/stdout for now.
I've opened an issue about this: https://github.com/Homebrew/homebrew-services/issues/215
The log path may not the same for everyone. You can check the path to log file by checking the config file /usr/local/etc/nginx/nginx.conf
. You can find a line like:
error_log /Users/myusername/somepath/nginx.log;
. Change the chown command above accordingly. If even this didn't solve the problem, you may have to do the same for any other log files specified in the server
blocks in your nginx configuration
Upvotes: 28
Reputation: 87
Try launching it with "sudo", even if the formula say
The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that nginx can run without sudo.
sudo brew services Nginx-Full start
Upvotes: 6