nginx doesn't come up when run via SystemD
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I installed mainline nginx 1.13.9 using the provided rpm on CentOS 7.4. I had to use this rpm because I am forced to do yum localinstall
due to company governance.
My problem is that systemctl start nginx
always yields this:
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
journalctl tells me:
Mar 07 08:57:05 myhost nginx[19466]: nginx: [emerg] open() "/var/opt/nginx/config/nginx.conf" failed (13: Permission denied)
(What you see here is another company thing: I mustn't put the conf files under etc, I have to keep them in a directory where I don't need root permissions to change them)
These are the permissions set for the nginx.conf:
-rw-r--r--. 1 nginx nginx 241 Mar 7 09:17 nginx.conf
I reduced the nginx.conf to an (I guess) absolute minimum and even tried to put log files, pid and alike to directories where permissions are granted for sure. The error log contains absolutely nothing.
This is my reduced nginx.conf:
user nginx nginx;
pid /tmp/nginx.pid;
error_log /tmp/error.log debug;
events
http
default_type application/octet-stream;
charset UTF-8;
server
listen 8080;
location /
root /tmp/;
And this is my slightly modified nginx.service
definition:
[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 /var/opt/nginx/config/nginx.conf -g "error_log /tmp/error.log debug;"
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
[Install]
WantedBy=multi-user.target
(You can see that I tried to force an error_log just in case nginx fails before the nginx.conf is read)
When I do sudo -u nginx /usr/sbin/nginx -c /var/opt/nginx/config/nginx.conf -g "error_log /tmp/error.log debug;"
this works just fine. Despite of a short warning the process starts up fine:
nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /var/opt/nginx/config/nginx.conf:1
I am sure it must be some stupid mistake, but I have no clue which.
centos nginx
add a comment |Â
up vote
1
down vote
favorite
I installed mainline nginx 1.13.9 using the provided rpm on CentOS 7.4. I had to use this rpm because I am forced to do yum localinstall
due to company governance.
My problem is that systemctl start nginx
always yields this:
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
journalctl tells me:
Mar 07 08:57:05 myhost nginx[19466]: nginx: [emerg] open() "/var/opt/nginx/config/nginx.conf" failed (13: Permission denied)
(What you see here is another company thing: I mustn't put the conf files under etc, I have to keep them in a directory where I don't need root permissions to change them)
These are the permissions set for the nginx.conf:
-rw-r--r--. 1 nginx nginx 241 Mar 7 09:17 nginx.conf
I reduced the nginx.conf to an (I guess) absolute minimum and even tried to put log files, pid and alike to directories where permissions are granted for sure. The error log contains absolutely nothing.
This is my reduced nginx.conf:
user nginx nginx;
pid /tmp/nginx.pid;
error_log /tmp/error.log debug;
events
http
default_type application/octet-stream;
charset UTF-8;
server
listen 8080;
location /
root /tmp/;
And this is my slightly modified nginx.service
definition:
[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 /var/opt/nginx/config/nginx.conf -g "error_log /tmp/error.log debug;"
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
[Install]
WantedBy=multi-user.target
(You can see that I tried to force an error_log just in case nginx fails before the nginx.conf is read)
When I do sudo -u nginx /usr/sbin/nginx -c /var/opt/nginx/config/nginx.conf -g "error_log /tmp/error.log debug;"
this works just fine. Despite of a short warning the process starts up fine:
nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /var/opt/nginx/config/nginx.conf:1
I am sure it must be some stupid mistake, but I have no clue which.
centos nginx
Stupid suggestion, but check in that all path of /var/opt/nginx/config/ is accessible to user 'nginx'. Maybe one directory in chain doesn't have enough permissions for user 'nginx'.
â Yurij Goncharuk
Mar 7 at 8:49
@YurijGoncharuk: Thanks for the suggestion. I checked this andothers
has at leastr
(var and opt) and further down the chain evenw
â Marged
Mar 7 at 9:53
Sometimes, in situations like this I login as necessary user ('nginx' in this situation) and trying to do something like read/write some files. Offcause, it's need to add possibility to login for that user (cmdline interpret is disabled by default) in /etc/passwd. It's dirty way, but sometimes is helpful for me.
â Yurij Goncharuk
Mar 7 at 10:49
@YurijGoncharuk Thanks for that suggestion, I already removednologin
from the user and triedsu nginx
(which has limitations) andsudo -u nginx ...
(see above). There everything works, but not when run by SystemD
â Marged
Mar 7 at 11:26
1
I think about it. If you have been solved problerm, please don't forget to post solution.
â Yurij Goncharuk
Mar 7 at 11:30
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I installed mainline nginx 1.13.9 using the provided rpm on CentOS 7.4. I had to use this rpm because I am forced to do yum localinstall
due to company governance.
My problem is that systemctl start nginx
always yields this:
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
journalctl tells me:
Mar 07 08:57:05 myhost nginx[19466]: nginx: [emerg] open() "/var/opt/nginx/config/nginx.conf" failed (13: Permission denied)
(What you see here is another company thing: I mustn't put the conf files under etc, I have to keep them in a directory where I don't need root permissions to change them)
These are the permissions set for the nginx.conf:
-rw-r--r--. 1 nginx nginx 241 Mar 7 09:17 nginx.conf
I reduced the nginx.conf to an (I guess) absolute minimum and even tried to put log files, pid and alike to directories where permissions are granted for sure. The error log contains absolutely nothing.
This is my reduced nginx.conf:
user nginx nginx;
pid /tmp/nginx.pid;
error_log /tmp/error.log debug;
events
http
default_type application/octet-stream;
charset UTF-8;
server
listen 8080;
location /
root /tmp/;
And this is my slightly modified nginx.service
definition:
[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 /var/opt/nginx/config/nginx.conf -g "error_log /tmp/error.log debug;"
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
[Install]
WantedBy=multi-user.target
(You can see that I tried to force an error_log just in case nginx fails before the nginx.conf is read)
When I do sudo -u nginx /usr/sbin/nginx -c /var/opt/nginx/config/nginx.conf -g "error_log /tmp/error.log debug;"
this works just fine. Despite of a short warning the process starts up fine:
nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /var/opt/nginx/config/nginx.conf:1
I am sure it must be some stupid mistake, but I have no clue which.
centos nginx
I installed mainline nginx 1.13.9 using the provided rpm on CentOS 7.4. I had to use this rpm because I am forced to do yum localinstall
due to company governance.
My problem is that systemctl start nginx
always yields this:
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
journalctl tells me:
Mar 07 08:57:05 myhost nginx[19466]: nginx: [emerg] open() "/var/opt/nginx/config/nginx.conf" failed (13: Permission denied)
(What you see here is another company thing: I mustn't put the conf files under etc, I have to keep them in a directory where I don't need root permissions to change them)
These are the permissions set for the nginx.conf:
-rw-r--r--. 1 nginx nginx 241 Mar 7 09:17 nginx.conf
I reduced the nginx.conf to an (I guess) absolute minimum and even tried to put log files, pid and alike to directories where permissions are granted for sure. The error log contains absolutely nothing.
This is my reduced nginx.conf:
user nginx nginx;
pid /tmp/nginx.pid;
error_log /tmp/error.log debug;
events
http
default_type application/octet-stream;
charset UTF-8;
server
listen 8080;
location /
root /tmp/;
And this is my slightly modified nginx.service
definition:
[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 /var/opt/nginx/config/nginx.conf -g "error_log /tmp/error.log debug;"
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
[Install]
WantedBy=multi-user.target
(You can see that I tried to force an error_log just in case nginx fails before the nginx.conf is read)
When I do sudo -u nginx /usr/sbin/nginx -c /var/opt/nginx/config/nginx.conf -g "error_log /tmp/error.log debug;"
this works just fine. Despite of a short warning the process starts up fine:
nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /var/opt/nginx/config/nginx.conf:1
I am sure it must be some stupid mistake, but I have no clue which.
centos nginx
asked Mar 7 at 8:29
Marged
17118
17118
Stupid suggestion, but check in that all path of /var/opt/nginx/config/ is accessible to user 'nginx'. Maybe one directory in chain doesn't have enough permissions for user 'nginx'.
â Yurij Goncharuk
Mar 7 at 8:49
@YurijGoncharuk: Thanks for the suggestion. I checked this andothers
has at leastr
(var and opt) and further down the chain evenw
â Marged
Mar 7 at 9:53
Sometimes, in situations like this I login as necessary user ('nginx' in this situation) and trying to do something like read/write some files. Offcause, it's need to add possibility to login for that user (cmdline interpret is disabled by default) in /etc/passwd. It's dirty way, but sometimes is helpful for me.
â Yurij Goncharuk
Mar 7 at 10:49
@YurijGoncharuk Thanks for that suggestion, I already removednologin
from the user and triedsu nginx
(which has limitations) andsudo -u nginx ...
(see above). There everything works, but not when run by SystemD
â Marged
Mar 7 at 11:26
1
I think about it. If you have been solved problerm, please don't forget to post solution.
â Yurij Goncharuk
Mar 7 at 11:30
add a comment |Â
Stupid suggestion, but check in that all path of /var/opt/nginx/config/ is accessible to user 'nginx'. Maybe one directory in chain doesn't have enough permissions for user 'nginx'.
â Yurij Goncharuk
Mar 7 at 8:49
@YurijGoncharuk: Thanks for the suggestion. I checked this andothers
has at leastr
(var and opt) and further down the chain evenw
â Marged
Mar 7 at 9:53
Sometimes, in situations like this I login as necessary user ('nginx' in this situation) and trying to do something like read/write some files. Offcause, it's need to add possibility to login for that user (cmdline interpret is disabled by default) in /etc/passwd. It's dirty way, but sometimes is helpful for me.
â Yurij Goncharuk
Mar 7 at 10:49
@YurijGoncharuk Thanks for that suggestion, I already removednologin
from the user and triedsu nginx
(which has limitations) andsudo -u nginx ...
(see above). There everything works, but not when run by SystemD
â Marged
Mar 7 at 11:26
1
I think about it. If you have been solved problerm, please don't forget to post solution.
â Yurij Goncharuk
Mar 7 at 11:30
Stupid suggestion, but check in that all path of /var/opt/nginx/config/ is accessible to user 'nginx'. Maybe one directory in chain doesn't have enough permissions for user 'nginx'.
â Yurij Goncharuk
Mar 7 at 8:49
Stupid suggestion, but check in that all path of /var/opt/nginx/config/ is accessible to user 'nginx'. Maybe one directory in chain doesn't have enough permissions for user 'nginx'.
â Yurij Goncharuk
Mar 7 at 8:49
@YurijGoncharuk: Thanks for the suggestion. I checked this and
others
has at least r
(var and opt) and further down the chain even w
â Marged
Mar 7 at 9:53
@YurijGoncharuk: Thanks for the suggestion. I checked this and
others
has at least r
(var and opt) and further down the chain even w
â Marged
Mar 7 at 9:53
Sometimes, in situations like this I login as necessary user ('nginx' in this situation) and trying to do something like read/write some files. Offcause, it's need to add possibility to login for that user (cmdline interpret is disabled by default) in /etc/passwd. It's dirty way, but sometimes is helpful for me.
â Yurij Goncharuk
Mar 7 at 10:49
Sometimes, in situations like this I login as necessary user ('nginx' in this situation) and trying to do something like read/write some files. Offcause, it's need to add possibility to login for that user (cmdline interpret is disabled by default) in /etc/passwd. It's dirty way, but sometimes is helpful for me.
â Yurij Goncharuk
Mar 7 at 10:49
@YurijGoncharuk Thanks for that suggestion, I already removed
nologin
from the user and tried su nginx
(which has limitations) and sudo -u nginx ...
(see above). There everything works, but not when run by SystemDâ Marged
Mar 7 at 11:26
@YurijGoncharuk Thanks for that suggestion, I already removed
nologin
from the user and tried su nginx
(which has limitations) and sudo -u nginx ...
(see above). There everything works, but not when run by SystemDâ Marged
Mar 7 at 11:26
1
1
I think about it. If you have been solved problerm, please don't forget to post solution.
â Yurij Goncharuk
Mar 7 at 11:30
I think about it. If you have been solved problerm, please don't forget to post solution.
â Yurij Goncharuk
Mar 7 at 11:30
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
This problem was caused by two mistakes I made:
- incorrect directory permissions
- a missing group membership
One of the directories was missing the x
, so the process couldn't traverse the path. I had to chmod g+X
it.
In addition to that I had to add the technical user of nginx (which in my scenario is not the default nginx) to the nginx group.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
This problem was caused by two mistakes I made:
- incorrect directory permissions
- a missing group membership
One of the directories was missing the x
, so the process couldn't traverse the path. I had to chmod g+X
it.
In addition to that I had to add the technical user of nginx (which in my scenario is not the default nginx) to the nginx group.
add a comment |Â
up vote
0
down vote
This problem was caused by two mistakes I made:
- incorrect directory permissions
- a missing group membership
One of the directories was missing the x
, so the process couldn't traverse the path. I had to chmod g+X
it.
In addition to that I had to add the technical user of nginx (which in my scenario is not the default nginx) to the nginx group.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
This problem was caused by two mistakes I made:
- incorrect directory permissions
- a missing group membership
One of the directories was missing the x
, so the process couldn't traverse the path. I had to chmod g+X
it.
In addition to that I had to add the technical user of nginx (which in my scenario is not the default nginx) to the nginx group.
This problem was caused by two mistakes I made:
- incorrect directory permissions
- a missing group membership
One of the directories was missing the x
, so the process couldn't traverse the path. I had to chmod g+X
it.
In addition to that I had to add the technical user of nginx (which in my scenario is not the default nginx) to the nginx group.
answered Aug 8 at 5:04
Marged
17118
17118
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f428689%2fnginx-doesnt-come-up-when-run-via-systemd%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Stupid suggestion, but check in that all path of /var/opt/nginx/config/ is accessible to user 'nginx'. Maybe one directory in chain doesn't have enough permissions for user 'nginx'.
â Yurij Goncharuk
Mar 7 at 8:49
@YurijGoncharuk: Thanks for the suggestion. I checked this and
others
has at leastr
(var and opt) and further down the chain evenw
â Marged
Mar 7 at 9:53
Sometimes, in situations like this I login as necessary user ('nginx' in this situation) and trying to do something like read/write some files. Offcause, it's need to add possibility to login for that user (cmdline interpret is disabled by default) in /etc/passwd. It's dirty way, but sometimes is helpful for me.
â Yurij Goncharuk
Mar 7 at 10:49
@YurijGoncharuk Thanks for that suggestion, I already removed
nologin
from the user and triedsu nginx
(which has limitations) andsudo -u nginx ...
(see above). There everything works, but not when run by SystemDâ Marged
Mar 7 at 11:26
1
I think about it. If you have been solved problerm, please don't forget to post solution.
â Yurij Goncharuk
Mar 7 at 11:30