0

I am trying to restart nginx with the command systemctl restart nginx but I am unable to do this.

Error

Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.constantly getting an error for this.

Then I typed in systemctl status nginx.service and I got this

    systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2018-02-11 22:19:23 UTC; 12s ago
  Process: 25401 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
  Process: 18943 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
  Process: 27943 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
 Main PID: 18947 (code=exited, status=0/SUCCESS)

Can you please tell what's going on as I am trying to setup SSL on nginx from Namecheap when all this happened. For which I already have a question here.

Updated: I used the command nginx -t which came out with the message below.

nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2018/02/12 05:46:36 [warn] 29804#29804: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
2018/02/12 05:46:36 [emerg] 29804#29804: open() "/etc/nginx/sites-enabled/nano.save" failed (13: Permission denied) in /etc/nginx/nginx.conf:62
nginx: configuration file /etc/nginx/nginx.conf test failed
1
  • Run nginx -t with root privileges (sudo); read the nginx log file (add it to your question if you can't find the problem yourself). Feb 12, 2018 at 7:03

1 Answer 1

2

Take a look at your log files to be sure, but my guess would be that nginx tries to load this nano backup file:

/etc/nginx/sites-enabled/nano.save

Most probably it contains some incomplete directives, resulting in syntax errors.

From what I could read in man nano this file is generated when nano is closed abnormally:

In some cases nano will try to dump the buffer into an emergency file. This will happen mainly if nano receives a SIGHUP or SIGTERM or runs out of memory. It will write the buffer into a file named nano.save if the buffer didn't have a name already, or will add a ".save" suffix to the current filename.

Remove this file and you should be good.

To prevent this in the future don't edit files in /etc/nginx/sites-enabled/, edit them in /etc/nginx/sites-available/. /etc/nginx/sites-enabled/ should only contain symlinks to files in /etc/nginx/sites-available/.

1
  • Thanks a lot for your answer. I'll definitely keep in mind to not edit sites-enabled after this and all the edits will be made on sites-available only. Feb 18, 2018 at 7:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .