# Init.d script

**URL:** <https://www.ruby-forum.com/t/init-d-script/193277>\
**Category:** NGINX\
**Created:** [August 14, 2010, 4:34pm UTC](https://www.ruby-forum.com/t/init-d-script/193277 "2010-08-14T16:34:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [August 14, 2010, 4:34pm UTC](https://www.ruby-forum.com/t/init-d-script/193277/1 "2010-08-14T16:34:12Z")

</div>

How should a nginx script in init.d for automatic restart look like on  
Debian 5?

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [August 14, 2010, 10:04pm UTC](https://www.ruby-forum.com/t/init-d-script/193277/2 "2010-08-14T22:04:32Z")

</div>

PÃ¥l BergstrÃ¶m wrote:

> How should a nginx script in init.d for automatic restart look like on  
> Debian 5?

Can this work?

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [December 11, 2010, 11:31pm UTC](https://www.ruby-forum.com/t/init-d-script/193277/3 "2010-12-11T23:31:59Z")

</div>

Or this:

[http://articles.slicehost.com/2007/10/19/debian-etch-adding-an-nginx-init-script](http://articles.slicehost.com/2007/10/19/debian-etch-adding-an-nginx-init-script)

I have nginx installed in /opt/nginx. Can I just change this?

DAEMON=/usr/local/sbin/nginx

To

DAEMON=/opt/nginx/sbin/nginx

Will it work?

Btw, why the PATH variable in the script if it’s not used in the script?

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [December 12, 2010, 10:25am UTC](https://www.ruby-forum.com/t/init-d-script/193277/4 "2010-12-12T10:25:08Z")

</div>

David J. wrote in post #967875:

> On 12/11/10 5:31 PM, Paul B. wrote:
> 
> > DAEMON=/opt/nginx/sbin/nginx
> > 
> > Will it work?
> > 
> > Btw, why the PATH variable in the script if it’s not used in the script?
> 
> Yes. Look at the other vars as well and just point them to where they  
> are on your setup;

Do I need to add it to update-rc? Not sure what that does.

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [December 12, 2010, 1:27am UTC](https://www.ruby-forum.com/t/init-d-script/193277/5 "2010-12-12T01:27:57Z")

</div>

On 12/11/10 5:31 PM, Paul B. wrote:

> DAEMON=/opt/nginx/sbin/nginx
> 
> Will it work?
> 
> Btw, why the PATH variable in the script if it’s not used in the script?

Yes. Look at the other vars as well and just point them to where they  
are on your setup;

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [December 12, 2010, 12:21pm UTC](https://www.ruby-forum.com/t/init-d-script/193277/6 "2010-12-12T12:21:23Z")

</div>

Paul B. wrote in post #967901:

> David J. wrote in post #967875:
> 
> > On 12/11/10 5:31 PM, Paul B. wrote:
> > 
> > > DAEMON=/opt/nginx/sbin/nginx
> > > 
> > > Will it work?
> > > 
> > > Btw, why the PATH variable in the script if it’s not used in the script?
> > 
> > Yes. Look at the other vars as well and just point them to where they  
> > are on your setup;
> 
> Do I need to add it to update-rc? Not sure what that does.

I did. Hopefully it will restart now when the server restart.
