Not a dupe: This is not a duplicate of this question. I've already looked into that question. That helps with raising the limit for worker processes
, but the nginx master process
continues to retain 1024
and 4096
respectively. This latter nuance is what this question is really about.
The problem:
I'm increasing file descriptor limit for nginx in systemd
as follows:
1) Create limit.conf
in /etc/systemd/system/nginx.service.d/
2) Save the following lines in this file
[Service]
LimitNOFILE=100000
3) Restart nginx via sudo service nginx restart
Now when I do cat /proc/$(ps aux | grep "nginx: master process" | grep -v grep | awk '{print $2}')/limits | grep "Max open files"
I can see this limit set up correctly.
However there is a catch!
If I reboot the system and then re-enter it, the default for nginx's master process
is back to 1024
and 4096
(I run the aforementioned cat
command to find out).
But if I issue sudo service nginx start
, the limit increases again as desired.
How do I ensure this setting is not lost on reboots? Would appreciate an illustrative example. I don't want to manually have to issue sudo service nginx restart
each time.
p.s. I've made complementary changes in /etc/security/limits.conf
and /etc/pam.d/common-session
as well. Ask me for more information in case you need it.
Moreover, /etc/systemd/system/multi-user.target.wants/nginx.service
contains:
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
[Install]
WantedBy=multi-user.target
But it's 14.04
, so that wouldn't have worked any way. What's the best way to accomplish this on Ubuntu 14.04? Would love an illustrative example that actually works.