Nginx挂起重启

我必须在后台运行Nginx启动脚本,否则它在运行时不会返回shell – 它通过以下任一方式执行此操作

service Nginx start

..或只是运行..

/etc/init.d/Nginx

..直接.我必须在后台运行它然后否认它..

在Ubuntu 14.04.2上运行,Nginx v 1.4.6

Nginx -V给了我们:

Nginx version: Nginx/1.4.6 (Ubuntu)
built by gcc 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --prefix=/usr/share/Nginx --conf-path=/etc/Nginx/Nginx.conf --http-log-path=/var/log/Nginx/access.log --error-log-path=/var/log/Nginx/error.log --lock-path=/var/lock/Nginx.lock --pid-path=/run/Nginx.pid --http-client-body-temp-path=/var/lib/Nginx/body --http-fastcgi-temp-path=/var/lib/Nginx/fastcgi --http-proxy-temp-path=/var/lib/Nginx/proxy --http-scgi-temp-path=/var/lib/Nginx/scgi --http-uwsgi-temp-path=/var/lib/Nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module

..和“bash -x Nginx restart”返回..

+ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+ DAEMON=/usr/sbin/Nginx
+ NAME=Nginx
+ DESC=Nginx
+ '[' -f /etc/default/Nginx ']'
+ . /etc/default/Nginx
+ test -x /usr/sbin/Nginx
+ set -e
+ . /lib/lsb/init-functions
+++ run-parts --lsbsysinit --list /lib/lsb/init-functions.d
++ for hook in '$(run-parts --lsbsysinit --list /lib/lsb/init-functions.d 2>/dev/null)'
++ '[' -r /lib/lsb/init-functions.d/20-left-info-blocks ']'
++ . /lib/lsb/init-functions.d/20-left-info-blocks
++ for hook in '$(run-parts --lsbsysinit --list /lib/lsb/init-functions.d 2>/dev/null)'
++ '[' -r /lib/lsb/init-functions.d/50-ubuntu-logging ']'
++ . /lib/lsb/init-functions.d/50-ubuntu-logging
+++ LOG_DAEMON_MSG=
++ FANCYTTY=
++ '[' -e /etc/lsb-base-logging.sh ']'
++ true
+ case "$1" in
+ echo -n 'Restarting Nginx: '
Restarting Nginx: + start-stop-daemon --stop --quiet --pidfile /var/run/Nginx.pid --exec /usr/sbin/Nginx
+ sleep 1
Nginx.
+ test_Nginx_config
+ /usr/sbin/Nginx -t
+ return 0
+ start-stop-daemon --start --quiet --pidfile /var/run/Nginx.pid --exec /usr/sbin/Nginx --

..然后什么也没有.

CONfigS:

Nginx.conf

# Generic startup file.
user www-data developers;

#ususally equal to number of cpu's you have. run command "grep processor /proc/cpuinfo | wc -l" to find it
worker_processes auto;

error_log  /var/log/Nginx/error.log;
pid        /var/run/Nginx.pid;

# Keeps the logs free of messages about not being able to bind().
daemon     off;

events {
    worker_connections  1024;
}

http {
#   rewrite_log on;

    include mime.types;
    default_type       application/octet-stream;
    access_log         /var/log/Nginx/access.log;
    sendfile           on;
#   tcp_nopush         on;
    keepalive_timeout  3;
#   tcp_nodelay        on;
#   gzip               on;
        #PHP max upload limit cannot be larger than this
    client_max_body_size 13m;

fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;

    index              index.PHP index.html index.htm;

    # Upstream to abstract backend connection(s) for PHP.
    upstream PHP {
                #this should match value of "listen" directive in PHP-fpm pool
        server unix:/var/run/PHP5-fpm.sock;
    }

    include sites-enabled/*;
}

任何见解都将非常感激.

最佳答案
init脚本,特别是helper start-stop-daemon,认情况下它开始将程序放在后台.但是,有人错误地改变了你的Nginx配置,以防止它这样做:

# Keeps the logs free of messages about not being able to bind().
daemon     off;

应完全删除此部分.首先,Nginx应该是daemonizing.其次,如果出现关于无法绑定()的消息,那不是因为Nginx作为守护进程运行,这是因为当有人试图启动第二个副本时,Nginx已经在运行.

相关文章

Nginx (engine x) 是一个高性能的HTTP和反向代理服务,也是一...
本地项目配置 1 复制 luffy/settings/dev.py为prop.py 修改l...
nginx不仅可以隐藏版本信息,还支持自定义web服务器信息 先看...
一 、此次漏洞分析 1 nginx HTTP/2漏洞 [nginx-announce] ng...
###进入nginx 目录cd /usr/local/nginx###递归显示 2 级目录...
在cmd命令窗口输入下面命令进行查看 tasklist /fi "ima...