Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx on macOS : open files resource limit

Tags:

macos

nginx

I'm having configuration errors and I have researched online but I'm not quite sure what the problem is. I'm wanting to install PHP and Nginx on a os x 10.7.5 operating system. Whenever i try to start or stop the server I get the following errors:

tone$ nginx
nginx: [warn] 1024 worker_connections exceed open file resource limit: 256
alcfwl128:~ tolbert$ nginx: [emerg] open() "/usr/local/Cellar/nginx/1.4.3/logs/nginx.pid" failed (2: No such file or directory)

nginx -s stop
nginx: [error] open() "/usr/local/Cellar/nginx/1.4.3/logs/nginx.pid" failed (2: No such file or directory)

For the first error I have tried the following command: tone$ ulimit -n 65536

But I get this error: -bash: ulimit: open files: cannot modify limit: Invalid argument I'm not sure if I'm to create the logs folder in the directory along with the nginx.pid file or if it is located somewhere else. Your help is appreciated.

like image 665
Tone Avatar asked Oct 25 '13 18:10

Tone


1 Answers

Try this in your terminal:

ulimit -a

And the result should be sth similar to this:

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 256
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 709
virtual memory          (kbytes, -v) unlimited

In your case, to increase the open files limit to 1024, use this code:

ulimit -n 1024

Check by running sudo nginx -t and let's hope you don't see the error again

like image 164
wicked Avatar answered Sep 18 '22 04:09

wicked