LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-25-2012, 10:44 AM   #1
dreamcoder
LQ Newbie
 
Registered: Jul 2012
Distribution: Ubuntu 12.04
Posts: 22

Rep: Reputation: Disabled
Problem in starting nginx on Ubuntu 11.10 VPS


Hey guys,

Today I installed nginx 1.2.2 on my new Virtual Private Server having Ubuntu 11.10 Server Edition.
I manually built the nginx 1.2.2 so after the installation and all the configurations, when I finally entered the following command in putty:

Code:
sudo /etc/init.d/nginx start
I got the response:

Code:
Starting nginx: start-stop-daemon: --start needs --exec or --startas
Try 'start-stop-daemon --help' for more information.
and when I enter the IP Address of my VPS in the the browser, I can't see the nginx Welcome Page.
Also, when I run top command in putty I don't see any process related to nginx running there, this shows that running
Code:
sudo /etc/init.d/nginx start
is not starting up nginx

the contents of nginx script is:

Code:
#! /bin/sh

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/sbin/nginx
NAME=nginx
DESC=nginx

test -x $DAEMON || exit 0

# Include nginx defaults if available
if [ -f /etc/default/nginx ] ; then
        . /etc/default/nginx
fi

set -e

case "$1" in
  start)
        echo -n "Starting $DESC: "
	start-stop-daemon --start --quiet --pidfile /usr/local/nginx/logs/$NAME$
                --exec $DAEMON -- $DAEMON_OPTS
        echo "$NAME."
        ;;

  stop)
        echo -n "Stopping $DESC: "
        start-stop-daemon --stop --quiet --pidfile /usr/local/nginx/logs/$NAME.$
                --exec $DAEMON
        echo "$NAME."
        ;;

 restart|force-reload)
        echo -n "Restarting $DESC: "
        start-stop-daemon --stop --quiet --pidfile
                /usr/local/nginx/logs/$NAME.pid --exec $DAEMON
        sleep 1
        start-stop-daemon --start --quiet --pidfile
                /usr/local/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
        echo "$NAME."
        ;;

 reload)
      echo -n "Reloading $DESC configuration: "
      start-stop-daemon --stop --signal HUP --quiet --pidfile /usr/local/nginx/$
          --exec $DAEMON
      echo "$NAME."
      ;;

 *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
        exit 1
        ;;
esac

exit 0

So guys I can't figure out whats the problem, how can I make nginx script run at the startup, please help me out

Thanks a lot
 
Old 07-25-2012, 11:48 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

Better try this startup script instead.

Regards
 
1 members found this post helpful.
Old 07-25-2012, 12:40 PM   #3
dreamcoder
LQ Newbie
 
Registered: Jul 2012
Distribution: Ubuntu 12.04
Posts: 22

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by bathory View Post
Hi,

Better try this startup script instead.

Regards

Thanks bro for your response, following your suggestion I saved the script at /etc/init.d/nginx and then ran /usr/sbin/update-rc.d -f nginx defaults but this returned:

Code:
System start/stop links for /etc/init.d/nginx already exist.
unable to write to /var/lib/update-rc.d/nginx.new at /usr/sbin/update-rc.d line 59.
and here's the line no 59 of /usr/sbin/update-rc.d

Code:
open(FILE, ">", "$archive/${script}.new") || die "unable to write to $archive/${script}.new";
Any idea how can I fix this ? or any other alternate way to run nginx at startup ?

Thanks a lot
 
Old 07-25-2012, 01:24 PM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Run first
Code:
update-rc.d -f nginx remove
to remove the symlinks from your previous attempt and then re-run
Code:
update-rc.d nginx defaults
to re-create them
 
Old 07-25-2012, 01:58 PM   #5
dreamcoder
LQ Newbie
 
Registered: Jul 2012
Distribution: Ubuntu 12.04
Posts: 22

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by bathory View Post
Run first
Code:
update-rc.d -f nginx remove
to remove the symlinks from your previous attempt and then re-run
Code:
update-rc.d nginx defaults
to re-create them
Awesome bro, that worked like a charm

I updated rc.d and then ran /usr/sbin/update-rc.d -f nginx defaults, nginx was successfully added to startup and then I ran sudo /etc/init.d/nginx start and this time nginx started without any problem. I entered my VPS IP Address in the browser to see the 'nginx welcome page'. I rebooted the system and ran top to see nginx running there

But can you please tell me previously why nginx was not starting with the following message shown:
Code:
Starting nginx: start-stop-daemon: --start needs --exec or --startas
Try 'start-stop-daemon --help' for more information.
And what did we do just now to resolve the problem ?


Thanks a lot bro

\\ U ROCK //
 
Old 07-25-2012, 02:26 PM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
But can you please tell me previously why nginx was not starting with the following message shown:
Code:

Starting nginx: start-stop-daemon: --start needs --exec or --startas
Try 'start-stop-daemon --help' for more information.

And what did we do just now to resolve the problem ?
See the differences between your startup script and the one provided by nginx, to find what was wrong with yours

Regards
 
Old 07-25-2012, 03:05 PM   #7
dreamcoder
LQ Newbie
 
Registered: Jul 2012
Distribution: Ubuntu 12.04
Posts: 22

Original Poster
Rep: Reputation: Disabled
Thanks for pointing out the obvious
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with ubuntu VPS - not showing the websites koslibpro Linux - Networking 1 07-25-2012 10:16 AM
nginx + php-fpm and nginx modules fantasygoat Linux - Server 0 06-09-2011 12:21 PM
LXer: Nginx+Varnish compared to Nginx LXer Syndicated Linux News 0 04-27-2011 02:30 PM
Nginx experts help me-problem when using Nginx php-fpm !!! HuMan-BiEnG Linux - Server 2 04-17-2011 02:30 PM
NGINX with PHP-FPM vis NGINX with Spawn-FCGI WhisperiN Linux - Server 1 03-15-2011 06:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration