Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 636
sir-haver Avatar asked Jun 10 '19 14:06

sir-haver


1 Answers

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

like image 139
anabeto93 Avatar answered Oct 23 '22 13:10

anabeto93