Explorar el Código

feat: 增加对 PHP 8.5 和 MySQL 8.4 的支持,并为 Caddy 添加虚拟主机和 SSL 管理功能。

Sky_slience hace 3 días
padre
commit
2802a337af
Se han modificado 9 ficheros con 783 adiciones y 82 borrados
  1. 2 0
      config/Caddyfile
  2. 2 1
      include/caddy.sh
  3. 217 0
      include/mysql-8.4.sh
  4. 24 0
      include/openssl.sh
  5. 233 0
      include/php-8.5.sh
  6. 1 1
      include/upgrade_php.sh
  7. 19 18
      install.sh
  8. 48 47
      versions.txt
  9. 237 15
      vhost.sh

+ 2 - 0
config/Caddyfile

@@ -24,3 +24,5 @@
 
 # Refer to the Caddy docs for more information:
 # https://caddyserver.com/docs/caddyfile
+
+import /usr/local/caddy/conf/vhost/*.conf

+ 2 - 1
include/caddy.sh

@@ -33,8 +33,9 @@ Install_Caddy() {
   # [ ! -L "/usr/local/bin/caddy" ] && ln -s ${caddy_install_dir}/bin/caddy /usr/local/bin/caddy
 
   #move caddyfile to /usr/local/caddy/conf
-  [ ! -d "${caddy_install_dir}/conf" ] && mkdir -p ${caddy_install_dir}/conf
+  [ ! -d "${caddy_install_dir}/conf/vhost" ] && mkdir -p ${caddy_install_dir}/conf/vhost
   /bin/cp ../config/Caddyfile ${caddy_install_dir}/conf/
+  sed -i "s@/usr/local/caddy@${caddy_install_dir}@g" ${caddy_install_dir}/conf/Caddyfile
 
   #move caddy.service to /lib/systemd/system
   /bin/cp ../init.d/caddy.service /lib/systemd/system/

+ 217 - 0
include/mysql-8.4.sh

@@ -0,0 +1,217 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://linuxeye.com
+#
+# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
+#
+# Project home page:
+#       https://oneinstack.com
+#       https://github.com/oneinstack/oneinstack
+
+Install_MySQL84() {
+  pushd ${oneinstack_dir}/src > /dev/null
+  id -u mysql >/dev/null 2>&1
+  [ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql
+
+  [ ! -d "${mysql_install_dir}" ] && mkdir -p ${mysql_install_dir}
+  mkdir -p ${mysql_data_dir};chown mysql:mysql -R ${mysql_data_dir}
+
+  if [ "${dbinstallmethod}" == "1" ]; then
+    tar xJf mysql-${mysql84_ver}-linux-glibc2.17-x86_64.tar.xz
+    mv mysql-${mysql84_ver}-linux-glibc2.17-x88_64/* ${mysql_install_dir}
+    sed -i "s@/usr/local/mysql@${mysql_install_dir}@g" ${mysql_install_dir}/bin/mysqld_safe
+  elif [ "${dbinstallmethod}" == "2" ]; then
+    boostVersion2=$(echo ${boost_ver} | awk -F. '{print $1"_"$2"_"$3}')
+    tar xzf boost_${boostVersion2}.tar.gz
+    tar xzf mysql-${mysql84_ver}.tar.gz
+    pushd mysql-${mysql84_ver}
+    [ -e "/usr/bin/cmake3" ] && CMAKE=cmake3 || CMAKE=cmake
+    $CMAKE . -DCMAKE_INSTALL_PREFIX=${mysql_install_dir} \
+    -DMYSQL_DATADIR=${mysql_data_dir} \
+    -DDOWNLOAD_BOOST=1 \
+    -DWITH_BOOST=../boost_${boostVersion2} \
+    -DFORCE_INSOURCE_BUILD=1 \
+    -DSYSCONFDIR=/etc \
+    -DWITH_INNOBASE_STORAGE_ENGINE=1 \
+    -DWITH_FEDERATED_STORAGE_ENGINE=1 \
+    -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
+    -DWITH_MYISAM_STORAGE_ENGINE=1 \
+    -DENABLED_LOCAL_INFILE=1 \
+    -DFORCE_INSOURCE_BUILD=1 \
+    -DCMAKE_C_COMPILER=/usr/bin/gcc \
+    -DCMAKE_CXX_COMPILER=/usr/bin/g++ \
+    -DDEFAULT_CHARSET=utf8mb4
+    make -j ${THREAD}
+    make install
+    popd
+  fi
+
+  if [ -d "${mysql_install_dir}/support-files" ]; then
+    sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mysql_install_dir}/bin/mysqld_safe
+    sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../options.conf
+    echo "${CSUCCESS}MySQL installed successfully! ${CEND}"
+    if [ "${dbinstallmethod}" == "1" ]; then
+      rm -rf mysql-${mysql84_ver}-*-x86_64
+    elif [ "${dbinstallmethod}" == "2" ]; then
+      rm -rf mysql-${mysql84_ver} boost_${boostVersion2}
+    fi
+  else
+    rm -rf ${mysql_install_dir}
+    echo "${CFAILURE}MySQL install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
+    kill -9 $$; exit 1;
+  fi
+
+  /bin/cp ${mysql_install_dir}/support-files/mysql.server /etc/init.d/mysqld
+  sed -i "s@^basedir=.*@basedir=${mysql_install_dir}@" /etc/init.d/mysqld
+  sed -i "s@^datadir=.*@datadir=${mysql_data_dir}@" /etc/init.d/mysqld
+  chmod +x /etc/init.d/mysqld
+  [ "${PM}" == 'yum' ] && { chkconfig --add mysqld; chkconfig mysqld on; }
+  [ "${PM}" == 'apt-get' ] && update-rc.d mysqld defaults
+  popd
+
+  # my.cnf
+  cat > /etc/my.cnf << EOF
+[client]
+port = 3306
+socket = /tmp/mysql.sock
+default-character-set = utf8mb4
+
+[mysql]
+prompt="MySQL [\\d]> "
+no-auto-rehash
+
+[mysqld]
+port = 3306
+socket = /tmp/mysql.sock
+# In MySQL 8.4, mysql_native_password is deprecated but still available if needed.
+# default_authentication_plugin = mysql_native_password
+
+basedir = ${mysql_install_dir}
+datadir = ${mysql_data_dir}
+pid-file = ${mysql_data_dir}/mysql.pid
+user = mysql
+bind-address = 0.0.0.0
+server-id = 1
+
+init-connect = 'SET NAMES utf8mb4'
+character-set-server = utf8mb4
+collation-server = utf8mb4_0900_ai_ci
+
+skip-name-resolve
+#skip-networking
+back_log = 300
+
+max_connections = 1000
+max_connect_errors = 6000
+open_files_limit = 65535
+table_open_cache = 128
+max_allowed_packet = 500M
+binlog_cache_size = 1M
+max_heap_table_size = 8M
+tmp_table_size = 16M
+
+read_buffer_size = 2M
+read_rnd_buffer_size = 8M
+sort_buffer_size = 8M
+join_buffer_size = 8M
+key_buffer_size = 4M
+
+thread_cache_size = 8
+
+ft_min_word_len = 4
+
+log_bin = mysql-bin
+binlog_format = mixed
+binlog_expire_logs_seconds = 604800
+
+log_error = ${mysql_data_dir}/mysql-error.log
+slow_query_log = 1
+long_query_time = 1
+slow_query_log_file = ${mysql_data_dir}/mysql-slow.log
+
+performance_schema = 0
+explicit_defaults_for_timestamp
+
+#lower_case_table_names = 1
+
+skip-external-locking
+
+default_storage_engine = InnoDB
+#default-storage-engine = MyISAM
+innodb_file_per_table = 1
+innodb_open_files = 500
+innodb_buffer_pool_size = 64M
+innodb_write_io_threads = 4
+innodb_read_io_threads = 4
+innodb_thread_concurrency = 0
+innodb_purge_threads = 1
+innodb_flush_log_at_trx_commit = 2
+innodb_log_buffer_size = 2M
+innodb_log_file_size = 32M
+innodb_log_files_in_group = 3
+innodb_max_dirty_pages_pct = 90
+innodb_lock_wait_timeout = 120
+
+bulk_insert_buffer_size = 8M
+myisam_sort_buffer_size = 8M
+myisam_max_sort_file_size = 10G
+
+interactive_timeout = 28800
+wait_timeout = 28800
+
+[mysqldump]
+quick
+max_allowed_packet = 500M
+
+[myisamchk]
+key_buffer_size = 8M
+sort_buffer_size = 8M
+read_buffer = 4M
+write_buffer = 4M
+EOF
+
+  sed -i "s@max_connections.*@max_connections = $((${Mem}/3))@" /etc/my.cnf
+  if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ]; then
+    sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
+    sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
+    sed -i 's@^key_buffer_size.*@key_buffer_size = 16M@' /etc/my.cnf
+    sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
+    sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
+    sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
+  elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ]; then
+    sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
+    sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
+    sed -i 's@^key_buffer_size.*@key_buffer_size = 64M@' /etc/my.cnf
+    sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
+    sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
+    sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
+  elif [ ${Mem} -gt 3500 ]; then
+    sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
+    sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
+    sed -i 's@^key_buffer_size.*@key_buffer_size = 256M@' /etc/my.cnf
+    sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 1024M@' /etc/my.cnf
+    sed -i 's@^tmp_table_size.*@tmp_table_size = 128M@' /etc/my.cnf
+    sed -i 's@^table_open_cache.*@table_open_cache = 1024@' /etc/my.cnf
+  fi
+
+  ${mysql_install_dir}/bin/mysqld --initialize-insecure --user=mysql --basedir=${mysql_install_dir} --datadir=${mysql_data_dir}
+
+  [ "${Wsl}" == true ] && chmod 600 /etc/my.cnf
+  chown mysql:mysql -R ${mysql_data_dir}
+  [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
+  service mysqld start
+  [ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${mysql_install_dir}/bin:\$PATH" >> /etc/profile
+  [ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${mysql_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${mysql_install_dir}/bin:\1@" /etc/profile
+  . /etc/profile
+
+  ${mysql_install_dir}/bin/mysql -uroot -hlocalhost -e "create user root@'127.0.0.1' identified by \"${dbrootpwd}\";"
+  ${mysql_install_dir}/bin/mysql -uroot -hlocalhost -e "grant all privileges on *.* to root@'127.0.0.1' with grant option;"
+  ${mysql_install_dir}/bin/mysql -uroot -hlocalhost -e "grant all privileges on *.* to root@'localhost' with grant option;"
+  ${mysql_install_dir}/bin/mysql -uroot -hlocalhost -e "alter user root@'localhost' identified by \"${dbrootpwd}\";"
+  ${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;"
+  rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf
+  [ -e "${mysql_install_dir}/my.cnf" ] && rm -f ${mysql_install_dir}/my.cnf
+  echo "${mysql_install_dir}/lib" > /etc/ld.so.conf.d/z-mysql.conf
+  ldconfig
+  service mysqld stop
+}

+ 24 - 0
include/openssl.sh

@@ -19,6 +19,8 @@ if openssl version | grep -Eqi 'OpenSSL 1.0.2*'; then
   php81_with_openssl="--with-openssl"
   php82_with_openssl="--with-openssl"
   php83_with_openssl="--with-openssl"
+  php84_with_openssl="--with-openssl"
+  php85_with_openssl="--with-openssl"
 
   php5_with_ssl="--with-ssl"
   php70_with_ssl="--with-ssl"
@@ -30,6 +32,8 @@ if openssl version | grep -Eqi 'OpenSSL 1.0.2*'; then
   php81_with_ssl="--with-ssl"
   php82_with_ssl="--with-ssl"
   php83_with_ssl="--with-ssl"
+  php84_with_ssl="--with-ssl"
+  php85_with_ssl="--with-ssl"
 
   php5_with_curl="--with-curl"
   php70_with_curl="--with-curl"
@@ -41,6 +45,8 @@ if openssl version | grep -Eqi 'OpenSSL 1.0.2*'; then
   php81_with_curl="--with-curl"
   php82_with_curl="--with-curl"
   php83_with_curl="--with-curl"
+  php84_with_curl="--with-curl"
+  php85_with_curl="--with-curl"
 elif openssl version | grep -Eqi 'OpenSSL 1.1.*'; then
   php5_with_openssl="--with-openssl=${openssl_install_dir}"
   php70_with_openssl="--with-openssl"
@@ -52,6 +58,8 @@ elif openssl version | grep -Eqi 'OpenSSL 1.1.*'; then
   php81_with_openssl="--with-openssl"
   php82_with_openssl="--with-openssl"
   php83_with_openssl="--with-openssl"
+  php84_with_openssl="--with-openssl"
+  php85_with_openssl="--with-openssl"
 
   php5_with_ssl="--with-ssl=${openssl_install_dir}"
   php70_with_ssl="--with-ssl"
@@ -63,6 +71,8 @@ elif openssl version | grep -Eqi 'OpenSSL 1.1.*'; then
   php81_with_ssl="--with-ssl"
   php82_with_ssl="--with-ssl"
   php83_with_ssl="--with-ssl"
+  php84_with_ssl="--with-ssl"
+  php85_with_ssl="--with-ssl"
 
   php5_with_curl="--with-curl=${curl_install_dir}"
   php70_with_curl="--with-curl"
@@ -74,6 +84,8 @@ elif openssl version | grep -Eqi 'OpenSSL 1.1.*'; then
   php81_with_curl="--with-curl"
   php82_with_curl="--with-curl"
   php83_with_curl="--with-curl"
+  php84_with_curl="--with-curl"
+  php85_with_curl="--with-curl"
   [[ ${php_option} =~ ^[1-4]$ ]] || [[ "${mphp_ver}" =~ ^5[3-6]$ ]] && with_old_openssl_flag=y
 elif openssl version | grep -Eqi 'OpenSSL 3.*'; then
   php5_with_openssl="--with-openssl=${openssl_install_dir}"
@@ -86,6 +98,8 @@ elif openssl version | grep -Eqi 'OpenSSL 3.*'; then
   php81_with_openssl="--with-openssl"
   php82_with_openssl="--with-openssl"
   php83_with_openssl="--with-openssl"
+  php84_with_openssl="--with-openssl"
+  php85_with_openssl="--with-openssl"
 
   php5_with_ssl="--with-ssl=${openssl_install_dir}"
   php70_with_ssl="--with-ssl=${openssl_install_dir}"
@@ -97,6 +111,8 @@ elif openssl version | grep -Eqi 'OpenSSL 3.*'; then
   php81_with_ssl="--with-ssl"
   php82_with_ssl="--with-ssl"
   php83_with_ssl="--with-ssl"
+  php84_with_ssl="--with-ssl"
+  php85_with_ssl="--with-ssl"
 
   php5_with_curl="--with-curl=${curl_install_dir}"
   php70_with_curl="--with-curl=${curl_install_dir}"
@@ -108,6 +124,8 @@ elif openssl version | grep -Eqi 'OpenSSL 3.*'; then
   php81_with_curl="--with-curl"
   php82_with_curl="--with-curl"
   php83_with_curl="--with-curl"
+  php84_with_curl="--with-curl"
+  php85_with_curl="--with-curl"
   [[ ${php_option} =~ ^[1-5]$ ]] || [[ "${mphp_ver}" =~ ^5[3-6]$|^70$ ]] && with_old_openssl_flag=y
 else
   php5_with_openssl="--with-openssl=${openssl_install_dir}"
@@ -120,6 +138,8 @@ else
   php81_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}"
   php82_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}"
   php83_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}"
+  php84_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}"
+  php85_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}"
 
   php5_with_ssl="--with-ssl=${openssl_install_dir}"
   php70_with_ssl="--with-ssl=${openssl_install_dir}"
@@ -131,6 +151,8 @@ else
   php81_with_ssl="--with-ssl=${openssl_install_dir}"
   php82_with_ssl="--with-ssl=${openssl_install_dir}"
   php83_with_ssl="--with-ssl=${openssl_install_dir}"
+  php84_with_ssl="--with-ssl=${openssl_install_dir}"
+  php85_with_ssl="--with-ssl=${openssl_install_dir}"
 
   php5_with_curl="--with-curl=${curl_install_dir}"
   php70_with_curl="--with-curl=${curl_install_dir}"
@@ -142,6 +164,8 @@ else
   php81_with_curl="--with-curl=${curl_install_dir}"
   php82_with_curl="--with-curl=${curl_install_dir}"
   php83_with_curl="--with-curl=${curl_install_dir}"
+  php84_with_curl="--with-curl=${curl_install_dir}"
+  php85_with_curl="--with-curl=${curl_install_dir}"
   with_old_openssl_flag=y
 fi
 

+ 233 - 0
include/php-8.5.sh

@@ -0,0 +1,233 @@
+#!/bin/bash
+
+Install_PHP85() {
+  # Check CentOS version
+  if [ -f /etc/redhat-release ]; then
+    OS_VERSION=$(grep -oE '[0-9]+\.[0-9]+' /etc/redhat-release | cut -d'.' -f1)
+    if [ "${OS_VERSION}" -lt "8" ]; then
+      echo "${CFAILURE}Error: PHP 8.5 cannot be installed on CentOS ${OS_VERSION}. Minimum required version is CentOS 8.${CEND}"
+      kill -9 $$; exit 1;
+    fi
+  fi
+
+  pushd ${oneinstack_dir}/src > /dev/null
+  
+  if [ ! -e "${php_install_dir}/bin/phpize" ]; then
+    PHP_version=${php85_ver}
+    PHP_main_ver=85
+    
+    # 下载和校验
+    src_url=https://www.php.net/distributions/php-${PHP_version}.tar.gz && Download_src
+    
+    # 编译安装
+    tar xzf php-${PHP_version}.tar.gz
+    pushd php-${PHP_version} > /dev/null
+    make clean
+    [ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir}
+    
+    # PHP 8.5 特定的编译选项
+    ./configure --prefix=${php_install_dir} \
+    --with-config-file-path=${php_install_dir}/etc \
+    --with-config-file-scan-dir=${php_install_dir}/etc/php.d \
+    --with-fpm-user=${run_user} \
+    --with-fpm-group=${run_user} \
+    --enable-mysqlnd \
+    --with-mysqli=mysqlnd \
+    --with-pdo-mysql=mysqlnd \
+    --with-sqlite3 \
+    --with-pdo-sqlite \
+    --with-openssl \
+    --with-zlib \
+    --with-zip \
+    --with-curl \
+    --with-iconv \
+    --with-gettext \
+    --with-readline \
+    --with-ldapsasl \
+    --with-sodium \
+    --enable-bcmath \
+    --enable-fpm \
+    --enable-xml \
+    --enable-sysvsem \
+    --enable-sysvshm \
+    --enable-sysvmsg \
+    --enable-shmop \
+    --enable-sockets \
+    --enable-mbstring \
+    --enable-pcntl \
+    --enable-soap \
+    --enable-gd \
+    --enable-intl \
+    --enable-opcache \
+    --enable-ftp \
+    --enable-exif \
+    --enable-calendar \
+    --without-pear \
+    --disable-phar \
+    --disable-rpath
+
+    make -j ${THREAD} && make install
+    
+    if [ -e "${php_install_dir}/bin/phpize" ]; then
+      # php.ini配置
+      mkdir -p ${php_install_dir}/etc/php.d
+      \cp php.ini-production ${php_install_dir}/etc/php.ini
+      tee -a ${php_install_dir}/etc/php.ini <<EOF
+
+; Modify php.ini Config by User
+memory_limit = 512M
+output_buffering = On
+short_open_tag = On
+expose_php = Off
+request_order = "CGP"
+date.timezone = ${timezone}
+post_max_size = 128M
+upload_max_filesize = 128M
+max_execution_time = 300
+realpath_cache_size = 2M
+disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen
+max_file_uploads = 20
+max_input_time = 300
+EOF
+
+      if [ -e /usr/sbin/sendmail ]; then
+        tee -a ${php_install_dir}/etc/php.ini <<EOF
+sendmail_path = /usr/sbin/sendmail -t -i
+EOF
+      fi
+      
+      # php-fpm.conf配置
+      \cp sapi/fpm/php-fpm.conf.in ${php_install_dir}/etc/php-fpm.conf
+      \cp sapi/fpm/www.conf.in ${php_install_dir}/etc/php-fpm.d/www.conf
+      sed -i "s@^include=@;include=@" ${php_install_dir}/etc/php-fpm.conf
+      tee -a ${php_install_dir}/etc/php-fpm.conf <<EOF
+
+; Modify php-fpm.conf Config by User
+pid = run/php-fpm.pid
+error_log = log/php-fpm.log
+log_level = warning
+emergency_restart_threshold = 30
+emergency_restart_interval = 60s
+process_control_timeout = 5s
+daemonize = yes
+include=${php_install_dir}/etc/php-fpm.d/*.conf
+EOF
+
+      # php-fpm.d/www.conf配置
+      tee -a ${php_install_dir}/etc/php-fpm.d/www.conf <<EOF
+
+; Modify php-fpm.d/www.conf Config by User
+[${run_user}]
+listen = /dev/shm/php-cgi.sock
+listen.backlog = 65535
+listen.allowed_clients = 127.0.0.1
+listen.owner = ${run_user}
+listen.group = ${run_group}
+listen.mode = 0666
+
+user = ${run_user}
+group = ${run_group}
+
+pm = dynamic
+pm.max_children = 20
+pm.start_servers = 15
+pm.min_spare_servers = 10
+pm.max_spare_servers = 20
+pm.max_requests = 10240
+pm.process_idle_timeout = 10s
+pm.status_path = /php-fpm_status
+
+request_terminate_timeout = 300
+request_slowlog_timeout = 10s
+slowlog = var/log/slow.log
+rlimit_files = 65535
+rlimit_core = 0
+catch_workers_output = yes
+
+php_admin_value[error_log] = var/log/php-fpm.error.log
+php_admin_flag[log_errors] = on
+
+php_admin_value[opcache.enable] = 1
+php_admin_value[opcache.memory_consumption] = 128
+php_admin_value[opcache.interned_strings_buffer] = 16
+php_admin_value[opcache.max_accelerated_files] = 10000
+php_admin_value[opcache.validate_timestamps] = 1
+php_admin_value[opcache.revalidate_freq] = 60
+
+env[HOSTNAME] = $HOSTNAME
+env[PATH] = /usr/local/bin:/usr/bin:/bin
+env[TMP] = /tmp
+env[TMPDIR] = /tmp
+env[TEMP] = /tmp
+
+; Recommended, if you need to adjust, please modify the following parameters.
+EOF
+
+      # php-fpm内存优化
+      if [ $Mem -gt 8500 ]; then
+        tee -a ${php_install_dir}/etc/php-fpm.d/www.conf <<EOF
+pm.max_children = 80
+pm.start_servers = 60
+pm.min_spare_servers = 50
+pm.max_spare_servers = 80
+EOF
+      elif [ $Mem -gt 6500 ]; then
+        tee -a ${php_install_dir}/etc/php-fpm.d/www.conf <<EOF
+pm.max_children = 70
+pm.start_servers = 50
+pm.min_spare_servers = 40
+pm.max_spare_servers = 70
+EOF
+      elif [ $Mem -gt 4500 ]; then
+        tee -a ${php_install_dir}/etc/php-fpm.d/www.conf <<EOF
+pm.max_children = 60
+pm.start_servers = 40
+pm.min_spare_servers = 30
+pm.max_spare_servers = 60
+EOF
+      elif [ $Mem -gt 3000 ]; then
+        tee -a ${php_install_dir}/etc/php-fpm.d/www.conf <<EOF
+pm.max_children = 50
+pm.start_servers = 30
+pm.min_spare_servers = 20
+pm.max_spare_servers = 50
+EOF
+      else
+        tee -a ${php_install_dir}/etc/php-fpm.d/www.conf <<EOF
+pm.max_children = $(($Mem/3/20))
+pm.start_servers = $(($Mem/3/30))
+pm.min_spare_servers = $(($Mem/3/40))
+pm.max_spare_servers = $(($Mem/3/20))
+EOF
+      fi
+      
+      # 启动脚本
+      \cp ${oneinstack_dir}/init.d/php-fpm.service /lib/systemd/system/
+      sed -i "s@/usr/local/php@${php_install_dir}@g" /lib/systemd/system/php-fpm.service
+      systemctl enable --now php-fpm.service
+
+      # 检测php-fpm是否启动成功
+      systemctl status php-fpm.service | grep "Active: active (running)"
+      if [ $? -ne 0 ]; then
+        systemctl restart php-fpm.service
+        systemctl status php-fpm.service | grep "Active: active (running)"
+        if [ $? -ne 0 ]; then
+          echo "${CFAILURE}PHP ${PHP_version} install failed, Please Contact the author! ${CEND}"
+          kill -9 $$; exit 1;
+        fi
+      fi
+
+      # 环境变量
+      echo "export PATH=${php_install_dir}/bin:\$PATH" > /etc/profile.d/php.sh
+      
+      echo "${CSUCCESS}PHP ${PHP_version} installed successfully! ${CEND}"
+      rm -rf php-${PHP_version}
+    else
+      rm -rf ${php_install_dir}
+      echo "${CFAILURE}PHP ${PHP_version} install failed, Please Contact the author! ${CEND}"
+      kill -9 $$; exit 1;
+    fi
+    popd > /dev/null
+  fi
+  popd > /dev/null
+}

+ 1 - 1
include/upgrade_php.sh

@@ -19,7 +19,7 @@ Upgrade_PHP() {
   echo
   echo "Current PHP Version: ${CMSG}$OLD_php_ver${CEND}"
   while :; do echo
-    [ "${php_flag}" != 'y' ] && read -e -p "Please input upgrade PHP Version(Default: $Latest_php_ver): " NEW_php_ver
+    read -e -p "Please input upgrade PHP Version(Default: $Latest_php_ver): " NEW_php_ver
     NEW_php_ver=${NEW_php_ver:-${Latest_php_ver}}
     if [ "${NEW_php_ver%.*}" == "${OLD_php_ver%.*}" ]; then
       [ ! -e "php-${NEW_php_ver}.tar.gz" ] && wget --no-check-certificate -c https://secure.php.net/distributions/php-${NEW_php_ver}.tar.gz > /dev/null 2>&1

+ 19 - 18
install.sh

@@ -36,8 +36,8 @@ xcachepwd=`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`
 dbinstallmethod=1
 
 version() {
-  echo "version: 2.6"
-  echo "updated date: 2023-02-04"
+  echo "version: 2.7"
+  echo "updated date: 2026-01-07"
 }
 
 Show_Help() {
@@ -49,8 +49,8 @@ Show_Help() {
   --apache                    Install Apache
   --apache_mode_option [1-2]  Apache2.4 mode, 1(default): php-fpm, 2: mod_php
   --apache_mpm_option [1-3]   Apache2.4 MPM, 1(default): event, 2: prefork, 3: worker
-  --php_option [1-14]         Install PHP version
-  --mphp_ver [53~84]          Install another PHP version (PATH: ${php_install_dir}\${mphp_ver})
+  --php_option [1-15]         Install PHP version
+  --mphp_ver [53~85]          Install another PHP version (PATH: ${php_install_dir}\${mphp_ver})
   --mphp_addons               Only install another PHP addons
   --phpcache_option [1-4]     Install PHP opcode cache, default: 1 opcache
   --php_extensions [ext name] Install PHP extensions, include zendguardloader,ioncube,
@@ -59,7 +59,7 @@ Show_Help() {
   --nodejs                    Install Nodejs
   --tomcat_option [1-6]       Install Tomcat version
   --jdk_option [1-3]          Install JDK version
-  --db_option [1-14]          Install DB version
+  --db_option [1-15]          Install DB version
   --dbinstallmethod [1-2]     DB install method, default: 1 binary install
   --dbrootpwd [password]      DB super password
   --pureftpd                  Install Pure-Ftpd
@@ -138,8 +138,8 @@ while :; do
   --php_option)
     php_option=$2
     shift 2
-    [[ ! ${php_option} =~ ^[1-9]$|^1[0-4]$ ]] && {
-      echo "${CWARNING}php_option input error! Please only input number 1~14${CEND}"
+    [[ ! ${php_option} =~ ^[1-9]$|^1[0-5]$ ]] && {
+      echo "${CWARNING}php_option input error! Please only input number 1~15${CEND}"
       exit 1
     }
     [ -e "${php_install_dir}/bin/phpize" ] && {
@@ -151,8 +151,8 @@ while :; do
     mphp_ver=$2
     mphp_flag=y
     shift 2
-    [[ ! "${mphp_ver}" =~ ^5[3-6]$|^7[0-4]$|^8[0-4]$ ]] && {
-      echo "${CWARNING}mphp_ver input error! Please only input number 53~84${CEND}"
+    [[ ! "${mphp_ver}" =~ ^5[3-6]$|^7[0-4]$|^8[0-5]$ ]] && {
+      echo "${CWARNING}mphp_ver input error! Please only input number 53~85${CEND}"
       exit 1
     }
     ;;
@@ -227,13 +227,13 @@ while :; do
         echo "${CWARNING}PostgreSQL already installed! ${CEND}"
         unset db_option
       }
-    elif [ "${db_option}" == '14' ]; then
+    elif [ "${db_option}" == '15' ]; then
       [ -e "${mongo_install_dir}/bin/mongo" ] && {
         echo "${CWARNING}MongoDB already installed! ${CEND}"
         unset db_option
       }
     else
-      echo "${CWARNING}db_option input error! Please only input number 1~14${CEND}"
+      echo "${CWARNING}db_option input error! Please only input number 1~15${CEND}"
       exit 1
     fi
     ;;
@@ -555,7 +555,7 @@ if [ ${ARG_NUM} == 0 ]; then
         while :; do
           echo
           echo 'Please select a version of the Database:'
-          echo -e "\t${CMSG} 0${CEND}. Install MySQL-8.2"
+          echo -e "\t${CMSG} 0${CEND}. Install MySQL-8.4 (LTS)"
           echo -e "\t${CMSG} 1${CEND}. Install MySQL-8.0"
           echo -e "\t${CMSG} 2${CEND}. Install MySQL-5.7"
           echo -e "\t${CMSG} 3${CEND}. Install MySQL-5.6"
@@ -570,8 +570,8 @@ if [ ${ARG_NUM} == 0 ]; then
           echo -e "\t${CMSG}12${CEND}. Install Percona-5.5"
           echo -e "\t${CMSG}13${CEND}. Install PostgreSQL"
           echo -e "\t${CMSG}14${CEND}. Install MongoDB"
-          read -e -p "Please input a number:(Default 2 press Enter) " db_option
-          db_option=${db_option:-2}
+          read -e -p "Please input a number:(Default 0 press Enter) " db_option
+          db_option=${db_option:-0}
           if [[ "${db_option}" =~ ^[0-9]$|^1[0-4]$ ]]; then
             if [ "${db_option}" == '13' ]; then
               [ -e "${pgsql_install_dir}/bin/psql" ] && { echo "${CWARNING}PostgreSQL already installed! ${CEND}"; unset db_option; break; }
@@ -654,9 +654,10 @@ if [ ${ARG_NUM} == 0 ]; then
           echo -e "\t${CMSG}12${CEND}. Install php-8.2"
           echo -e "\t${CMSG}13${CEND}. Install php-8.3"
           echo -e "\t${CMSG}14${CEND}. Install php-8.4"
-          read -e -p "Please input a number:(Default 7 press Enter) " php_option
-          php_option=${php_option:-7}
-          if [[ ! ${php_option} =~ ^[1-9]$|^1[0-4]$ ]]; then
+          echo -e "\t${CMSG}15${CEND}. Install php-8.5"
+          read -e -p "Please input a number:(Default 15 press Enter) " php_option
+          php_option=${php_option:-15}
+          if [[ ! ${php_option} =~ ^[1-9]$|^1[0-5]$ ]]; then
             echo "${CWARNING}input error! Please only input number 1~14${CEND}"
           else
             break
@@ -743,7 +744,7 @@ if [ ${ARG_NUM} == 0 ]; then
               fi
             done
           fi
-          if [[ ${php_option} =~ ^[5-9]$|^1[0-3]$ ]] || [[ "${PHP_main_ver}" =~ ^7.[0-4]$|^8.[0-3]$ ]]; then
+          if [[ ${php_option} =~ ^[5-9]$|^1[0-4]$ ]] || [[ "${PHP_main_ver}" =~ ^7.[0-4]$|^8.[0-4]$ ]]; then
             while :; do
               echo 'Please select a opcode cache of the PHP:'
               echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"

+ 48 - 47
versions.txt

@@ -1,32 +1,32 @@
 # newest software version
 # Web
-nginx_ver=1.28.0
-caddy_ver=2.10.1
+nginx_ver=1.28.1
+caddy_ver=2.10.2
 tengine_ver=3.1.0
-openresty_ver=1.21.4.3
+openresty_ver=1.27.1.2
 openssl11_ver=1.1.1w
-openssl_ver=1.0.2u
+openssl_ver=3.2.1
 
-tomcat11_ver=11.0.8
-tomcat10_ver=10.1.16
-tomcat9_ver=9.0.83
+tomcat11_ver=11.0.15
+tomcat10_ver=10.1.50
+tomcat9_ver=9.0.113
 tomcat8_ver=8.5.96
 tomcat7_ver=7.0.109
 
-apache_ver=2.4.58
+apache_ver=2.4.66
 pcre_ver=8.45
-apr_ver=1.7.0
-apr_util_ver=1.6.1
-nghttp2_ver=1.42.0
+apr_ver=1.7.5
+apr_util_ver=1.6.3
+nghttp2_ver=1.64.0
 
 # DB
-mysql82_ver=8.2.0
-mysql80_ver=8.0.36
+mysql84_ver=8.4.0
+mysql80_ver=8.0.39
 mysql57_ver=5.7.44
 mysql56_ver=5.6.51
 mysql55_ver=5.5.62
 
-mariadb1011_ver=10.11.11
+mariadb1011_ver=10.11.15
 mariadb105_ver=10.5.23
 mariadb104_ver=10.4.32
 mariadb55_ver=5.5.68
@@ -36,9 +36,9 @@ percona57_ver=5.7.42-46
 percona56_ver=5.6.51-91.0
 percona55_ver=5.5.62-38.14
 
-pgsql_ver=12.7
+pgsql_ver=18.1
 
-mongodb_ver=4.0.26
+mongodb_ver=8.0.17
 
 # PHP
 php53_ver=5.3.29
@@ -51,29 +51,30 @@ php72_ver=7.2.34
 php73_ver=7.3.33
 php74_ver=7.4.33
 php80_ver=8.0.30
-php81_ver=8.1.33
-php82_ver=8.2.29
-php83_ver=8.3.24
-php84_ver=8.4.11
+php81_ver=8.1.34
+php82_ver=8.2.30
+php83_ver=8.3.29
+php84_ver=8.4.16
+php85_ver=8.5.1
 
 # Nodejs
-nodejs_ver=20.10.0
+nodejs_ver=22.12.0
 
-libiconv_ver=1.16
-curl_ver=8.4.0
+libiconv_ver=1.17
+curl_ver=8.17.0
 libmcrypt_ver=2.5.8
 mcrypt_ver=2.6.8
 mhash_ver=0.9.9.9
 freetype_ver=2.10.1
 icu4c_ver=63_1
-libsodium_ver=1.0.18
-libsodium_up_ver=1.0.19
-libzip_ver=1.2.0
+libsodium_ver=1.0.21
+libsodium_up_ver=1.0.21
+libzip_ver=1.11.4
 argon2_ver=20171227
-imagemagick_ver=7.1.1-45
+imagemagick_ver=7.1.2-12
 imagick_ver=3.7.0
 imagick_oldver=3.4.4
-graphicsmagick_ver=1.3.40
+graphicsmagick_ver=1.3.46
 gmagick_ver=2.0.6RC1
 gmagick_oldver=1.1.7RC3
 zendopcache_ver=7.0.5
@@ -85,48 +86,48 @@ phalcon_ver=5.4.0
 phalcon_oldver=3.4.5
 yaf_ver=3.3.2
 yar_ver=2.2.0
-swoole_ver=6.0.1
-swoole_oldver=4.8.12
-xdebug_ver=3.1.2
-xdebug_oldver=2.9.8
+swoole_ver=6.1.6
+swoole_oldver=5.1.5
+xdebug_ver=3.5.0
+xdebug_oldver=3.1.6
 
 # Ftp
 pureftpd_ver=1.0.51
 
 # Redis
-redis_ver=7.2.3
-redis_oldver=6.2.14
-pecl_redis_ver=6.1.0
+redis_ver=8.4.0
+redis_oldver=7.4.2
+pecl_redis_ver=6.3.0
 
 # Memcached
-memcached_ver=1.6.22
+memcached_ver=1.6.40
 libmemcached_ver=1.0.18
-pecl_memcached_ver=3.2.0
+pecl_memcached_ver=3.3.0
 pecl_memcached_oldver=2.2.0
 pecl_memcache_ver=8.2
 pecl_memcache_oldver=4.0.5.2
 
 # MongoDB
-pecl_mongodb_ver=1.21.0
-pecl_mongodb_oldver=1.9.2
+pecl_mongodb_ver=2.1.4
+pecl_mongodb_oldver=1.19.1
 pecl_mongo_ver=1.6.16
 
 # phpMyadmin
-phpmyadmin_ver=5.2.1
+phpmyadmin_ver=5.2.3
 phpmyadmin_oldver=4.4.15.10
 
 # jemalloc
 jemalloc_ver=5.3.0
 
 # boost
-boost_ver=1.77.0
-boost_percona_ver=1.77.0
+boost_ver=1.86.0
+boost_percona_ver=1.86.0
 boost_oldver=1.59.0
 
 # Others
-lua_nginx_module_ver=0.10.25
-luajit2_ver=2.1-20230410
-lua_resty_core_ver=0.1.27
-lua_resty_lrucache_ver=0.13
-lua_cjson_ver=2.1.0.12
+lua_nginx_module_ver=0.10.28
+luajit2_ver=2.1-ROLLING
+lua_resty_core_ver=0.1.32
+lua_resty_lrucache_ver=0.15
+lua_cjson_ver=2.1.0+dfsg-4
 fail2ban_ver=master

+ 237 - 15
vhost.sh

@@ -63,7 +63,7 @@ while :; do
       ;;
     --mphp_ver)
       mphp_ver=$2; mphp_flag=y; shift 2
-      [[ ! "${mphp_ver}" =~ ^5[3-6]$|^7[0-4]$|^8[0-1]$ ]] && { echo "${CWARNING}mphp_ver input error! Please only input number 53~81${CEND}"; unset mphp_ver mphp_flag; }
+      [[ ! "${mphp_ver}" =~ ^5[3-6]$|^7[0-4]$|^8[0-5]$ ]] && { echo "${CWARNING}mphp_ver input error! Please only input number 53~85${CEND}"; unset mphp_ver mphp_flag; }
       ;;
     --proxy)
       proxy_flag=y; shift 1
@@ -160,7 +160,7 @@ If you enter '.', the field will be left blank.
     read -e -p "Country Name (2 letter code) [CN]: " SELFSIGNEDSSL_C
     SELFSIGNEDSSL_C=${SELFSIGNEDSSL_C:-CN}
     # shellcheck disable=SC2104
-    [ ${#SELFSIGNEDSSL_C} != 2 ] && { echo "${CWARNING}input error, You must input 2 letter code country name${CEND}"; continue; }
+    [ ${#SELFSIGNEDSSL_C} != 2 ] && { echo "${CWARNING}input error, You must input 2 letter code country name${CEND}"; return 1; }
     echo
     read -e -p "State or Province Name (full name) [Shanghai]: " SELFSIGNEDSSL_ST
     SELFSIGNEDSSL_ST=${SELFSIGNEDSSL_ST:-Shanghai}
@@ -239,6 +239,11 @@ If you enter '.', the field will be left blank.
         fi
         ${web_install_dir}/sbin/nginx -s reload
       fi
+      if [ "${caddy_ssl_flag}" == 'y' ]; then
+        [ ! -d ${caddy_install_dir}/conf/vhost ] && mkdir -p ${caddy_install_dir}/conf/vhost
+        echo "${domain}${moredomainame} {  root * ${vhostdir}; file_server }" > ${caddy_install_dir}/conf/vhost/${domain}.conf
+        Reload_Caddy
+      fi
       if [ "${apache_ssl_flag}" == 'y' ]; then
         [ ! -d ${apache_install_dir}/conf/vhost ] && mkdir ${apache_install_dir}/conf/vhost
         cat > ${apache_install_dir}/conf/vhost/${domain}.conf << EOF
@@ -274,12 +279,15 @@ EOF
       [ -e "${PATH_SSL}/${domain}.crt" ] && rm -f ${PATH_SSL}/${domain}.{crt,key}
       Nginx_cmd="/bin/systemctl restart nginx"
       Apache_cmd="${apache_install_dir}/bin/apachectl -k graceful"
+      [ -e /usr/bin/systemctl ] && Caddy_cmd="systemctl reload caddy" || Caddy_cmd="service caddy reload"
       if [ -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/bin/httpd" ]; then
         Command="${Nginx_cmd};${Apache_cmd}"
       elif [ -e "${web_install_dir}/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" ]; then
         Command="${Nginx_cmd}"
       elif [ ! -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/bin/httpd" ]; then
         Command="${Apache_cmd}"
+      elif [ -e "${caddy_install_dir}/bin/caddy" ]; then
+        Command="${Caddy_cmd}"
       fi
     if [ -s ~/.acme.sh/${domain}/fullchain.cer ] && [[ "${CERT_KEYLENGTH}" =~ ^2048$|^3072$|^4096$|^8192$ ]]; then
       ~/.acme.sh/acme.sh --force --install-cert -d ${domain} --fullchain-file ${PATH_SSL}/${domain}.crt --key-file ${PATH_SSL}/${domain}.key --reloadcmd "${Command}" > /dev/null
@@ -289,6 +297,7 @@ EOF
       echo "${CFAILURE}Error: Create Let's Encrypt SSL Certificate failed! ${CEND}"
       [ -e "${web_install_dir}/conf/vhost/${domain}.conf" ] && rm -f ${web_install_dir}/conf/vhost/${domain}.conf
       [ -e "${apache_install_dir}/conf/vhost/${domain}.conf" ] && rm -f ${apache_install_dir}/conf/vhost/${domain}.conf
+      [ -e "${caddy_install_dir}/conf/vhost/${domain}.conf" ] && rm -f ${caddy_install_dir}/conf/vhost/${domain}.conf
       exit 1
     fi
   fi
@@ -337,7 +346,7 @@ What Are You Doing?
   fi
 
   #Multiple_PHP
-  if [ $(ls /dev/shm/php*-cgi.sock 2> /dev/null | wc -l) -ge 2 ]; then
+  if [ -e "${php_install_dir}/bin/php-config" ] && [ $(ls /dev/shm/php*-cgi.sock 2> /dev/shm/php_err | wc -l) -ge 2 ]; then
     if [ "${mphp_flag}" != 'y' ]; then
       PHP_detail_ver=`${php_install_dir}/bin/php-config --version`
       PHP_main_ver=${PHP_detail_ver%.*}
@@ -357,10 +366,12 @@ What Are You Doing?
         [ -e "/dev/shm/php81-cgi.sock" ] && echo -e "\t${CMSG}11${CEND}. PHP 8.1"
         [ -e "/dev/shm/php82-cgi.sock" ] && echo -e "\t${CMSG}12${CEND}. PHP 8.2"
         [ -e "/dev/shm/php83-cgi.sock" ] && echo -e "\t${CMSG}13${CEND}. PHP 8.3"
+        [ -e "/dev/shm/php84-cgi.sock" ] && echo -e "\t${CMSG}14${CEND}. PHP 8.4"
+        [ -e "/dev/shm/php85-cgi.sock" ] && echo -e "\t${CMSG}15${CEND}. PHP 8.5"
         read -e -p "Please input a number:(Default 0 press Enter) " php_option
         php_option=${php_option:-0}
-        if [[ ! ${php_option} =~ ^[0-9]$|^1[0-2]$ ]]; then
-          echo "${CWARNING}input error! Please only input number 1~12${CEND}"
+        if [[ ! ${php_option} =~ ^[0-9]$|^1[0-5]$ ]]; then
+          echo "${CWARNING}input error! Please only input number 0~15${CEND}"
         else
           break
         fi
@@ -379,6 +390,8 @@ What Are You Doing?
     [ "${php_option}" == '11' ] && mphp_ver=81
     [ "${php_option}" == '12' ] && mphp_ver=82
     [ "${php_option}" == '13' ] && mphp_ver=83
+    [ "${php_option}" == '14' ] && mphp_ver=84
+    [ "${php_option}" == '15' ] && mphp_ver=85
     [ ! -e "/dev/shm/php${mphp_ver}-cgi.sock" ] && unset mphp_ver
   fi
 
@@ -405,11 +418,15 @@ What Are You Doing?
     if [ -e "${web_install_dir}/sbin/nginx" ]; then
       nginx_ssl_flag=y
       PATH_SSL=${web_install_dir}/conf/ssl
-      [ ! -d "${PATH_SSL}" ] && mkdir ${PATH_SSL}
-    elif [ ! -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/bin/httpd" ]; then
+      [ ! -d "${PATH_SSL}" ] && mkdir -p ${PATH_SSL}
+    elif [ -e "${caddy_install_dir}/bin/caddy" ]; then
+      caddy_ssl_flag=y
+      PATH_SSL=${caddy_install_dir}/conf/ssl
+      [ ! -d "${PATH_SSL}" ] && mkdir -p ${PATH_SSL}
+    elif [ -e "${apache_install_dir}/bin/httpd" ]; then
       apache_ssl_flag=y
       PATH_SSL=${apache_install_dir}/conf/ssl
-      [ ! -d "${PATH_SSL}" ] && mkdir ${PATH_SSL}
+      [ ! -d "${PATH_SSL}" ] && mkdir -p ${PATH_SSL}
     fi
   elif [ "${Domian_Mode}" == 'q' ]; then
     exit 1
@@ -468,7 +485,7 @@ What Are You Doing?
       if [ -z "$(echo ${moredomain} | grep '.*\..*')" ]; then
         echo "${CWARNING}Your ${domain} is invalid! ${CEND}"
       else
-        [ "${moredomain}" == "${domain}" ] && echo "${CWARNING}Domain name already exists! ${CND}" && continue
+        [ "${moredomain}" == "${domain}" ] && echo "${CWARNING}Domain name already exists! ${CEND}" && continue
         echo domain list="$moredomain"
         moredomainame=" $moredomain"
         break
@@ -490,7 +507,7 @@ What Are You Doing?
     fi
   fi
 
-  if [ "${nginx_ssl_flag}" == 'y' ]; then
+  if [ "${nginx_ssl_flag}" == 'y' -o "${caddy_ssl_flag}" == 'y' -o "${apache_ssl_flag}" == 'y' ]; then
     while :; do echo
       read -e -p "Do you want to redirect all HTTP requests to HTTPS? [y/n]: " https_flag
       if [[ ! ${https_flag} =~ ^[y,n]$ ]]; then
@@ -620,6 +637,25 @@ Nginx_log() {
   fi
 }
 
+Caddy_log() {
+  while :; do echo
+    read -e -p "Allow Caddy access_log? [y/n]: " access_flag
+    if [[ ! "${access_flag}" =~ ^[y,n]$ ]]; then
+      echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+    else
+      break
+    fi
+  done
+  if [ "${access_flag}" == 'n' ]; then
+    Caddy_log=""
+  else
+    Caddy_log="log {
+        output file ${wwwlogs_dir}/${domain}_caddy.log
+    }"
+    echo "You access log file=${CMSG}${wwwlogs_dir}/${domain}_caddy.log${CEND}"
+  fi
+}
+
 Create_nginx_tomcat_conf() {
   [ ! -d ${web_install_dir}/conf/vhost ] && mkdir ${web_install_dir}/conf/vhost
   cat > ${web_install_dir}/conf/vhost/${domain}.conf << EOF
@@ -892,6 +928,117 @@ EOF
   Print_SSL
 }
 
+Reload_Caddy() {
+  if [ -e /usr/bin/systemctl ]; then
+    systemctl reload caddy
+  else
+    service caddy reload
+  fi
+}
+
+Create_caddy_php_conf() {
+  [ ! -d ${caddy_install_dir}/conf/vhost ] && mkdir -p ${caddy_install_dir}/conf/vhost
+  if [ "${https_flag}" == 'y' ]; then
+    cat > ${caddy_install_dir}/conf/vhost/${domain}.conf << EOF
+http://${domain}, http://${moredomainame} {
+  redir https://{host}{uri}
+}
+
+https://${domain}, https://${moredomainame} {
+  root * ${vhostdir}
+  php_fastcgi unix:/dev/shm/php${mphp_ver}-cgi.sock
+  file_server
+  ${Caddy_log}
+  tls ${PATH_SSL}/${domain}.crt ${PATH_SSL}/${domain}.key
+  handle_errors {
+    rewrite * /{err.status_code}.html
+    file_server
+  }
+}
+EOF
+  else
+    cat > ${caddy_install_dir}/conf/vhost/${domain}.conf << EOF
+${domain}${moredomainame} {
+  root * ${vhostdir}
+  php_fastcgi unix:/dev/shm/php${mphp_ver}-cgi.sock
+  file_server
+  ${Caddy_log}
+  [ -e "${PATH_SSL}/${domain}.crt" ] && tls ${PATH_SSL}/${domain}.crt ${PATH_SSL}/${domain}.key
+  handle_errors {
+    rewrite * /{err.status_code}.html
+    file_server
+  }
+}
+EOF
+  fi
+
+  echo
+  ${caddy_install_dir}/bin/caddy validate --config ${caddy_install_dir}/conf/Caddyfile
+  if [ $? == 0 ]; then
+    echo "Reload Caddy......"
+    systemctl reload caddy
+  else
+    rm -f ${caddy_install_dir}/conf/vhost/${domain}.conf
+    echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]"
+    exit 1
+  fi
+
+  printf "
+#######################################################################
+#       OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+      #
+#       For more information please visit https://oneinstack.com      #
+#######################################################################
+"
+  echo "$(printf "%-30s" "Your domain:")${CMSG}${domain}${CEND}"
+  echo "$(printf "%-30s" "Caddy Virtualhost conf:")${CMSG}${caddy_install_dir}/conf/vhost/${domain}.conf${CEND}"
+  echo "$(printf "%-30s" "Directory of:")${CMSG}${vhostdir}${CEND}"
+}
+
+Create_caddy_proxy_conf() {
+  [ ! -d ${caddy_install_dir}/conf/vhost ] && mkdir -p ${caddy_install_dir}/conf/vhost
+  if [ "${https_flag}" == 'y' ]; then
+    cat > ${caddy_install_dir}/conf/vhost/${domain}.conf << EOF
+http://${domain}, http://${moredomainame} {
+  redir https://{host}{uri}
+}
+
+https://${domain}, https://${moredomainame} {
+  reverse_proxy ${Proxy_Pass}
+  ${Caddy_log}
+  tls ${PATH_SSL}/${domain}.crt ${PATH_SSL}/${domain}.key
+}
+EOF
+  else
+    cat > ${caddy_install_dir}/conf/vhost/${domain}.conf << EOF
+${domain}${moredomainame} {
+  reverse_proxy ${Proxy_Pass}
+  ${Caddy_log}
+  [ -e "${PATH_SSL}/${domain}.crt" ] && tls ${PATH_SSL}/${domain}.crt ${PATH_SSL}/${domain}.key
+}
+EOF
+  fi
+
+  echo
+  ${caddy_install_dir}/bin/caddy validate --config ${caddy_install_dir}/conf/Caddyfile
+  if [ $? == 0 ]; then
+    echo "Reload Caddy......"
+    Reload_Caddy
+  else
+    rm -f ${caddy_install_dir}/conf/vhost/${domain}.conf
+    echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]"
+    exit 1
+  fi
+
+  printf "
+#######################################################################
+#       OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+      #
+#       For more information please visit https://oneinstack.com      #
+#######################################################################
+"
+  echo "$(printf "%-30s" "Your domain:")${CMSG}${domain}${CEND}"
+  echo "$(printf "%-30s" "Caddy Virtualhost conf:")${CMSG}${caddy_install_dir}/conf/vhost/${domain}.conf${CEND}"
+}
+
 Apache_log() {
   while :; do echo
     read -e -p "Allow Apache access_log? [y/n]: " access_flag
@@ -1087,7 +1234,18 @@ EOF
 }
 
 Add_Vhost() {
-  if [ -e "${web_install_dir}/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" ]; then
+  if [ -e "${caddy_install_dir}/bin/caddy" ] && [[ "${web_install_dir}" =~ caddy || ! -e "${web_install_dir}/sbin/nginx" ]]; then
+    Choose_ENV
+    Input_Add_domain
+    if [ "${proxy_flag}" == "y" ]; then
+      Input_Add_proxy
+      Caddy_log
+      Create_caddy_proxy_conf
+    else
+      Caddy_log
+      Create_caddy_php_conf
+    fi
+  elif [ -e "${web_install_dir}/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" ]; then
     Choose_ENV
     Input_Add_domain
     Nginx_anti_hotlinking
@@ -1126,6 +1284,17 @@ Add_Vhost() {
       Apache_log
       Create_nginx_apache_modphp_conf
     fi
+  elif [ -e "${caddy_install_dir}/bin/caddy" ]; then
+    Choose_ENV
+    Input_Add_domain
+    if [ "${proxy_flag}" == "y" ]; then
+      Input_Add_proxy
+      Caddy_log
+      Create_caddy_proxy_conf
+    else
+      Caddy_log
+      Create_caddy_php_conf
+    fi
   else
     echo "Error! ${CFAILURE}Web server${CEND} not found!"
   fi
@@ -1180,6 +1349,55 @@ Del_NGX_Vhost() {
   fi
 }
 
+Del_Caddy_Vhost() {
+  if [ -e "${caddy_install_dir}/bin/caddy" ]; then
+    [ -d "${caddy_install_dir}/conf/vhost" ] && Domain_List=$(ls ${caddy_install_dir}/conf/vhost | sed "s@.conf@@g")
+    if [ -n "${Domain_List}" ]; then
+      echo
+      echo "Virtualhost list:"
+      echo ${CMSG}${Domain_List}${CEND}
+      while :; do echo
+        read -e -p "Please input a domain you want to delete: " domain
+        if [ -z "$(echo ${domain} | grep '.*\..*')" ]; then
+          echo "${CWARNING}Your ${domain} is invalid! ${CEND}"
+        else
+          if [ -e "${caddy_install_dir}/conf/vhost/${domain}.conf" ]; then
+            Directory=$(grep 'root \*' ${caddy_install_dir}/conf/vhost/${domain}.conf | head -1 | sed 's@^.*root \* @@g')
+            rm -f ${caddy_install_dir}/conf/vhost/${domain}.conf
+            Reload_Caddy
+            if [ -n "${Directory}" -a -d "${Directory}" ]; then
+              while :; do echo
+                read -e -p "Do you want to delete Virtul Host directory? [y/n]: " Del_Vhost_wwwroot_flag
+                if [[ ! ${Del_Vhost_wwwroot_flag} =~ ^[y,n]$ ]]; then
+                  echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+                else
+                  break
+                fi
+              done
+
+              if [ "${Del_Vhost_wwwroot_flag}" == 'y' ]; then
+                if [ "${quiet_flag}" != 'y' ]; then
+                  echo "Press Ctrl+c to cancel or Press any key to continue..."
+                  char=$(get_char)
+                fi
+                rm -rf ${Directory}
+              fi
+            fi
+            echo
+            [ -d ~/.acme.sh/${domain} ] && ~/.acme.sh/acme.sh --force --remove -d ${domain} > /dev/null 2>&1
+            [ -d ~/.acme.sh/${domain}_ecc ] && ~/.acme.sh/acme.sh --force --remove --ecc -d ${domain} > /dev/null 2>&1
+            echo "${CSUCCESS}Domain: ${domain} has been deleted.${CEND}"
+            echo
+          else
+            echo "${CWARNING}Virtualhost: ${domain} was not exist! ${CEND}"
+          fi
+          break
+        fi
+      done
+    fi
+  fi
+}
+
 Del_Apache_Vhost() {
   if [ -e "${apache_install_dir}/bin/httpd" ]; then
     if [ -e "${web_install_dir}/sbin/nginx" ]; then
@@ -1289,9 +1507,13 @@ Del_Tomcat_Vhost() {
 }
 
 List_Vhost() {
-  [ -e "${tomcat_install_dir}/conf/server.xml" -a ! -d "${web_install_dir}/sbin/nginx" ] && Domain_List=$(ls ${tomcat_install_dir}/conf/vhost | grep -v 'localhost.xml' | sed "s@.xml@@g")
-  [ -d "${web_install_dir}/conf/vhost" ] && Domain_List=$(ls ${web_install_dir}/conf/vhost | sed "s@.conf@@g")
-  [ -e "${apache_install_dir}/bin/httpd" -a ! -d "${web_install_dir}/conf/vhost" ] && Domain_List=$(ls ${apache_install_dir}/conf/vhost | grep -v '0.conf' | sed "s@.conf@@g")
+  Domain_List_Nginx=$( [ -d "${web_install_dir}/conf/vhost" ] && ls ${web_install_dir}/conf/vhost | sed "s@.conf@@g" )
+  Domain_List_Caddy=$( [ -d "${caddy_install_dir}/conf/vhost" ] && ls ${caddy_install_dir}/conf/vhost | sed "s@.conf@@g" )
+  Domain_List_Apache=$( [ -e "${apache_install_dir}/bin/httpd" ] && ls ${apache_install_dir}/conf/vhost | grep -v '0.conf' | sed "s@.conf@@g" )
+  Domain_List_Tomcat=$( [ -e "${tomcat_install_dir}/conf/server.xml" ] && ls ${tomcat_install_dir}/conf/vhost | grep -v 'localhost.xml' | sed "s@.xml@@g" )
+  
+  Domain_List=$(echo "${Domain_List_Nginx} ${Domain_List_Caddy} ${Domain_List_Apache} ${Domain_List_Tomcat}" | tr ' ' '\n' | sort | uniq | xargs)
+  
   if [ -n "${Domain_List}" ]; then
     echo
     echo "Virtualhost list:"
@@ -1307,5 +1529,5 @@ if [ ${ARG_NUM} == 0 ]; then
 else
   [ "${add_flag}" == 'y' -o "${proxy_flag}" == 'y' -o "${sslquiet_flag}" == 'y' ] && Add_Vhost
   [ "${list_flag}" == 'y' ] && List_Vhost
-  [ "${delete_flag}" == 'y' ] && { Del_NGX_Vhost; Del_Apache_Vhost; Del_Tomcat_Vhost; }
+  [ "${delete_flag}" == 'y' ] && { Del_NGX_Vhost; Del_Apache_Vhost; Del_Tomcat_Vhost; Del_Caddy_Vhost; }
 fi