# Nginx restart/reload not working

**URL:** <https://www.ruby-forum.com/t/nginx-restart-reload-not-working/234886>\
**Category:** NGINX\
**Created:** [January 7, 2015, 9:13am UTC](https://www.ruby-forum.com/t/nginx-restart-reload-not-working/234886 "2015-01-07T09:13:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@alcina](https://www.ruby-forum.com/u/alcina)\
**Post date:** [January 7, 2015, 9:13am UTC](https://www.ruby-forum.com/t/nginx-restart-reload-not-working/234886/1 "2015-01-07T09:13:56Z")

</div>

I have compiled nginx from source and i think that there is something  
wrong  
with my init script.I changed the error log from debug to crit but error  
log  
was still showing [debug] in logs.I had to killall nginx and then i ran  
service nginx start to nginx again

#!/bin/sh

# 

# nginx - this script starts and stops the nginx daemon

# 

# chkconfig: - 85 15

# description: Nginx is an HTTP(S) server, HTTP(S) reverse \

# proxy and IMAP/POP3 proxy server

# processname: nginx

# config: /etc/nginx/nginx.conf

# config: /etc/sysconfig/nginx

# pidfile: /var/run/nginx.pid

# Source function library.

. /etc/rc.d/init.d/functions

# Source networking configuration.

. /etc/sysconfig/network

# Check that networking is up.

[“$NETWORKING” = “no”] && exit 0

nginx=“/usr/sbin/nginx”  
prog=$(basename $nginx)

NGINX\_CONF\_FILE=“/etc/nginx/nginx.conf”

[-f /etc/sysconfig/nginx] && . /etc/sysconfig/nginx

lockfile=/var/lock/subsys/nginx

make\_dirs() {

# make required directories

user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^]*\).*/\1/g' -`  
if [-z “`grep $user /etc/passwd`”]; then  
useradd -M -s /bin/nologin $user  
fi  
options=`$nginx -V 2>&1 | grep 'configure arguments:'`  
for opt in $options; do  
if [`echo $opt | grep '.*-temp-path'`]; then  
value=`echo $opt | cut -d "=" -f 2`  
if [! -d “$value”]; then  
# echo “creating” $value  
mkdir -p $value && chown -R $user $value  
fi  
fi  
done  
}

start() {  
[-x $nginx] || exit 5  
[-f $NGINX\_CONF\_FILE] || exit 6  
make\_dirs  
echo -n $"Starting $prog: "  
daemon $nginx -c $NGINX\_CONF\_FILE  
retval=$?  
echo  
[$retval -eq 0] && touch $lockfile  
return $retval  
}

stop() {  
echo -n $"Stopping $prog: "  
killproc $prog -QUIT  
retval=$?  
echo  
[$retval -eq 0] && rm -f $lockfile  
return $retval  
}

restart() {  
configtest || return $?  
stop  
sleep 1  
start  
}

reload() {  
configtest || return $?  
echo -n $"Reloading $prog: "  
killproc $nginx -HUP  
RETVAL=$?  
echo  
}

force\_reload() {  
restart  
}

configtest() {  
$nginx -t -c $NGINX\_CONF\_FILE  
}

rh\_status() {  
status $prog  
}

rh\_status\_q() {  
rh\_status \>/dev/null 2\>&1  
}

case “$1” in  
start)  
rh\_status\_q && exit 0  
$1  
;;  
stop)  
rh\_status\_q || exit 0  
$1  
;;  
restart|configtest)  
$1  
;;  
reload)  
rh\_status\_q || exit 7  
$1  
;;  
force-reload)  
force\_reload  
;;  
status)  
rh\_status  
;;  
condrestart|try-restart)  
rh\_status\_q || exit 0  
;;  
\*)  
echo $“Usage: $0  
{start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}”  
exit 2  
esac

nginx version: nginx/1.7.9  
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)  
TLS SNI support enabled  
configure arguments: --prefix=/usr/share/nginx  
–sbin-path=/usr/sbin/nginx  
–conf-path=/etc/nginx/nginx.conf  
–error-log-path=/var/log/nginx/error.log  
–http-log-path=/var/log/nginx/access.log  
–http-client-body-temp-path=/var/lib/nginx/tmp/client\_body  
–http-proxy-temp-path=/var/lib/nginx/tmp/proxy  
–http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi  
–http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi  
–http-scgi-temp-path=/var/lib/nginx/tmp/scgi  
–pid-path=/var/run/nginx.pid  
–lock-path=/var/lock/subsys/nginx --user=nginx --group=nginx  
–with-file-aio --with-ipv6 --with-http\_ssl\_module  
–with-http\_spdy\_module  
–with-http\_realip\_module --with-http\_geoip\_module  
–with-http\_sub\_module  
–with-http\_random\_index\_module --with-http\_gzip\_static\_module  
–with-http\_stub\_status\_module --with-debug

Posted at Nginx Forum:

> **[Nginx restart/reload not working](https://forum.nginx.org/read.php?2,255979,255979#msg-255979)**
>
> I have compiled nginx from source and i think that there is something wrong with my init script.I changed the error log from debug to crit but error log was still showing \[debug\] in logs.I had to killall nginx and then i ran service nginx start to...
