I have Ubuntu 16.04 LTS and I used this guide to build Nginx with this LDAP module.

I believe my trouble is that guide uses an older /etc/init.d script that doesn't work so well with 16.04. I then tried this newer script for systemd which sort of works but I'm getting some weird service behavior.

Currently I can "systemctl start nginx" and the service starts (the web server works) but I have to ctrl-c to get my command back. "systemctl status nginx" will show this below. "systemctl stop nginx" does not stop the nginx web server. In order to stop nginx I have to "systemctl kill nginx". I did find that /usr/local/nginx/logs/nginx.pid file missing but creating it myself didn't fix that error.

From here I'm kind of lost, how do I fix this?

    ● nginx.service - LSB: nginx init.d dash script for Ubuntu or other *nix.
   Loaded: loaded (/etc/init.d/nginx; bad; vendor preset: enabled)
   Active: activating (start) since Thu 2018-04-05 15:44:43 EDT; 48s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 28806 ExecStart=/etc/init.d/nginx start (code=exited, status=0/SUCCESS)
    Tasks: 2
   Memory: 9.2M
      CPU: 29ms
   CGroup: /system.slice/nginx.service
           ├─28815 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.con
           └─28816 nginx: worker process                   

Apr 05 15:44:43 ubuntu systemd[1]: Starting LSB: nginx init.d dash script for Ubuntu or other *nix....
Apr 05 15:44:43 ubuntu nginx[28806]:  * Starting Nginx Server...
Apr 05 15:44:43 ubuntu nginx[28806]:    ...done.
Apr 05 15:44:43 ubuntu systemd[1]: nginx.service: PID file /usr/local/nginx/logs/nginx.pid not readable (yet?) after start: No such file or directory

1 Answer 1


According to your posted output, you are not using a systemd service unit but still using the init.d script.

Possibly you did not add the service unit correctly and reload systemd, or your old init.d script is interfering, or you are doing something in your service unit that you are not showing. That should not be the behavior of the systemd file you posted.

If the contents of your posted systemd service unit are indeed in the correct place (/etc/systemd/system/nginx.service), and you have issued the systemctl daemon-reload command to load the new service unit, then try moving your nginx init.d file (/etc/init.d/nginx) out of the way or remove it if you do not need it anymore.

The key here is the line at the top of the status output, "Loaded" which indicates the script being used. You want to make sure the output tells you it is using systemd. Looking at that nginx service unit you posted, it should behave properly as long as you set the PIDFile to the proper location.

  • The correct place to install nginx.service is actually /etc/systemd/system/nginx.service. Service units in the /lib/systemd tree are "static" units, units which have an "[Install]" section are meant to be installed under /etc/systemd instead.
    – filbranden
    Commented Apr 6, 2018 at 5:18
  • @FilipeBrandenburger, according to man file-hierarchy, /lib/systemd is for vendor-supplied files and /etc/systemd is for "System-specific configuration."-- Usually files maintained by humans. In other words, consider /lib to be read-only and /etc to be read-write. The man file-hierarchy docs are part of the systemd distribution. Commented Apr 6, 2018 at 14:01
  • @MarkStosberg Yes, I guess I'm mistaken about making them "static" units... Still, vendor-supplied files would be included in RPM/DEB packages, which is not the case here... /etc is more appropriate here.
    – filbranden
    Commented Apr 6, 2018 at 18:09
  • My bad, I was just stating the path that was in the documentation linked in the original question. I can edit my answer to /etc Commented Apr 6, 2018 at 20:41

You must log in to answer this question.

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