# Can't start nginx

**URL:** <https://www.ruby-forum.com/t/cant-start-nginx/171927>\
**Category:** NGINX\
**Created:** [July 11, 2009, 5:13pm UTC](https://www.ruby-forum.com/t/cant-start-nginx/171927 "2009-07-11T17:13:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vieten](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/65b543/32.png) [@vieten](https://www.ruby-forum.com/u/vieten)\
**Post date:** [July 11, 2009, 5:13pm UTC](https://www.ruby-forum.com/t/cant-start-nginx/171927/1 "2009-07-11T17:13:20Z")

</div>

Hello,

I’ve tried a serveral times to start nginx but it always ends with no  
happy end.

Download and compiling is no problem for me.

So here goes my way that i do it:

1. cd /tmp  
wget wget [http://sysoev.ru/nginx/nginx-0.7.61.tar.gz](http://sysoev.ru/nginx/nginx-0.7.61.tar.gz)  
tar xvfz nginx-0.7.61.tar.gz  
cd nginx-0.7.61

./configure   
–prefix=/usr   
–conf-path=/etc/nginx/nginx.conf   
–http-log-path=/var/log/nginx/access\_log   
–error-log-path=/var/log/nginx/error\_log   
–pid-path=/var/run/nginx.pid   
–http-client-body-temp-path=/var/tmp/nginx/client   
–http-proxy-temp-path=/var/tmp/nginx/proxy   
–http-fastcgi-temp-path=/var/tmp/nginx/fastcgi   
–with-md5-asm --with-md5=/usr/include   
–with-http\_realip\_module   
–with-http\_ssl\_module   
–with-http\_stub\_status\_module

make  
make install

1. vi /etc/init.d/nginx

#! /bin/sh

### BEGIN INIT INFO

# Provides: nginx

# Required-Start: $all

# Required-Stop: $all

# Default-Start: 2 3 4 5

# Default-Stop: 0 1 6

# Short-Description: starts the nginx web server

# Description: starts nginx using start-stop-daemon

### END INIT INFO

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/nginx.pid --exec $DAEMON – $DAEMON\_OPTS  
echo “$NAME.”  
;;  
stop)  
echo -n "Stopping $DESC: "  
start-stop-daemon --stop --quiet --pidfile  
/usr/local/nginx/logs/nginx.pid --exec $DAEMON  
echo “$NAME.”  
;;  
restart|force-reload)  
echo -n "Restarting $DESC: "  
start-stop-daemon --stop --quiet --pidfile  
/usr/local/nginx/logs/nginx.pid --exec $DAEMON  
sleep 1  
start-stop-daemon --start --quiet --pidfile  
/usr/local/nginx/logs/nginx.pid --exec $DAEMON – $DAEMON\_OPTS  
echo “$NAME.”  
;;  
reload)  
echo -n "Reloading $DESC configuration: "  
start-stop-daemon --stop --signal HUP --quiet --pidfile  
/usr/local/nginx/logs/nginx.pid --exec $DAEMON  
echo “$NAME.”  
;;  
\*)  
N=/etc/init.d/$NAME  
echo “Usage: $N {start|stop|restart|force-reload}” \>&2  
exit 1  
;;  
esac

exit 0

1. chmod 755 /etc/init.d/nginx

2. /etc/init.d/nginx start

But it won’t start because of this error here:

(root)-(/tmp/nginx-0.7.61) $ /etc/init.d/nginx start  
/etc/init.d/nginx: line 1: N: command not found

---

<div class="post-metadata">

