perf: 优化构建层级
This commit is contained in:
		
							parent
							
								
									6895daf9f1
								
							
						
					
					
						commit
						f17291148b
					
				
							
								
								
									
										99
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										99
									
								
								Dockerfile
									
									
									
									
									
								
							| @ -1,13 +1,9 @@ | |||||||
| FROM debian:bookworm | FROM debian:bookworm | ||||||
| 
 | 
 | ||||||
| # 切换 Debian 镜像源为腾讯云源 | # 切换 Debian 镜像源为腾讯云源,更新包列表并安装依赖 | ||||||
| RUN sed -i 's/deb.debian.org/mirrors.tencent.com/g' /etc/apt/sources.list.d/debian.sources | RUN sed -i 's/deb.debian.org/mirrors.tencent.com/g' /etc/apt/sources.list.d/debian.sources \ | ||||||
| 
 |     && apt update && apt upgrade -y \ | ||||||
| # 更新包列表并升级系统中已经安装的软件包 |     && apt install -y \ | ||||||
| RUN apt update && apt upgrade -y |  | ||||||
| 
 |  | ||||||
| # 安装前置依赖 |  | ||||||
| RUN apt install -y \ |  | ||||||
|     locales \ |     locales \ | ||||||
|     wget iproute2 openssh-server libgd-dev cmake make gcc g++ autoconf \ |     wget iproute2 openssh-server libgd-dev cmake make gcc g++ autoconf \ | ||||||
|     libsodium-dev libonig-dev libssh2-1-dev libc-ares-dev libaio-dev sudo curl dos2unix \ |     libsodium-dev libonig-dev libssh2-1-dev libc-ares-dev libaio-dev sudo curl dos2unix \ | ||||||
| @ -15,79 +11,46 @@ RUN apt install -y \ | |||||||
|     diffutils unzip tar libbz2-dev libncurses5 libncurses5-dev libtool libevent-dev libssl-dev libsasl2-dev \ |     diffutils unzip tar libbz2-dev libncurses5 libncurses5-dev libtool libevent-dev libssl-dev libsasl2-dev \ | ||||||
|     libltdl-dev zlib1g-dev libglib2.0-0 libglib2.0-dev libkrb5-dev libpq-dev libpq5 gettext libcap-dev \ |     libltdl-dev zlib1g-dev libglib2.0-0 libglib2.0-dev libkrb5-dev libpq-dev libpq5 gettext libcap-dev \ | ||||||
|     libc-client2007e-dev psmisc patch git e2fsprogs libxslt1-dev xz-utils libgd3 libwebp-dev libvpx-dev \ |     libc-client2007e-dev psmisc patch git e2fsprogs libxslt1-dev xz-utils libgd3 libwebp-dev libvpx-dev \ | ||||||
|     libfreetype6-dev libjpeg62-turbo libjpeg62-turbo-dev iptables |     libfreetype6-dev libjpeg62-turbo libjpeg62-turbo-dev iptables libudev-dev libldap2-dev \ | ||||||
| # 配置区域设置 |     && apt clean \ | ||||||
| RUN locale-gen en_US.UTF-8 |     && rm -rf /var/lib/apt/lists/*  | ||||||
| 
 | 
 | ||||||
| ENV LANG en_US.UTF-8 | # 复制脚本 | ||||||
| ENV LANGUAGE en_US:en | COPY ["bt.sh", "init_mysql.sh", "/"] | ||||||
| ENV LC_ALL en_US.UTF-8 | COPY ["phpmyadmin.sh", "/lnmp/"] | ||||||
| ENV LC_CTYPE en_US.UTF-8 |  | ||||||
| 
 |  | ||||||
| # 复制启动脚本 |  | ||||||
| COPY bt.sh /bt.sh |  | ||||||
| COPY init_mysql.sh /init_mysql.sh |  | ||||||
| 
 | 
 | ||||||
| # 转换启动脚本 | # 转换启动脚本 | ||||||
| RUN dos2unix /bt.sh | RUN dos2unix /bt.sh && dos2unix /init_mysql.sh | ||||||
| RUN dos2unix /init_mysql.sh |  | ||||||
| 
 | 
 | ||||||
| # 设置构建参数 | # 下载并安装宝塔面板及 lnmp 环境 | ||||||
| ARG RANDOM_NAME |  | ||||||
| 
 |  | ||||||
| # 设置一个btd12-前缀的随机主机名 |  | ||||||
| RUN echo "btd12-${RANDOM_NAME}" > /etc/hostname |  | ||||||
| 
 |  | ||||||
| # 下载并安装宝塔面板 |  | ||||||
| RUN curl -sSO https://download.bt.cn/install/install_panel.sh \ | RUN curl -sSO https://download.bt.cn/install/install_panel.sh \ | ||||||
|     && echo y | bash install_panel.sh -P 8888 --ssl-disable |     && echo y | bash install_panel.sh -P 8888 --ssl-disable \ | ||||||
| 
 |     && curl -o /lnmp/nginx.sh https://download.bt.cn/install/3/nginx.sh \ | ||||||
| # 安装 lnmp 环境 |     && sh /lnmp/nginx.sh install 1.27 \  | ||||||
| # 创建目录 |     && curl -o /lnmp/php.sh https://download.bt.cn/install/4/php.sh \ | ||||||
| RUN mkdir -p /lnmp |     && sh /lnmp/php.sh install 8.3 \ | ||||||
| 
 |     && curl -o /lnmp/mysql.sh https://download.bt.cn/install/4/mysql.sh \ | ||||||
| # 安装 lnmp 环境 |     && sh /lnmp/mysql.sh install 8.0 \ | ||||||
| # 创建目录 |     && sh /lnmp/phpmyadmin.sh install 5.2 \ | ||||||
| RUN mkdir -p /lnmp |     && rm -rf /lnmp \ | ||||||
| 
 |  | ||||||
| # 安装 Nginx 1.27 |  | ||||||
| RUN curl -o /lnmp/nginx.sh https://download.bt.cn/install/3/nginx.sh \ |  | ||||||
|     && sh /lnmp/nginx.sh install 1.27 |  | ||||||
| 
 |  | ||||||
| # 安装 PHP 8.3 |  | ||||||
| RUN curl -o /lnmp/php.sh https://download.bt.cn/install/4/php.sh \ |  | ||||||
|     && sh /lnmp/php.sh install 8.3 |  | ||||||
| 
 |  | ||||||
| # 安装 MySQL 8.0 |  | ||||||
| RUN curl -o /lnmp/mysql.sh https://download.bt.cn/install/4/mysql.sh \ |  | ||||||
|     && sh /lnmp/mysql.sh install 8.0 |  | ||||||
| 
 |  | ||||||
| # 清理安装包 |  | ||||||
| RUN rm -rf /lnmp \ |  | ||||||
|     && rm -rf /www/server/php/83/src \ |     && rm -rf /www/server/php/83/src \ | ||||||
|     && rm -rf /www/server/mysql/mysql-test \ |     && rm -rf /www/server/mysql/mysql-test \ | ||||||
|     && rm -rf /www/server/mysql/src.tar.gz \ |     && rm -rf /www/server/mysql/src.tar.gz \ | ||||||
|     && rm -rf /www/server/mysql/src \ |     && rm -rf /www/server/mysql/src \ | ||||||
|     && rm -rf /www/server/data/* \ |     && rm -rf /www/server/data/* \ | ||||||
|     && rm -rf /www/server/nginx/src |     && rm -rf /www/server/nginx/src \ | ||||||
|  |     && echo "docker_btlnmp_d12" > /www/server/panel/data/o.pl \ | ||||||
|  |     && apt clean \ | ||||||
|  |     && rm -rf /var/lib/apt/lists/* \ | ||||||
|  |     && chmod +x /bt.sh \ | ||||||
|  |     && chmod +x /init_mysql.sh | ||||||
|      |      | ||||||
| # 配置宝塔面板安全入口和用户名及密码 | 
 | ||||||
|  | # 配置宝塔面板安全入口和用户名及密码,以及 SSH 密码 | ||||||
| RUN echo btpanel | bt 6 \ | RUN echo btpanel | bt 6 \ | ||||||
|     && echo btpaneldocker | bt 5 \ |     && echo btpaneldocker | bt 5 \ | ||||||
|     && echo "/btpanel" > /www/server/panel/data/admin_path.pl |     && echo "/btpanel" > /www/server/panel/data/admin_path.pl \ | ||||||
| 
 |     && echo "root:btpaneldocker" | chpasswd | ||||||
| # 设置 root 用户密码 |  | ||||||
| RUN echo "root:btpaneldocker" | chpasswd |  | ||||||
| 
 |  | ||||||
| # 赋予 bt.sh 可执行权限 |  | ||||||
| RUN chmod +x /bt.sh |  | ||||||
| 
 |  | ||||||
| # 清理缓存 |  | ||||||
| RUN apt clean \ |  | ||||||
|     && rm -rf /var/lib/apt/lists/* |  | ||||||
| 
 |  | ||||||
| # 设置标识文件 |  | ||||||
| RUN echo "docker_btlnmp_d12" > /www/server/panel/data/o.pl |  | ||||||
| 
 | 
 | ||||||
| ENTRYPOINT ["/bin/sh","-c","/bt.sh"] | ENTRYPOINT ["/bin/sh","-c","/bt.sh"] | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										100
									
								
								arm64/Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										100
									
								
								arm64/Dockerfile
									
									
									
									
									
								
							| @ -1,13 +1,9 @@ | |||||||
| FROM debian:bookworm | FROM debian:bookworm | ||||||
| 
 | 
 | ||||||
| # 切换 Debian 镜像源为腾讯云源 | # 切换 Debian 镜像源为腾讯云源,更新包列表并安装依赖 | ||||||
| RUN sed -i 's/deb.debian.org/mirrors.tencent.com/g' /etc/apt/sources.list.d/debian.sources | RUN sed -i 's/deb.debian.org/mirrors.tencent.com/g' /etc/apt/sources.list.d/debian.sources \ | ||||||
| 
 |     && apt update && apt upgrade -y \ | ||||||
| # 更新包列表并升级系统中已经安装的软件包 |     && apt install -y \ | ||||||
| RUN apt update && apt upgrade -y |  | ||||||
| 
 |  | ||||||
| # 安装前置依赖 |  | ||||||
| RUN apt install -y \ |  | ||||||
|     locales \ |     locales \ | ||||||
|     wget iproute2 openssh-server libgd-dev cmake make gcc g++ autoconf \ |     wget iproute2 openssh-server libgd-dev cmake make gcc g++ autoconf \ | ||||||
|     libsodium-dev libonig-dev libssh2-1-dev libc-ares-dev libaio-dev sudo curl dos2unix \ |     libsodium-dev libonig-dev libssh2-1-dev libc-ares-dev libaio-dev sudo curl dos2unix \ | ||||||
| @ -15,80 +11,46 @@ RUN apt install -y \ | |||||||
|     diffutils unzip tar libbz2-dev libncurses5 libncurses5-dev libtool libevent-dev libssl-dev libsasl2-dev \ |     diffutils unzip tar libbz2-dev libncurses5 libncurses5-dev libtool libevent-dev libssl-dev libsasl2-dev \ | ||||||
|     libltdl-dev zlib1g-dev libglib2.0-0 libglib2.0-dev libkrb5-dev libpq-dev libpq5 gettext libcap-dev \ |     libltdl-dev zlib1g-dev libglib2.0-0 libglib2.0-dev libkrb5-dev libpq-dev libpq5 gettext libcap-dev \ | ||||||
|     libc-client2007e-dev psmisc patch git e2fsprogs libxslt1-dev xz-utils libgd3 libwebp-dev libvpx-dev \ |     libc-client2007e-dev psmisc patch git e2fsprogs libxslt1-dev xz-utils libgd3 libwebp-dev libvpx-dev \ | ||||||
|     libfreetype6-dev libjpeg62-turbo libjpeg62-turbo-dev iptables libudev-dev libldap2-dev |     libfreetype6-dev libjpeg62-turbo libjpeg62-turbo-dev iptables libudev-dev libldap2-dev \ | ||||||
|  |     && apt clean \ | ||||||
|  |     && rm -rf /var/lib/apt/lists/*  | ||||||
| 
 | 
 | ||||||
| # 配置区域设置 | # 复制脚本 | ||||||
| RUN locale-gen en_US.UTF-8 \ | COPY ["bt.sh", "init_mysql.sh", "/"] | ||||||
|     && export LANG=en_US.UTF-8 \ | COPY ["phpmyadmin.sh", "/lnmp/"] | ||||||
|     && export LANGUAGE=en_US:en \ |  | ||||||
|     && export LC_ALL=en_US.UTF-8 \ |  | ||||||
|     && export LC_CTYPE=en_US.UTF-8 \ |  | ||||||
|     && update-locale |  | ||||||
| 
 |  | ||||||
| # 复制启动脚本 |  | ||||||
| COPY bt.sh /bt.sh |  | ||||||
| COPY init_mysql.sh /init_mysql.sh |  | ||||||
| 
 | 
 | ||||||
| # 转换启动脚本 | # 转换启动脚本 | ||||||
| RUN dos2unix /bt.sh | RUN dos2unix /bt.sh && dos2unix /init_mysql.sh | ||||||
| RUN dos2unix /init_mysql.sh |  | ||||||
| 
 | 
 | ||||||
| # 设置构建参数 | # 下载并安装宝塔面板及 lnmp 环境 | ||||||
| ARG RANDOM_NAME |  | ||||||
| 
 |  | ||||||
| # 设置一个btd12-前缀的随机主机名 |  | ||||||
| RUN echo "btd12-${RANDOM_NAME}" > /etc/hostname |  | ||||||
| 
 |  | ||||||
| # 下载并安装宝塔面板 |  | ||||||
| RUN curl -sSO https://download.bt.cn/install/install_panel.sh \ | RUN curl -sSO https://download.bt.cn/install/install_panel.sh \ | ||||||
|     && echo y | bash install_panel.sh -P 8888 --ssl-disable |     && echo y | bash install_panel.sh -P 8888 --ssl-disable \ | ||||||
| 
 |     && curl -o /lnmp/nginx.sh https://download.bt.cn/install/3/nginx.sh \ | ||||||
| # 安装 lnmp 环境 |     && sh /lnmp/nginx.sh install openresty \  | ||||||
| # 创建目录 |     && curl -o /lnmp/php.sh https://download.bt.cn/install/4/php.sh \ | ||||||
| RUN mkdir -p /lnmp |     && sh /lnmp/php.sh install 8.3 \ | ||||||
| 
 |     && curl -o /lnmp/mysql.sh https://download.bt.cn/install/4/mysql.sh \ | ||||||
| # 安装 lnmp 环境 |     && sh /lnmp/mysql.sh install 8.0 \ | ||||||
| # 创建目录 |     && sh /lnmp/phpmyadmin.sh install 5.2 \ | ||||||
| RUN mkdir -p /lnmp |     && rm -rf /lnmp \ | ||||||
| 
 |  | ||||||
| # 安装 Nginx 1.27 |  | ||||||
| RUN curl -o /lnmp/nginx.sh https://download.bt.cn/install/3/nginx.sh \ |  | ||||||
|     && sh /lnmp/nginx.sh install openresty |  | ||||||
| 
 |  | ||||||
| # 安装 PHP 8.3 |  | ||||||
| RUN curl -o /lnmp/php.sh https://download.bt.cn/install/4/php.sh \ |  | ||||||
|     && sh /lnmp/php.sh install 8.3 |  | ||||||
| 
 |  | ||||||
| # 安装 MySQL 8.0 |  | ||||||
| RUN curl -o /lnmp/mysql.sh https://download.bt.cn/install/4/mysql.sh \ |  | ||||||
|     && sh /lnmp/mysql.sh install 8.0 |  | ||||||
| 
 |  | ||||||
| # 清理安装包 |  | ||||||
| RUN rm -rf /lnmp \ |  | ||||||
|     && rm -rf /www/server/php/83/src \ |     && rm -rf /www/server/php/83/src \ | ||||||
|     && rm -rf /www/server/mysql/mysql-test \ |     && rm -rf /www/server/mysql/mysql-test \ | ||||||
|     && rm -rf /www/server/mysql/src.tar.gz \ |     && rm -rf /www/server/mysql/src.tar.gz \ | ||||||
|     && rm -rf /www/server/mysql/src \ |     && rm -rf /www/server/mysql/src \ | ||||||
|  |     && rm -rf /www/server/data/* \ | ||||||
|     && rm -rf /www/server/nginx/src \ |     && rm -rf /www/server/nginx/src \ | ||||||
|     && rm -rf /www/server/data/* |     && echo "docker_btlnmp_d12" > /www/server/panel/data/o.pl \ | ||||||
|  |     && apt clean \ | ||||||
|  |     && rm -rf /var/lib/apt/lists/* \ | ||||||
|  |     && chmod +x /bt.sh \ | ||||||
|  |     && chmod +x /init_mysql.sh | ||||||
|      |      | ||||||
| # 配置宝塔面板安全入口和用户名及密码 | 
 | ||||||
|  | # 配置宝塔面板安全入口和用户名及密码,以及 SSH 密码 | ||||||
| RUN echo btpanel | bt 6 \ | RUN echo btpanel | bt 6 \ | ||||||
|     && echo btpaneldocker | bt 5 \ |     && echo btpaneldocker | bt 5 \ | ||||||
|     && echo "/btpanel" > /www/server/panel/data/admin_path.pl |     && echo "/btpanel" > /www/server/panel/data/admin_path.pl \ | ||||||
| 
 |     && echo "root:btpaneldocker" | chpasswd | ||||||
| # 设置 root 用户密码 |  | ||||||
| RUN echo "root:btpaneldocker" | chpasswd |  | ||||||
| 
 |  | ||||||
| # 赋予 bt.sh 可执行权限 |  | ||||||
| RUN chmod +x /bt.sh |  | ||||||
| 
 |  | ||||||
| # 清理缓存 |  | ||||||
| RUN apt clean \ |  | ||||||
|     && rm -rf /var/lib/apt/lists/* |  | ||||||
| 
 |  | ||||||
| # 设置标识文件 |  | ||||||
| RUN echo "docker_btlnmp_d12" > /www/server/panel/data/o.pl |  | ||||||
| 
 | 
 | ||||||
| ENTRYPOINT ["/bin/sh","-c","/bt.sh"] | ENTRYPOINT ["/bin/sh","-c","/bt.sh"] | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										108
									
								
								arm64/phpmyadmin.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										108
									
								
								arm64/phpmyadmin.sh
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,108 @@ | |||||||
|  | #!/bin/bash | ||||||
|  | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin | ||||||
|  | export PATH | ||||||
|  | 
 | ||||||
|  | public_file=/www/server/panel/install/public.sh | ||||||
|  | if [ ! -f $public_file ];then | ||||||
|  | 	wget -O $public_file https://download.bt.cn/install/public.sh -T 5; | ||||||
|  | fi | ||||||
|  | . $public_file | ||||||
|  | 
 | ||||||
|  | download_Url=$NODE_URL | ||||||
|  | Root_Path=`cat /var/bt_setupPath.conf` | ||||||
|  | Setup_Path=$Root_Path/server/phpmyadmin | ||||||
|  | webserver="" | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | Install_phpMyAdmin() | ||||||
|  | { | ||||||
|  | 	if [ -d "${Root_Path}/server/apache"  ];then | ||||||
|  | 		webserver='apache' | ||||||
|  | 	elif [ -d "${Root_Path}/server/nginx"  ];then | ||||||
|  | 		webserver='nginx' | ||||||
|  | 	elif [ -f "/usr/local/lsws/bin/lswsctrl" ];then | ||||||
|  | 		webserver='openlitespeed' | ||||||
|  | 	fi | ||||||
|  | 
 | ||||||
|  | 	if [ "${webserver}" == "" ];then | ||||||
|  | 		echo "No Web server installed!" | ||||||
|  | 		exit 0; | ||||||
|  | 	fi | ||||||
|  | 	 | ||||||
|  |     PHPVersion="" | ||||||
|  | 	for phpVer in 52 53 54 55 56 70 71 72 73 74 80 81 82 83; | ||||||
|  | 	do | ||||||
|  | 		if [ -d "/www/server/php/${phpVer}/bin" ]; then | ||||||
|  | 			PHPVersion=${phpVer} | ||||||
|  | 		fi | ||||||
|  | 	done | ||||||
|  | 	 | ||||||
|  | 	if [ -z $PHPVersion ];then | ||||||
|  | 	    echo "======================================" | ||||||
|  | 	    echo "当前没有可用php,停止安装!" | ||||||
|  | 	    echo "请先安装好php后再进行安装phpmyadmin!" | ||||||
|  | 	    exit 1; | ||||||
|  | 	fi | ||||||
|  | 	 | ||||||
|  | 	wget -O phpMyAdmin.zip $download_Url/src/phpMyAdmin-${1}.zip -T20 | ||||||
|  | 	mkdir -p $Setup_Path | ||||||
|  | 
 | ||||||
|  | 	unzip -o phpMyAdmin.zip -d $Setup_Path/ > /dev/null | ||||||
|  | 	rm -f phpMyAdmin.zip | ||||||
|  | 	rm -rf $Root_Path/server/phpmyadmin/phpmyadmin* | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	phpmyadminExt=`cat /dev/urandom | head -n 32 | md5sum | head -c 16`; | ||||||
|  | 	mv $Setup_Path/databaseAdmin $Setup_Path/phpmyadmin_$phpmyadminExt | ||||||
|  | 	chmod -R 755 $Setup_Path/phpmyadmin_$phpmyadminExt | ||||||
|  | 	chown -R www.www $Setup_Path/phpmyadmin_$phpmyadminExt | ||||||
|  | 	chmod 755 /www/server/phpmyadmin | ||||||
|  | 	 | ||||||
|  | 	secret=`cat /dev/urandom | head -n 32 | md5sum | head -c 32`; | ||||||
|  | 	\cp -a -r $Setup_Path/phpmyadmin_$phpmyadminExt/config.sample.inc.php  $Setup_Path/phpmyadmin_$phpmyadminExt/config.inc.php | ||||||
|  | 	sed -i "s#^\$cfg\['blowfish_secret'\].*#\$cfg\['blowfish_secret'\] = '${secret}';#" $Setup_Path/phpmyadmin_$phpmyadminExt/config.inc.php | ||||||
|  | 	sed -i "s#^\$cfg\['blowfish_secret'\].*#\$cfg\['blowfish_secret'\] = '${secret}';#" $Setup_Path/phpmyadmin_$phpmyadminExt/libraries/config.default.php | ||||||
|  | 	 | ||||||
|  | 	echo $1 > $Setup_Path/version.pl | ||||||
|  | 	 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 	if [ "${webserver}" == "nginx" ];then | ||||||
|  | 		sed -i "s#$Root_Path/wwwroot/default#$Root_Path/server/phpmyadmin#" $Root_Path/server/nginx/conf/nginx.conf | ||||||
|  | 		rm -f $Root_Path/server/nginx/conf/enable-php.conf | ||||||
|  | 		\cp $Root_Path/server/nginx/conf/enable-php-$PHPVersion.conf $Root_Path/server/nginx/conf/enable-php.conf | ||||||
|  | 		sed -i "/pathinfo/d" $Root_Path/server/nginx/conf/enable-php.conf | ||||||
|  | 		if [ ! -f "/www/server/nginx/conf/enable-php.conf" ];then | ||||||
|  |             touch /www/server/nginx/conf/enable-php.conf | ||||||
|  | 		fi | ||||||
|  | 		/etc/init.d/nginx reload | ||||||
|  | 		 | ||||||
|  | 		PMA_PORT=$(cat $Root_Path/server/nginx/conf/nginx.conf|grep "listen "|grep -oE '[0-9]+') | ||||||
|  | 	else | ||||||
|  | 		sed -i "s#$Root_Path/wwwroot/default#$Root_Path/server/phpmyadmin#" $Root_Path/server/apache/conf/extra/httpd-vhosts.conf | ||||||
|  | 		sed -i "0,/php-cgi/ s/php-cgi-\w*\.sock/php-cgi-${PHPVersion}.sock/" $Root_Path/server/apache/conf/extra/httpd-vhosts.conf | ||||||
|  | 		/etc/init.d/httpd reload | ||||||
|  | 		 | ||||||
|  | 		PMA_PORT=$(cat /www/server/apache/conf/extra/httpd-vhosts.conf |grep "Listen "|grep -oE '[0-9]+') | ||||||
|  | 	fi | ||||||
|  | 	 | ||||||
|  | 	echo ${PMA_PORT} > /www/server/phpmyadmin/port.pl | ||||||
|  | 	 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | Uninstall_phpMyAdmin() | ||||||
|  | { | ||||||
|  | 	rm -rf $Root_Path/server/phpmyadmin/phpmyadmin* | ||||||
|  | 	rm -f $Root_Path/server/phpmyadmin/version.pl | ||||||
|  | 	rm -f $Root_Path/server/phpmyadmin/version_check.pl | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | actionType=$1 | ||||||
|  | version=$2 | ||||||
|  | 
 | ||||||
|  | if [ "$actionType" == 'install' ];then | ||||||
|  | 	Install_phpMyAdmin $version | ||||||
|  | elif [ "$actionType" == 'uninstall' ];then | ||||||
|  | 	Uninstall_phpMyAdmin | ||||||
|  | fi | ||||||
							
								
								
									
										108
									
								
								phpmyadmin.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										108
									
								
								phpmyadmin.sh
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,108 @@ | |||||||
|  | #!/bin/bash | ||||||
|  | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin | ||||||
|  | export PATH | ||||||
|  | 
 | ||||||
|  | public_file=/www/server/panel/install/public.sh | ||||||
|  | if [ ! -f $public_file ];then | ||||||
|  | 	wget -O $public_file https://download.bt.cn/install/public.sh -T 5; | ||||||
|  | fi | ||||||
|  | . $public_file | ||||||
|  | 
 | ||||||
|  | download_Url=$NODE_URL | ||||||
|  | Root_Path=`cat /var/bt_setupPath.conf` | ||||||
|  | Setup_Path=$Root_Path/server/phpmyadmin | ||||||
|  | webserver="" | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | Install_phpMyAdmin() | ||||||
|  | { | ||||||
|  | 	if [ -d "${Root_Path}/server/apache"  ];then | ||||||
|  | 		webserver='apache' | ||||||
|  | 	elif [ -d "${Root_Path}/server/nginx"  ];then | ||||||
|  | 		webserver='nginx' | ||||||
|  | 	elif [ -f "/usr/local/lsws/bin/lswsctrl" ];then | ||||||
|  | 		webserver='openlitespeed' | ||||||
|  | 	fi | ||||||
|  | 
 | ||||||
|  | 	if [ "${webserver}" == "" ];then | ||||||
|  | 		echo "No Web server installed!" | ||||||
|  | 		exit 0; | ||||||
|  | 	fi | ||||||
|  | 	 | ||||||
|  |     PHPVersion="" | ||||||
|  | 	for phpVer in 52 53 54 55 56 70 71 72 73 74 80 81 82 83; | ||||||
|  | 	do | ||||||
|  | 		if [ -d "/www/server/php/${phpVer}/bin" ]; then | ||||||
|  | 			PHPVersion=${phpVer} | ||||||
|  | 		fi | ||||||
|  | 	done | ||||||
|  | 	 | ||||||
|  | 	if [ -z $PHPVersion ];then | ||||||
|  | 	    echo "======================================" | ||||||
|  | 	    echo "当前没有可用php,停止安装!" | ||||||
|  | 	    echo "请先安装好php后再进行安装phpmyadmin!" | ||||||
|  | 	    exit 1; | ||||||
|  | 	fi | ||||||
|  | 	 | ||||||
|  | 	wget -O phpMyAdmin.zip $download_Url/src/phpMyAdmin-${1}.zip -T20 | ||||||
|  | 	mkdir -p $Setup_Path | ||||||
|  | 
 | ||||||
|  | 	unzip -o phpMyAdmin.zip -d $Setup_Path/ > /dev/null | ||||||
|  | 	rm -f phpMyAdmin.zip | ||||||
|  | 	rm -rf $Root_Path/server/phpmyadmin/phpmyadmin* | ||||||
|  | 	 | ||||||
|  | 	 | ||||||
|  | 	phpmyadminExt=`cat /dev/urandom | head -n 32 | md5sum | head -c 16`; | ||||||
|  | 	mv $Setup_Path/databaseAdmin $Setup_Path/phpmyadmin_$phpmyadminExt | ||||||
|  | 	chmod -R 755 $Setup_Path/phpmyadmin_$phpmyadminExt | ||||||
|  | 	chown -R www.www $Setup_Path/phpmyadmin_$phpmyadminExt | ||||||
|  | 	chmod 755 /www/server/phpmyadmin | ||||||
|  | 	 | ||||||
|  | 	secret=`cat /dev/urandom | head -n 32 | md5sum | head -c 32`; | ||||||
|  | 	\cp -a -r $Setup_Path/phpmyadmin_$phpmyadminExt/config.sample.inc.php  $Setup_Path/phpmyadmin_$phpmyadminExt/config.inc.php | ||||||
|  | 	sed -i "s#^\$cfg\['blowfish_secret'\].*#\$cfg\['blowfish_secret'\] = '${secret}';#" $Setup_Path/phpmyadmin_$phpmyadminExt/config.inc.php | ||||||
|  | 	sed -i "s#^\$cfg\['blowfish_secret'\].*#\$cfg\['blowfish_secret'\] = '${secret}';#" $Setup_Path/phpmyadmin_$phpmyadminExt/libraries/config.default.php | ||||||
|  | 	 | ||||||
|  | 	echo $1 > $Setup_Path/version.pl | ||||||
|  | 	 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 	if [ "${webserver}" == "nginx" ];then | ||||||
|  | 		sed -i "s#$Root_Path/wwwroot/default#$Root_Path/server/phpmyadmin#" $Root_Path/server/nginx/conf/nginx.conf | ||||||
|  | 		rm -f $Root_Path/server/nginx/conf/enable-php.conf | ||||||
|  | 		\cp $Root_Path/server/nginx/conf/enable-php-$PHPVersion.conf $Root_Path/server/nginx/conf/enable-php.conf | ||||||
|  | 		sed -i "/pathinfo/d" $Root_Path/server/nginx/conf/enable-php.conf | ||||||
|  | 		if [ ! -f "/www/server/nginx/conf/enable-php.conf" ];then | ||||||
|  |             touch /www/server/nginx/conf/enable-php.conf | ||||||
|  | 		fi | ||||||
|  | 		/etc/init.d/nginx reload | ||||||
|  | 		 | ||||||
|  | 		PMA_PORT=$(cat $Root_Path/server/nginx/conf/nginx.conf|grep "listen "|grep -oE '[0-9]+') | ||||||
|  | 	else | ||||||
|  | 		sed -i "s#$Root_Path/wwwroot/default#$Root_Path/server/phpmyadmin#" $Root_Path/server/apache/conf/extra/httpd-vhosts.conf | ||||||
|  | 		sed -i "0,/php-cgi/ s/php-cgi-\w*\.sock/php-cgi-${PHPVersion}.sock/" $Root_Path/server/apache/conf/extra/httpd-vhosts.conf | ||||||
|  | 		/etc/init.d/httpd reload | ||||||
|  | 		 | ||||||
|  | 		PMA_PORT=$(cat /www/server/apache/conf/extra/httpd-vhosts.conf |grep "Listen "|grep -oE '[0-9]+') | ||||||
|  | 	fi | ||||||
|  | 	 | ||||||
|  | 	echo ${PMA_PORT} > /www/server/phpmyadmin/port.pl | ||||||
|  | 	 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | Uninstall_phpMyAdmin() | ||||||
|  | { | ||||||
|  | 	rm -rf $Root_Path/server/phpmyadmin/phpmyadmin* | ||||||
|  | 	rm -f $Root_Path/server/phpmyadmin/version.pl | ||||||
|  | 	rm -f $Root_Path/server/phpmyadmin/version_check.pl | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | actionType=$1 | ||||||
|  | version=$2 | ||||||
|  | 
 | ||||||
|  | if [ "$actionType" == 'install' ];then | ||||||
|  | 	Install_phpMyAdmin $version | ||||||
|  | elif [ "$actionType" == 'uninstall' ];then | ||||||
|  | 	Uninstall_phpMyAdmin | ||||||
|  | fi | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 xiao
						xiao