How to set nginx max open files?

前端 未结 3 2074
悲&欢浪女
悲&欢浪女 2021-01-30 11:19

Though I have done the following setting, and even restarted the server:

# head /etc/security/limits.conf -n2
www-data soft nofile -1
www-data hard nofile -1
# /         


        
3条回答
  •  借酒劲吻你
    2021-01-30 12:10

    On CentOS (tested on 7.x):

    Create file /etc/systemd/system/nginx.service.d/override.conf with the following contents:

    [Service]
    LimitNOFILE=65536
    

    Reload systemd daemon with:

    systemctl daemon-reload
    

    Add this to Nginx config file:

    worker_rlimit_nofile 16384; (has to be smaller or equal to LimitNOFILE set above)
    

    And finally restart Nginx:

    systemctl restart nginx
    

    You can verify that it works with cat /proc//limits.

提交回复
热议问题