**Author:** ![vieten](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/65b543/32.png) [@vieten](https://www.ruby-forum.com/u/vieten)\
**Post date:** [July 13, 2009, 2:14pm UTC](https://www.ruby-forum.com/t/cant-start-nginx/171927/2 "2009-07-13T14:14:29Z")

</div>

Try this:

sh -x /etc/init.d/nginx start

and see what happen or put it in a reply, as you wish.

---

<div class="post-metadata">

**Author:** ![vieten](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/65b543/32.png) [@vieten](https://www.ruby-forum.com/u/vieten)\
**Post date:** [July 13, 2009, 11:23pm UTC](https://www.ruby-forum.com/t/cant-start-nginx/171927/3 "2009-07-13T23:23:36Z")

</div>

Robert G. wrote:

> Try this:
> 
> sh -x /etc/init.d/nginx start
> 
> and see what happen or put it in a reply, as you wish.

Hello, doesn’t work either.

---

<div class="post-metadata">

**Author:** ![vieten](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/65b543/32.png) [@vieten](https://www.ruby-forum.com/u/vieten)\
**Post date:** [July 14, 2009, 10:33am UTC](https://www.ruby-forum.com/t/cant-start-nginx/171927/4 "2009-07-14T10:33:58Z")

</div>

Robert G. wrote:

> Andreas Vieten wrote:
> 
> > Robert G. wrote:
> > 
> > > Try this:
> > > 
> > > sh -x /etc/init.d/nginx start
> > > 
> > > and see what happen or put it in a reply, as you wish.
> > 
> > Hello, doesn’t work either.
> 
> I didnt say its gonna work, but you can see where the error is coming  
> from…

Wait, are u using Ubuntu?! If so, then do this first:

rm -f /bin/sh; ln -s /bin/bash /bin/sh (as root user)

---

<div class="post-metadata">

**Author:** ![vieten](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/65b543/32.png) [@vieten](https://www.ruby-forum.com/u/vieten)\
**Post date:** [July 14, 2009, 10:32am UTC](https://www.ruby-forum.com/t/cant-start-nginx/171927/5 "2009-07-14T10:32:12Z")

</div>

Andreas Vieten wrote:

> Robert G. wrote:
> 
> > Try this:
> > 
> > sh -x /etc/init.d/nginx start
> > 
> > and see what happen or put it in a reply, as you wish.
> 
> Hello, doesn’t work either.

I didnt say its gonna work, but you can see where the error is coming  
from…

---

<div class="post-metadata">

**Author:** ![vieten](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/65b543/32.png) [@vieten](https://www.ruby-forum.com/u/vieten)\
**Post date:** [January 17, 2014, 3:23pm UTC](https://www.ruby-forum.com/t/cant-start-nginx/171927/6 "2014-01-17T15:23:07Z")

</div>

Hello  
exuce me for posting again in this old question  
i have problem for starting nginx  
i tried  
[root@server libmemcached-0.48]# sh -x /etc/init.d/nginx stop

- . /etc/rc.d/init.d/functions  
++ TEXTDOMAIN=initscripts  
++ umask 022  
++ PATH=/sbin:/usr/sbin:/bin:/usr/bin  
++ export PATH  
++ ‘[’ -z ‘’ ‘]’  
++ COLUMNS=80  
++ ‘[’ -z ‘’ ‘]’  
+++ /sbin/consoletype  
++ CONSOLETYPE=pty  
++ ‘[’ -f /etc/sysconfig/i18n -a -z ‘’ -a -z ‘’ ‘]’  
++ . /etc/profile.d/lang.sh  
++ unset LANGSH\_SOURCED  
++ ‘[’ -z ‘’ ‘]’  
++ ‘[’ -f /etc/sysconfig/init ‘]’  
++ . /etc/sysconfig/init  
+++ BOOTUP=color  
+++ RES\_COL=60  
+++ MOVE\_TO\_COL=‘echo -en \033[60G’  
+++ SETCOLOR\_SUCCESS=‘echo -en \033[0;32m’  
+++ SETCOLOR\_FAILURE=‘echo -en \033[0;31m’  
+++ SETCOLOR\_WARNING=‘echo -en \033[0;33m’  
+++ SETCOLOR\_NORMAL=‘echo -en \033[0;39m’  
+++ PROMPT=yes  
+++ AUTOSWAP=no  
+++ ACTIVE\_CONSOLES=’/dev/tty[1-6]’  
+++ SINGLE=/sbin/sushell  
++ ‘[’ pty = serial ‘]’  
++  
\_\_sed\_discard\_ignored\_files=’/(~|.bak|.orig|.rpmnew|.rpmorig|.rpmsave)$/d’

- . /etc/sysconfig/network  
++ NETWORKING=yes  
++ HOSTNAME=server.ghoghnooschat.ir  
++ GATEWAY=144.76.228.1

- ‘[’ yes = no ‘]’

- nginx=/usr/sbin/nginx  
++ basename /usr/sbin/nginx

- prog=nginx

- NGINX\_CONF\_FILE=/etc/nginx/nginx.conf

- lockfile=/var/lock/subsys/nginx

- case “$1” in

- rh\_status\_q

- rh\_status

- stop

- echo -n 'Stopping nginx: ’  
Stopping nginx: + killproc nginx -QUIT

- local RC killlevel= base pid pid\_file= delay try

- RC=0

- delay=3

- try=0

- ‘[’ 2 -eq 0 ‘]’

- ‘[’ nginx = -p ‘]’

- ‘[’ nginx = -d ‘]’

- ‘[’ -n -QUIT ‘]’

- killlevel=-QUIT

- base=nginx

- \_\_pids\_var\_run nginx ‘’

- local base=nginx

- local pid\_file=/var/run/nginx.pid

- pid=

- ‘[’ -f /var/run/nginx.pid ‘]’

- local line p

- ‘[’ ‘!’ -r /var/run/nginx.pid ‘]’

- :

- read line

- ‘[’ -z 25826 ‘]’

- for p in ‘$line’

- ‘[’ -z ‘’ -a -d /proc/25826 ‘]’

- pid=’ 25826’

- :

- read line

- ‘[’ -z ‘’ ‘]’

- break

- ‘[’ -n ’ 25826’ ‘]’

- return 0

- RC=0

- ‘[’ -z ’ 25826’ ‘]’

- ‘[’ -n ’ 25826’ ‘]’

- ‘[’ color = verbose -a -z ‘’ ‘]’

- ‘[’ -z -QUIT ‘]’

- checkpid 25826

- local i

- for i in ‘$\*’

- ‘[’ -d /proc/25826 ‘]’

- return 0

- kill -QUIT 25826

- RC=0

- ‘[’ 0 -eq 0 ‘]’

- success ‘nginx -QUIT’

- ‘[’ color ‘!=’ verbose -a -z ‘’ ‘]’

- echo\_success

- ‘[’ color = color ‘]’

- echo -en ‘\033[60G’  
+ echo -n ‘[’  
[+ ‘[’ color = color ‘]’

- echo -en ‘\033[0;32m’

- echo -n ’ OK ’  
OK + ‘[’ color = color ‘]’

- echo -en ‘\033[0;39m’

- echo -n ‘]’  
]+ echo -ne ‘\r’

- return 0

- return 0

- ‘[’ -z -QUIT ‘]’

- return 0

- retval=0

- echo

- ‘[’ 0 -eq 0 ‘]’

- rm -f /var/lock/subsys/nginx

- return 0

and then :  
[root@server libmemcached-0.48]# sh -x /etc/init.d/nginx start

- . /etc/rc.d/init.d/functions  
++ TEXTDOMAIN=initscripts  
++ umask 022  
++ PATH=/sbin:/usr/sbin:/bin:/usr/bin  
++ export PATH  
++ ‘[’ -z ‘’ ‘]’  
++ COLUMNS=80  
++ ‘[’ -z ‘’ ‘]’  
+++ /sbin/consoletype  
++ CONSOLETYPE=pty  
++ ‘[’ -f /etc/sysconfig/i18n -a -z ‘’ -a -z ‘’ ‘]’  
++ . /etc/profile.d/lang.sh  
++ unset LANGSH\_SOURCED  
++ ‘[’ -z ‘’ ‘]’  
++ ‘[’ -f /etc/sysconfig/init ‘]’  
++ . /etc/sysconfig/init  
+++ BOOTUP=color  
+++ RES\_COL=60  
+++ MOVE\_TO\_COL=‘echo -en \033[60G’  
+++ SETCOLOR\_SUCCESS=‘echo -en \033[0;32m’  
+++ SETCOLOR\_FAILURE=‘echo -en \033[0;31m’  
+++ SETCOLOR\_WARNING=‘echo -en \033[0;33m’  
+++ SETCOLOR\_NORMAL=‘echo -en \033[0;39m’  
+++ PROMPT=yes  
+++ AUTOSWAP=no  
+++ ACTIVE\_CONSOLES=’/dev/tty[1-6]’  
+++ SINGLE=/sbin/sushell  
++ ‘[’ pty = serial ‘]’  
++  
\_\_sed\_discard\_ignored\_files=’/(~|.bak|.orig|.rpmnew|.rpmorig|.rpmsave)$/d’
- . /etc/sysconfig/network  
++ NETWORKING=yes  
++ HOSTNAME=server.ghoghnooschat.ir  
++ GATEWAY=144.76.228.1
- ‘[’ yes = no ‘]’
- nginx=/usr/sbin/nginx  
++ basename /usr/sbin/nginx
- prog=nginx
- NGINX\_CONF\_FILE=/etc/nginx/nginx.conf
- lockfile=/var/lock/subsys/nginx
- case “$1” in
- rh\_status\_q
- rh\_status
- exit 0

and my nginx don’t start!  
what should i do ?
