nginx.service: Can't open PID file /run/nginx

Multi tool use
I am on Ubuntu 18.10, running under vmware and unable to start the nginx service - I get the error "nginx.service: Can't open PID file /run/nginx".
I have compiled nginx from source using passenger. It went ok on one machine, but trying it in my vm I cannot start the nginx service. It gives the above error as it cannot open the PID file (or create it?). I have done systemctl enable & start and it hangs.
I have used the /etc/sytemd/system/nginx.service script as follows:
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/opt/nginx/sbin/nginx -t
ExecStart=/opt/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
I have tried substituting /var/run for /run and it gives the same error.
There is no reference to the PID in the nginx.conf (and I don't think there needs to be?).
Could anyone give me any pointers on how to troubleshoot or fix this please?
server nginx
add a comment |
I am on Ubuntu 18.10, running under vmware and unable to start the nginx service - I get the error "nginx.service: Can't open PID file /run/nginx".
I have compiled nginx from source using passenger. It went ok on one machine, but trying it in my vm I cannot start the nginx service. It gives the above error as it cannot open the PID file (or create it?). I have done systemctl enable & start and it hangs.
I have used the /etc/sytemd/system/nginx.service script as follows:
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/opt/nginx/sbin/nginx -t
ExecStart=/opt/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
I have tried substituting /var/run for /run and it gives the same error.
There is no reference to the PID in the nginx.conf (and I don't think there needs to be?).
Could anyone give me any pointers on how to troubleshoot or fix this please?
server nginx
add a comment |
I am on Ubuntu 18.10, running under vmware and unable to start the nginx service - I get the error "nginx.service: Can't open PID file /run/nginx".
I have compiled nginx from source using passenger. It went ok on one machine, but trying it in my vm I cannot start the nginx service. It gives the above error as it cannot open the PID file (or create it?). I have done systemctl enable & start and it hangs.
I have used the /etc/sytemd/system/nginx.service script as follows:
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/opt/nginx/sbin/nginx -t
ExecStart=/opt/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
I have tried substituting /var/run for /run and it gives the same error.
There is no reference to the PID in the nginx.conf (and I don't think there needs to be?).
Could anyone give me any pointers on how to troubleshoot or fix this please?
server nginx
I am on Ubuntu 18.10, running under vmware and unable to start the nginx service - I get the error "nginx.service: Can't open PID file /run/nginx".
I have compiled nginx from source using passenger. It went ok on one machine, but trying it in my vm I cannot start the nginx service. It gives the above error as it cannot open the PID file (or create it?). I have done systemctl enable & start and it hangs.
I have used the /etc/sytemd/system/nginx.service script as follows:
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/opt/nginx/sbin/nginx -t
ExecStart=/opt/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
I have tried substituting /var/run for /run and it gives the same error.
There is no reference to the PID in the nginx.conf (and I don't think there needs to be?).
Could anyone give me any pointers on how to troubleshoot or fix this please?
server nginx
server nginx
asked 2 days ago
tentimestentimes
1012
1012
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Is /run available? Can you cd into /run and touch a file?
cd /run && touch hello.txt && ls -lash
If not that probably means that you want nginx to put the PID file in a location that is not available. You can do 2 things;
- Figure out why /run is not available (probably tmpfs configuration)
- Put the PID file somewhere else, for example /tmp
I can do this with sudo, yes, and I see "hello.txt". When try use the PID line "PIDFile=/tmp/nginx.pid" I get the same error: "Can't open PID file /tmp/nginx.pid (yet?) after start: No such file or directory".
– tentimes
2 days ago
Interestingly, in a VPS version of this server I have been creating everything went ok. But going back to that setup I can find no nginx.service file in /etc/systemd/system or /lib/systemd/system. I am able to control the service though using systmctl. So maybe in the VPS server (also Ubuntu 18.10) I got the service working using some different method to my vm that I am currently on? It says .etc.init.d/nginx somewhere in the message for the working version, so is there a way to get this service running with init.d scripts?
– tentimes
2 days ago
add a comment |
I have an answer in the sense of how to fix this, but I will leave it open for a bit so someone may comment on WHY this is so.
I changed the PID line so the PID file was written to the log folder of the installed nginx folder (/opt/nginx/logs). Anwhere else and it would REFUSE to write the PID file!!!
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/opt/nginx/logs/nginx.pid
ExecStartPre=/opt/nginx/sbin/nginx -t
ExecStart=/opt/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
I have no idea what the reason for this behaviour is and it would be great if some Ubuntu Linux expert could tell me why it wouldn't write the PID anywhere else, including the normal run location /run and /var/run (or even tmp) for example, as is normal in all quoted startup scripts for the program. I think this only happens when it is created from source.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1113319%2fnginx-service-cant-open-pid-file-run-nginx%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is /run available? Can you cd into /run and touch a file?
cd /run && touch hello.txt && ls -lash
If not that probably means that you want nginx to put the PID file in a location that is not available. You can do 2 things;
- Figure out why /run is not available (probably tmpfs configuration)
- Put the PID file somewhere else, for example /tmp
I can do this with sudo, yes, and I see "hello.txt". When try use the PID line "PIDFile=/tmp/nginx.pid" I get the same error: "Can't open PID file /tmp/nginx.pid (yet?) after start: No such file or directory".
– tentimes
2 days ago
Interestingly, in a VPS version of this server I have been creating everything went ok. But going back to that setup I can find no nginx.service file in /etc/systemd/system or /lib/systemd/system. I am able to control the service though using systmctl. So maybe in the VPS server (also Ubuntu 18.10) I got the service working using some different method to my vm that I am currently on? It says .etc.init.d/nginx somewhere in the message for the working version, so is there a way to get this service running with init.d scripts?
– tentimes
2 days ago
add a comment |
Is /run available? Can you cd into /run and touch a file?
cd /run && touch hello.txt && ls -lash
If not that probably means that you want nginx to put the PID file in a location that is not available. You can do 2 things;
- Figure out why /run is not available (probably tmpfs configuration)
- Put the PID file somewhere else, for example /tmp
I can do this with sudo, yes, and I see "hello.txt". When try use the PID line "PIDFile=/tmp/nginx.pid" I get the same error: "Can't open PID file /tmp/nginx.pid (yet?) after start: No such file or directory".
– tentimes
2 days ago
Interestingly, in a VPS version of this server I have been creating everything went ok. But going back to that setup I can find no nginx.service file in /etc/systemd/system or /lib/systemd/system. I am able to control the service though using systmctl. So maybe in the VPS server (also Ubuntu 18.10) I got the service working using some different method to my vm that I am currently on? It says .etc.init.d/nginx somewhere in the message for the working version, so is there a way to get this service running with init.d scripts?
– tentimes
2 days ago
add a comment |
Is /run available? Can you cd into /run and touch a file?
cd /run && touch hello.txt && ls -lash
If not that probably means that you want nginx to put the PID file in a location that is not available. You can do 2 things;
- Figure out why /run is not available (probably tmpfs configuration)
- Put the PID file somewhere else, for example /tmp
Is /run available? Can you cd into /run and touch a file?
cd /run && touch hello.txt && ls -lash
If not that probably means that you want nginx to put the PID file in a location that is not available. You can do 2 things;
- Figure out why /run is not available (probably tmpfs configuration)
- Put the PID file somewhere else, for example /tmp
answered 2 days ago


Aike de JongsteAike de Jongste
111
111
I can do this with sudo, yes, and I see "hello.txt". When try use the PID line "PIDFile=/tmp/nginx.pid" I get the same error: "Can't open PID file /tmp/nginx.pid (yet?) after start: No such file or directory".
– tentimes
2 days ago
Interestingly, in a VPS version of this server I have been creating everything went ok. But going back to that setup I can find no nginx.service file in /etc/systemd/system or /lib/systemd/system. I am able to control the service though using systmctl. So maybe in the VPS server (also Ubuntu 18.10) I got the service working using some different method to my vm that I am currently on? It says .etc.init.d/nginx somewhere in the message for the working version, so is there a way to get this service running with init.d scripts?
– tentimes
2 days ago
add a comment |
I can do this with sudo, yes, and I see "hello.txt". When try use the PID line "PIDFile=/tmp/nginx.pid" I get the same error: "Can't open PID file /tmp/nginx.pid (yet?) after start: No such file or directory".
– tentimes
2 days ago
Interestingly, in a VPS version of this server I have been creating everything went ok. But going back to that setup I can find no nginx.service file in /etc/systemd/system or /lib/systemd/system. I am able to control the service though using systmctl. So maybe in the VPS server (also Ubuntu 18.10) I got the service working using some different method to my vm that I am currently on? It says .etc.init.d/nginx somewhere in the message for the working version, so is there a way to get this service running with init.d scripts?
– tentimes
2 days ago
I can do this with sudo, yes, and I see "hello.txt". When try use the PID line "PIDFile=/tmp/nginx.pid" I get the same error: "Can't open PID file /tmp/nginx.pid (yet?) after start: No such file or directory".
– tentimes
2 days ago
I can do this with sudo, yes, and I see "hello.txt". When try use the PID line "PIDFile=/tmp/nginx.pid" I get the same error: "Can't open PID file /tmp/nginx.pid (yet?) after start: No such file or directory".
– tentimes
2 days ago
Interestingly, in a VPS version of this server I have been creating everything went ok. But going back to that setup I can find no nginx.service file in /etc/systemd/system or /lib/systemd/system. I am able to control the service though using systmctl. So maybe in the VPS server (also Ubuntu 18.10) I got the service working using some different method to my vm that I am currently on? It says .etc.init.d/nginx somewhere in the message for the working version, so is there a way to get this service running with init.d scripts?
– tentimes
2 days ago
Interestingly, in a VPS version of this server I have been creating everything went ok. But going back to that setup I can find no nginx.service file in /etc/systemd/system or /lib/systemd/system. I am able to control the service though using systmctl. So maybe in the VPS server (also Ubuntu 18.10) I got the service working using some different method to my vm that I am currently on? It says .etc.init.d/nginx somewhere in the message for the working version, so is there a way to get this service running with init.d scripts?
– tentimes
2 days ago
add a comment |
I have an answer in the sense of how to fix this, but I will leave it open for a bit so someone may comment on WHY this is so.
I changed the PID line so the PID file was written to the log folder of the installed nginx folder (/opt/nginx/logs). Anwhere else and it would REFUSE to write the PID file!!!
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/opt/nginx/logs/nginx.pid
ExecStartPre=/opt/nginx/sbin/nginx -t
ExecStart=/opt/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
I have no idea what the reason for this behaviour is and it would be great if some Ubuntu Linux expert could tell me why it wouldn't write the PID anywhere else, including the normal run location /run and /var/run (or even tmp) for example, as is normal in all quoted startup scripts for the program. I think this only happens when it is created from source.
add a comment |
I have an answer in the sense of how to fix this, but I will leave it open for a bit so someone may comment on WHY this is so.
I changed the PID line so the PID file was written to the log folder of the installed nginx folder (/opt/nginx/logs). Anwhere else and it would REFUSE to write the PID file!!!
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/opt/nginx/logs/nginx.pid
ExecStartPre=/opt/nginx/sbin/nginx -t
ExecStart=/opt/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
I have no idea what the reason for this behaviour is and it would be great if some Ubuntu Linux expert could tell me why it wouldn't write the PID anywhere else, including the normal run location /run and /var/run (or even tmp) for example, as is normal in all quoted startup scripts for the program. I think this only happens when it is created from source.
add a comment |
I have an answer in the sense of how to fix this, but I will leave it open for a bit so someone may comment on WHY this is so.
I changed the PID line so the PID file was written to the log folder of the installed nginx folder (/opt/nginx/logs). Anwhere else and it would REFUSE to write the PID file!!!
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/opt/nginx/logs/nginx.pid
ExecStartPre=/opt/nginx/sbin/nginx -t
ExecStart=/opt/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
I have no idea what the reason for this behaviour is and it would be great if some Ubuntu Linux expert could tell me why it wouldn't write the PID anywhere else, including the normal run location /run and /var/run (or even tmp) for example, as is normal in all quoted startup scripts for the program. I think this only happens when it is created from source.
I have an answer in the sense of how to fix this, but I will leave it open for a bit so someone may comment on WHY this is so.
I changed the PID line so the PID file was written to the log folder of the installed nginx folder (/opt/nginx/logs). Anwhere else and it would REFUSE to write the PID file!!!
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/opt/nginx/logs/nginx.pid
ExecStartPre=/opt/nginx/sbin/nginx -t
ExecStart=/opt/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
I have no idea what the reason for this behaviour is and it would be great if some Ubuntu Linux expert could tell me why it wouldn't write the PID anywhere else, including the normal run location /run and /var/run (or even tmp) for example, as is normal in all quoted startup scripts for the program. I think this only happens when it is created from source.
answered yesterday
tentimestentimes
1012
1012
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1113319%2fnginx-service-cant-open-pid-file-run-nginx%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Jl7FmGEmj7xClswqpn GWhyjGaDkrHgB4W8zK2JJ1E I56AA4JAa KQ,V WS1c7y2