Hosting: new droplet on Digital Ocean

Operating system: fresh install of CentOS 7.6.1810

Background: testing Nginx on Centos in 100 different ways before it is used in production.

Question: My installation of Nginx from source appears to work but the service isn't found by the OS. Where should I start testing to find the root of the problem? I can get around Linux fine but I'm far from an expert.

Backstory: Installing Nginx with the package manager works fine. The install goes smooth and the service starts perfectly.

sudo yum install -y nginx

sudo systemctl start nginx

However when I build from source Nginx doesn't want to start.

The install appears to go fine without problems.

curl nginx.org/download/nginx-1.16.0.tar.gz > nginx-1.16.0.tar.gz

tar -zxvf nginx-1.16.0.tar.gz

cd nginx-1.16.0

sudo ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-file-aio --with-threads --with-http_ssl_module --with-http_v2_module

sudo make

sudo make install

However when I try to start nginx I get an error.

sudo systemctl start nginx

Failed to start nginx.service: Unit not found.

I checked /etc/nginx and nginx.conf was created properly. It's almost as if nginx installed but somehow it didn't check in with the OS. I'm not an expert on Centos or Linux and I'm not sure what things I should check off to determine the root of the problem.

  • Not exactly an answer to this question, but still might be helpful to someone like me: if you successfully install nginx from a package but the systemctl status command results in a "unit could not be found" error, make sure you didn't misspell "nginx" as "ngnix" or something similar. It's quite easy to make a typo and quite difficult to notice it. Nov 14, 2021 at 13:06

2 Answers 2


The nginx source tarball doesn't include a systemd unit. If you insist on running a copy built by yourself from source then you will need to provide the systemd unit file yourself. You can find one in the RPM package.

BTW your explanation of why you aren't doing this doesn't make much sense; almost everyone actually needs most of the modules you have stripped out, so it is usually a waste of time to even make the attempt. Many of the truly optional modules are already loadable modules which you can simply change nginx's configuration to not load.

  • You are 100% correct. I just installed from source and checked /lib/systemd/system and sure enough nginx.service didn't exist. Neither the course on Udemy nor the official instructions on docs.nginx mentioned the need to make my own nginx.service file. The course said that installing from source was the preferred method but now I'm seriously questioning that logic. Jun 27, 2019 at 20:48
  • An online course recommended installing nginx from source?!? I hope you didn't waste too much money on it. Using packages is the recommended method for virtually everyone. Jun 27, 2019 at 20:49
  • It cost $10 and I guess I got my money's worth. Haha! Jun 27, 2019 at 20:50

My suggestion is instead of building it from source, you can follow their installation on RHEL/CentOS on their site http://nginx.org/en/linux_packages.html#RHEL-CentOS

Can you also provide some logs so we can figure out your issue?

  • Hi Joenel, installing from the package works perfect without error. The instructions on your link work great. However I'm trying to build from source to eliminate modules that I don't need. Which error logs should I check? Jun 27, 2019 at 16:38

You must log in to answer this question.

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