宝塔面板nginx安装后无法启动的解决方法
发表时间:2023-12-06 23:36:04 浏览:1312 次
最近在安排完面板环境有,创建网址显示
卸载后,重新安装,但是nginx启动不了查看,/etc/rc.d/init.d/nginx文件空白,所以用了之前的正常的nginx文件复制了一份,解决
通常到这一步就解决了。
如果找不到正常的
下面给你复制一份:
#! /bin/sh
# chkconfig: 2345 55 25
# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and
# run 'update-rc.d -f nginx defaults', or use the appropriate command on your
# distro. For CentOS/Redhat run: 'chkconfig --add nginx'
### 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
# Author: licess
# website: http://www.bt.cn
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=nginx
NGINX_BIN=/www/server/nginx/sbin/$NAME
CONFIGFILE=/www/server/nginx/conf/$NAME.conf
PIDFILE=/www/server/nginx/logs/$NAME.pid
ulimit -n 8192
case "$1" in
start)
echo -n "Starting $NAME... "
if [ -f $PIDFILE ];then
mPID=`cat $PIDFILE`
isStart=`ps ax | awk '{ print $1 }' | grep -e "^${mPID}$"`
if [ "$isStart" != '' ];then
echo "$NAME (pid `pidof $NAME`) already running."
exit 1
fi
fi
$NGINX_BIN -c $CONFIGFILE
if [ "$?" != 0 ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;
stop)
echo -n "Stoping $NAME... "
if [ -f $PIDFILE ];then
mPID=`cat $PIDFILE`
isStart=`ps ax | awk '{ print $1 }' | grep -e "^${mPID}$"`
if [ "$isStart" = '' ];then
echo "$NAME is not running."
exit 1
fi
else
echo "$NAME is not running."
exit 1
fi
$NGINX_BIN -s stop
if [ "$?" != 0 ] ; then
echo " failed. Use force-quit"
exit 1
else
echo " done"
fi
;;
status)
if [ -f $PIDFILE ];then
mPID=`cat $PIDFILE`
isStart=`ps ax | awk '{ print $1 }' | grep -e "^${mPID}$"`
if [ "$isStart" != '' ];then
echo "$NAME (pid `pidof $NAME`) already running."
exit 1
else
echo "$NAME is stopped"
exit 0
fi
else
echo "$NAME is stopped"
exit 0
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
reload)
echo -n "Reload service $NAME... "
if [ -f $PIDFILE ];then
mPID=`cat $PIDFILE`
isStart=`ps ax | awk '{ print $1 }' | grep -e "^${mPID}$"`
if [ "$isStart" != '' ];then
$NGINX_BIN -s reload
echo " done"
else
echo "$NAME is not running, can't reload."
exit 1
fi
else
echo "$NAME is not running, can't reload."
exit 1
fi
;;
configtest)
echo -n "Test $NAME configure files... "
$NGINX_BIN -t
;;
*)
echo "Usage: $0 {start|stop|restart|reload|status|configtest}"
exit 1
;;
esac
宝塔面板里面的nginx安装后无法启动的解决方法:当我们安装好宝塔面板和nginx后,有时发现nginx无法启动,无论点击启动、重启还是重载配置都提示“nginx服务启动失败”,这时该怎么办呢?
造成这种情况的原因很多,这里分析详细一下:
第一种情况,宝塔面板安装完成后,安装nginx出现一些小问题,导致:/etc/rc.d/init.d/nginx文件空白,这样就无法启动nginx,解决方法:从正常的宝塔环境下对应目录中复制一份nginx文件源码到/etc/rc.d/init.d/nginx文件中保存即可,再启动nginx就可以了。
第二种情况,启动nginx报如下错误:
/www/server/nginx/sbin/nginx: error while loading shared libraries: libgd.so.3: cannot open shared object file: No such file or directory
这种出错是缺少依赖的问题,根据自身情况在ssh执行如下命令:
缺失libgd.so.3
wget http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/gd-2.2.5-7.el8.x86_64.rpm
rpm -i --nodeps gd-2.2.5-7.el8.x86_64.rpm #忽略依赖安装
缺失libXpm.so.4
wget http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/libXpm-3.5.12-8.el8.x86_64.rpm
rpm -i libXpm-3.5.12-8.el8.x86_64.rpm
缺失libtiff.so.5
wget http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/libtiff-4.0.9-20.el8.x86_64.rpm
rpm -i --nodeps libtiff-4.0.9-20.el8.x86_64.rpm
libjbig.so.2.1
wget http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/jbigkit-libs-2.1-14.el8.x86_64.rpm
rpm -i jbigkit-libs-2.1-14.el8.x86_64.rpm
第三种情况,nginx防火墙和网站监控报表与Nginx不太兼容
已知宝塔两个插件: nginx防火墙和网站监控报表与Nginx不太兼容。
如果先安装了上面两个插件,或者安装好NGINX后再升级NGINX版本,很可能性就会出现nginx无法启动的情况。
1、更新了下Nginx,更新到1.18就发现nginx无法启动了。只要是点启动就会报以下错误。
nginx: the configuration file /www/server/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /www/server/nginx/conf/nginx.conf test failed
解决方法:卸载宝塔免费nginx防火墙及网站监控报表
| 百度搜索推广 |公司简介 |人才招聘 |付款方式 |联系方式 | ||
| 恩施网络公司-恩施市百捷在线网络科技有限公司 Copyright © 2012-2021 网址:www.esbaidu.com | ||
| 电话:15587589530 传真:15587589530 联系人:邹经理 | ||
| 地址:恩施市火车站万福国际写字楼613 Email:zou@esbaidu.com 备案号:鄂ICP备16001060号-8 | ||
|