Passenger with NginX is not registered as a service in Fedora

I am running Fedora 16 32bit and I installed the passenger with nginx (option 1 during installation, everything was handled for me). Installation went fine, but nginx is not registered as a service.

The only way I can run it is directly through /opt/nginx/sbin/nginx . There is no way to run it through /etc/init.d/nginx

Is there a way to register it as a service?

+6
source share
2 answers

Create the file /etc/systemd/system/nginx.service with the contents:

 [Unit] Description=Nginx After=syslog.target network.target [Service] Type=forking ExecStart=/usr/local/nginx/sbin/nginx ExecReload=/usr/local/nginx/sbin/nginx -s reload [Install] WantedBy=multi-user.target 

After that, you can control it with

 sudo systemctl stop|start|restart nginx.service 

or

 sudo service nginx stop|start|restart 

To start nginx at boot, you can run sudo systemctl enable nginx.service .

+5
source

I made the following hack. A recently installed compiled nginx with Passenger support installed, checked that it works correctly when launched from the command line, and then installed nginx with sudo yum install nginx (this is CentOS).

And finally, I looked for the *nginx* files in the /etc folder and replaced /usr/sbin/nginx with /opt/nginx/sbin/nginx . Then they rebooted the machine and were able to start nginx using sudo service nginx start .

Of course, there is a more elegant way to do this, but I'm lazy to learn how each Linux distribution service is registered.

I also replaced the paths for

  • nginx.conf
  • nginx.pid ( ${prog}.pid ) - otherwise it will not be able to stop nginx
0
source

Source: https://habr.com/ru/post/911176/


All Articles