title: How to set nginx max open files?
body: <p>Though I have done the following setting, and even restarted the server:</p>
  
  <pre><code># head /etc/security/limits.conf -n2
  www-data soft nofile -1
  www-data hard nofile -1
  # /sbin/sysctl fs.file-max
  fs.file-max = 201558
  </code></pre>
  
  <p>The open files limitation of specific process is still 1024/4096:</p>
  
  <pre><code># ps aux | grep nginx
  root       983  0.0  0.0  85872  1348 ?        Ss   15:42   0:00 nginx: master process /usr/sbin/nginx
  www-data   984  0.0  0.2  89780  6000 ?        S    15:42   0:00 nginx: worker process
  www-data   985  0.0  0.2  89780  5472 ?        S    15:42   0:00 nginx: worker process
  root      1247  0.0  0.0  11744   916 pts/0    S+   15:47   0:00 grep --color=auto nginx
  # cat /proc/984/limits
  Limit                     Soft Limit           Hard Limit           Units
  Max cpu time              unlimited            unlimited            seconds
  Max file size             unlimited            unlimited            bytes
  Max data size             unlimited            unlimited            bytes
  Max stack size            8388608              unlimited            bytes
  Max core file size        0                    unlimited            bytes
  Max resident set          unlimited            unlimited            bytes
  Max processes             15845                15845                processes
  Max open files            1024                 4096                 files
  Max locked memory         65536                65536                bytes
  Max address space         unlimited            unlimited            bytes
  Max file locks            unlimited            unlimited            locks
  Max pending signals       15845                15845                signals
  Max msgqueue size         819200               819200               bytes
  Max nice priority         0                    0
  Max realtime priority     0                    0
  Max realtime timeout      unlimited            unlimited            us
  </code></pre>
  
  <p>I've tried all possible solutions from googling but in vain. What setting did I miss?</p>