I have an nginx server configured to run the master service as a non-root user and it runs fine when I manually invoke it by running
I've tried to automate startup by writing it into an rc.conf script saved to /etc/rc.conf.d/nginx with the following lines:
but when I run
when I run
If I
Is there a way in the rc.conf file to force ownership of the pid file?
Is there something else I should be changing to make this work?
Thanks in advance for anyone who can shed some light on how the rc scripts work here.
Other details:
I've tried
When I invoke
nginx -c /path/to/nginx.conf
as the user 'nginx' but it doesn't work from my rc.conf script.I've tried to automate startup by writing it into an rc.conf script saved to /etc/rc.conf.d/nginx with the following lines:
Code:
nginx_user="nginx"
nginx_enable="YES"
nginx_flags="-c /path/to/nginx.conf"
but when I run
service nginx start
I get the error nginx: [emerg] open() "/path/to/nginx.pid" failed (13: Permission denied)
when I run
ls -al /path/to/
I can see that the folder is owned by nginx:nginx but the pid file is owned by root:nginx
Code:
drwxr-xr-x 2 nginx nginx 7 Nov 23 22:29 .
drwxr-xr-x 6 nginx nginx 18 Nov 21 22:11 ..
-rw-r--r-- 1 nginx nginx 1534 Nov 23 19:49 nginx.conf
-rw-r--r-- 1 root nginx 0 Nov 23 22:29 nginx.pid
If I
chown nginx:nginx /path/to/nginx.pid
then the next time I run service nginx start
the server starts up correctly, but the pid file is removed at shutdown so on restart it won't start automatically.Is there a way in the rc.conf file to force ownership of the pid file?
Is there something else I should be changing to make this work?
Thanks in advance for anyone who can shed some light on how the rc scripts work here.
Other details:
I've tried
echo nginx_pid_prefix=\"/path/to\" >> /etc/rc.conf.d/nginx
but that doesn't seem to affect anything.When I invoke
nginx -c /path/to/nginx.conf
as ther user 'nginx' the pid is owned by nginx:nginx with permissions set to 644.