Failed to start nginx.service: Unit not found

I installed the latest version of nginx and configured some directories:

./configure --sbin-path=/usr/bin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-pcre --pid-path=/var/run/nginx.pid --with-http_ssl_module 

It all works completely fine. After that I created a custom file:

nano /lib/systemd/system/nginx.service 

The content of the 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=/var/run/nginx.pid ExecStartPre=/usr/bin/nginx -t ExecStart=/usr/bin/nginx ExecReload=/usr/sbin/nginx -s reload ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target 

But then when running "systemctl start nginx" I get the error "unit not found":

enter image description here

I can't understnad why or what's the problem. Running "nginx -V" shows the directories are set.

Does anyone have a clue? Thanks in advance

2

1 Answer

Try the following and let's see what happens.

 sudo yum install epel-release sudo yum install nginx sudo systemctl -l enable nginx sudo systemctl -l start nginx 

It did not work for me initially because epel-release was not installed. But this is assuming you're using Fedora/ CentOs

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like