2 Nginx server installed and service nginx restart cant work

Hi I recently may have accidentally installed 2 nginx together on 1 node and now I use the command 'service nginx restart.'

It there a way to solve this without rebuilding the server?

I followed this guide for the install of rails and also nginx, which lead to the error.

https://library.linode.com/frameworks/r … 0.04-lucid">https://library.linode.com/frameworks/ruby-on-rails-nginx/ubuntu-10.04-lucid

8 Replies

I am not great expert but the only way you can have two nginx services is to have two links pointing to /etc/init.d/nginx

The links should reside in /etc/rc2.d

hth

Nenad

Hi Nenad,

So how to go from here to solve? Please help.

Really appreciate.

If you do

ls -l /etc/rc2.d

and really see that there are two links pointing to etc/init.d/nginx

just delete one link; they are doing the same

if you do

ps aux | grep nginx

you get nginx processes. In normal circumstances you have one master process and more worker processes.

In your case you should have two master processes.

To kill manually one master and his workers you can issue

kill -15 pidnum

where pidnum is the number from the second column (of the master row) that you get with previous ps command.

hth

Nenad

Hi Nenad,

I tried using your method. However when I do ls -l /etc/rc2.d, I can only see 1 nginx link.

Please see the image attached.

~~![](<URL url=)https://www.dropbox.com/s/5u890pk40037m … shot_2.png">https://www.dropbox.com/s/5u890pk40037mzt/Screenshot_2.png" />

[https://www.dropbox.com/s/5u890pk40037mzt/Screenshot2.png" target="blank">](https://www.dropbox.com/s/5u890pk40037m … shot_2.png">https://www.dropbox.com/s/5u890pk40037mzt/Screenshot_2.png](

What's the output of which -a nginx that'll list your nginx binaries. If you installed nginx then installed passenger and nginx you probably do have two versions, one from the package manager and one compiled. Try running apt-get remove nginx && killall nginx && service nginx start that will remove the packaged version of nginx, kill all nginx processes and start up the remaining nginx installation

hi obs,

thanks for the reply and help.

I tried what you mentioned

The output for

which -a nginx

is:

/usr/sbin/nginx

and I also tried running:

apt-get remove nginx && killall nginx && service nginx start

the output is
> nx start

Reading package lists… Done

Building dependency tree

Reading state information… Done

The following packages were automatically installed and are no longer required:

libgd2-noxpm libjpeg-turbo8 libjpeg8 libxslt1.1 nginx-common nginx-full

Use 'apt-get autoremove' to remove them.

The following packages will be REMOVED:

nginx

0 upgraded, 0 newly installed, 1 to remove and 3 not upgraded.

After this operation, 91.1 kB disk space will be freed.

Do you want to continue [Y/n]? y

(Reading database … 51385 files and directories currently installed.)

Removing nginx …

nginx(3382): Operation not permitted

nginx(3383): Operation not permitted

nginx(3385): Operation not permitted

nginx(3386): Operation not permitted

nginx(3388): Operation not permitted

nginx: no process found

Is this normal?

Really appreciate your help

Ilogin as root again and try to run

apt-get remove nginx && killall nginx && service nginx start

This is the output"
> nginx start

Reading package lists… Done

Building dependency tree

Reading state information… Done

Package 'nginx' is not installed, so not removed

The following packages were automatically installed and are no longer required:

libgd2-noxpm libjpeg-turbo8 libjpeg8 libxslt1.1 nginx-common nginx-full

Use 'apt-get autoremove' to remove them.

0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

As root run apt-get autoremove to remove the left over nginx packages. Then try running through the passenger doc again. You may want to reboot after the setup just to make sure any nginx processes have been killed.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct