service nginx start 报错,请仔细看报错信息,万分感谢

问答中心分类: Nginxservice nginx start 报错,请仔细看报错信息,万分感谢
charles asked 7年 ago
service nginx start|stop|restart   等等, 启动会这个错。

Job for nginx.service failed because a configured resource limit was exceeded. See "systemctl status nginx.service" and "journalctl -xe" for details.
[FAIL
[root@localhost showdoc]# systemctl status nginx.service
● nginx.service - SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server
Loaded: loaded (/etc/rc.d/init.d/nginx)
Active: failed (Result: resources) since Wed 2016-11-23 11:04:24 CST; 19min ago
Docs: man:systemd-sysv-generator(8)
Process: 6852 ExecStart=/etc/rc.d/init.d/nginx start (code=exited, status=0/SUCCESS)

Nov 23 11:04:24 localhost.localdomain systemd[1]: Starting SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server...
Nov 23 11:04:24 localhost.localdomain systemd[1]: PID file /var/run/nginx.pid not readable (yet?) after start.
Nov 23 11:04:24 localhost.localdomain systemd[1]: Failed to start SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server.
Nov 23 11:04:24 localhost.localdomain systemd[1]: Unit nginx.service entered failed state.
Nov 23 11:04:24 localhost.localdomain systemd[1]: nginx.service failed

nginx的配置是没问题的。

Nov 23 11:04:24 localhost.localdomain systemd[1]: nginx.service failed.
[root@localhost showdoc]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

详细看 systemctl status nginx.service  的问题。 检查了都没问题。 至今无解。   

9 Answers
oneinstack answered 7年 ago
killall nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf #这样启动是否有问题?

charles answered 7年 ago
@oneinstack      那种是没问题的。装的时候 用service不行, 我就是一直 用 原始方法启动跟重启的。

charles answered 7年 ago
@oneinstack  我只是想知道 service的方法为何会那样

oneinstack answered 7年 ago
操作系统具体版本多少?

charles answered 7年 ago
@oneinstack 

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

catch answered 7年 ago
我和你遇到了一样的问题,而且我的也是centos7,,是不是oneinstack有BUG?

davidtall answered 7年 ago
启动脚本有坑,nginx reload 和stop的时候是直接用killproc 干掉进程的,应该用nginx -s reload 和nginx -s stop 完整脚本如下。

#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /www/wdlinux/nginx/conf/nginx.conf
# pidfile: /www/wdlinux/nginx/logs/nginx.pid
# Url http://www.wdlinux.cn
# Last Updated 2010.06.01

# 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/local/tengine/sbin/nginx"
prog=$(basename $nginx)

NGINX_CONF_FILE="/usr/local/tengine/conf/nginx.conf"

#NGINX_PID="/www/wdlinux/nginx/logs/nginx.pid"

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

lockfile=/var/lock/subsys/nginx

start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
##service php-fpm start
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
$nginx -s stop
echo_success
retval=$?
echo
##service php-fpm stop
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}

restart() {
stop
start
}

reload() {
configtest || return $?
echo -n $"Reloading $prog: "
$nginx -s reload
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

charles answered 7年 ago
@davidtall    感谢

oneinstack answered 5年 ago
现在已经切换至systemd管理。