mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-18 23:45:52 +08:00
up
This commit is contained in:
@@ -1,118 +1,48 @@
|
||||
#! /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 openresty'
|
||||
#!/bin/bash
|
||||
# chkconfig: 345 85 15
|
||||
# description: Apache Server
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: nginx
|
||||
# Required-Start: $all
|
||||
# Required-Stop: $all
|
||||
# Provides: apache
|
||||
# Required-Start: $network
|
||||
# Required-Stop: $network
|
||||
# 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
|
||||
# Description: Apache Server
|
||||
### END INIT INFO
|
||||
|
||||
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/homebrew/bin
|
||||
NAME=nginx
|
||||
NGINX_BIN={$SERVER_PATH}/openresty/bin/openresty
|
||||
CONFIGFILE={$SERVER_PATH}/openresty/nginx/conf/$NAME.conf
|
||||
PIDFILE={$SERVER_PATH}/openresty/nginx/logs/$NAME.pid
|
||||
NAME=apache
|
||||
# Apache 可执行文件的路径
|
||||
DAEMON={$SERVER_PATH}/httpd/bin/httpd
|
||||
# 进程的 PID 文件路径
|
||||
PIDFILE={$SERVER_PATH}/httpd/logs/httpd.pid
|
||||
|
||||
# 根据传入的参数执行不同操作
|
||||
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
|
||||
echo "Starting Apache..."
|
||||
$DAEMON -k start
|
||||
;;
|
||||
|
||||
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
|
||||
echo "Stopping Apache..."
|
||||
$DAEMON -k stop
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
sleep 1
|
||||
$0 start
|
||||
echo "Restarting Apache..."
|
||||
$DAEMON -k restart
|
||||
;;
|
||||
|
||||
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
|
||||
status)
|
||||
if [ -f $PIDFILE ]; then
|
||||
echo "Apache is running."
|
||||
else
|
||||
echo "Apache is not running."
|
||||
fi
|
||||
;;
|
||||
|
||||
configtest)
|
||||
echo -n "Test $NAME configure files... "
|
||||
$NGINX_BIN -t
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|reload|status|configtest}"
|
||||
echo "Usage: $0 {start|stop|restart|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
@@ -1,6 +1,6 @@
|
||||
function orPost(method, args, callback){
|
||||
function httpPost(method, args, callback){
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
$.post('/plugins/run', {name:'openresty', func:method, args:JSON.stringify(args)}, function(data) {
|
||||
$.post('/plugins/run', {name:'apache', func:method, args:JSON.stringify(args)}, function(data) {
|
||||
layer.close(loadT);
|
||||
if (!data.status){
|
||||
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']});
|
||||
@@ -21,7 +21,7 @@ function orPluginService(_name, version){
|
||||
version = '';
|
||||
}
|
||||
|
||||
orPost('status', data, function(data){
|
||||
httpPost('status', data, function(data){
|
||||
if (data.data == 'start'){
|
||||
orPluginSetService(_name, true, version);
|
||||
} else {
|
||||
@@ -59,7 +59,7 @@ function orPluginOpService(a, b, v,request_callback) {
|
||||
case "reload":d = '重载';break;
|
||||
}
|
||||
layer.confirm( msgTpl('您真的要{1}{2}{3}服务吗?', [d,a,v]), {icon:3,closeBtn: 2}, function() {
|
||||
orPost('get_os',{},function(data){
|
||||
httpPost('get_os',{},function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
if (!rdata['auth']){
|
||||
layer.prompt({title: '检查到权限不足,需要输入密码!', formType: 1},function(pwd, index){
|
||||
@@ -113,7 +113,7 @@ function orPluginOpServiceOp(a,b,c,d,a,v,request_callback){
|
||||
//查看Nginx负载状态
|
||||
function getOpStatus() {
|
||||
var loadT = layer.msg('正在处理,请稍后...', { icon: 16, time: 0, shade: 0.3 });
|
||||
$.post('/plugins/run', {name:'openresty', func:'run_info'}, function(data) {
|
||||
$.post('/plugins/run', {name:'apache', func:'run_info'}, function(data) {
|
||||
layer.close(loadT);
|
||||
try {
|
||||
var rdata = $.parseJSON(data.data);
|
||||
@@ -140,7 +140,7 @@ function getOpStatus() {
|
||||
|
||||
|
||||
function setOpCfg(){
|
||||
orPost('get_cfg', {}, function(data){
|
||||
httpPost('get_cfg', {}, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
var rdata = rdata.data;
|
||||
// console.log(rdata);
|
||||
@@ -196,7 +196,7 @@ function submitConf() {
|
||||
};
|
||||
|
||||
// console.log(data);
|
||||
orPost('set_cfg', data, function(rdata){
|
||||
httpPost('set_cfg', data, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
// console.log(rdata);
|
||||
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
|
||||
@@ -212,14 +212,14 @@ function otherFunc(){
|
||||
}
|
||||
|
||||
function cronAddCheck(){
|
||||
orPost('cron_add_check', {}, function(data){
|
||||
httpPost('cron_add_check', {}, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
|
||||
});
|
||||
}
|
||||
|
||||
function cronDelCheck(){
|
||||
orPost('cron_del_check', {}, function(data){
|
||||
httpPost('cron_del_check', {}, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
|
||||
});
|
||||
|
||||
@@ -72,14 +72,17 @@ Install_App()
|
||||
cd ${apacheDir}/apr-${APR_VERSION} && ./configure --prefix=${serverPath}/apache/apr
|
||||
make -j${cpuCore} && make install
|
||||
if [ "$?" == "0" ];then
|
||||
if [ ! -f ${serverPath}/apache/apr/bin/apr-1-config ];then
|
||||
echo "APR installation failed: apr-config not found"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "APR configure failed"
|
||||
exit 1
|
||||
fi
|
||||
# 检查 APR 配置文件
|
||||
APR_CONFIG=$(find ${serverPath}/apache/apr -name "apr-*config" | head -1)
|
||||
if [ -z "$APR_CONFIG" ];then
|
||||
echo "APR installation failed: apr-config not found"
|
||||
exit 1
|
||||
fi
|
||||
echo "APR installed successfully: $APR_CONFIG"
|
||||
else
|
||||
echo "APR configure failed"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# 安装 APR-util
|
||||
@@ -88,15 +91,18 @@ Install_App()
|
||||
cd ${apacheDir}/apr-util-${APR_UTIL_VERSION} && ./configure --prefix=${serverPath}/apache/apr-util --with-apr=${serverPath}/apache/apr
|
||||
make -j${cpuCore} && make install
|
||||
if [ "$?" == "0" ];then
|
||||
if [ ! -f ${serverPath}/apache/apr-util/bin/apu-1-config ];then
|
||||
echo "APR-util installation failed: apu-config not found"
|
||||
find ${serverPath}/apache/apr-util -name "apu-config"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "APR-util configure failed"
|
||||
exit 1
|
||||
fi
|
||||
# 检查 APR-util 配置文件
|
||||
APU_CONFIG=$(find ${serverPath}/apache/apr-util -name "apu-*config" | head -1)
|
||||
if [ -z "$APU_CONFIG" ];then
|
||||
echo "APR-util installation failed: apu-config not found"
|
||||
find ${serverPath}/apache/apr-util -name "apu-*config"
|
||||
exit 1
|
||||
fi
|
||||
echo "APR-util installed successfully: $APU_CONFIG"
|
||||
else
|
||||
echo "APR-util configure failed"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -f ${apacheDir}/httpd-${VERSION}.tar.bz2 ];then
|
||||
@@ -109,15 +115,28 @@ Install_App()
|
||||
|
||||
|
||||
# 检查 APR 和 APR-util 可执行文件
|
||||
APR_CONFIG=$(find ${serverPath}/apache/apr -name "apr-1-config" | head -1)
|
||||
APU_CONFIG=$(find ${serverPath}/apache/apr-util -name "apu-1-config" | head -1)
|
||||
APR_CONFIG=$(find ${serverPath}/apache/apr -name "apr-*config" | head -1)
|
||||
APU_CONFIG=$(find ${serverPath}/apache/apr-util -name "apu-*config" | head -1)
|
||||
|
||||
if [ -z "$APR_CONFIG" ];then
|
||||
echo "APR config not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$APU_CONFIG" ];then
|
||||
echo "APR-util config not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Using APR config: $APR_CONFIG"
|
||||
echo "Using APR-util config: $APU_CONFIG"
|
||||
|
||||
OPTIONS="${OPTIONS} --with-apr=$APR_CONFIG"
|
||||
OPTIONS="${OPTIONS} --with-apr-util=$APU_CONFIG"
|
||||
|
||||
# echo "cd ${apacheDir}/httpd-${VERSION} && ./configure --prefix=$serverPath/apache $OPTIONS"
|
||||
cd ${apacheDir}/httpd-${VERSION} && ./configure \
|
||||
--prefix=$serverPath/apache/httpd \
|
||||
--prefix=$serverPath/apache \
|
||||
$OPTIONS
|
||||
|
||||
make -j${cpuCore} && make install && make clean
|
||||
|
||||
Reference in New Issue
Block a user