Parcourir la source

Merge pull request #551 from Helov/main

Fix php 8.4 install and config bugs.
Update Some lib Versions
OneinStack il y a 3 mois
Parent
commit
bb4a17c52d
3 fichiers modifiés avec 242 ajouts et 8 suppressions
  1. 235 2
      include/php-8.4.sh
  2. 2 2
      install.sh
  3. 5 4
      versions.txt

+ 235 - 2
include/php-8.4.sh

@@ -72,11 +72,244 @@ Install_PHP84() {
       # 配置文件
       mkdir -p ${php_install_dir}/etc/php.d
       \cp php.ini-production ${php_install_dir}/etc/php.ini
+
+      # 设置php.ini配置
+      tee -a ${php_install_dir}/etc/php.ini <<EOF
+
+; 内存限制
+memory_limit = 256M
+
+; 输出缓冲
+output_buffering = On
+
+; 输出缓冲
+output_buffering =
+
+; 短标签
+short_open_tag = On
+
+; 暴露php出错信息
+expose_php = Off
+
+; 请求顺序
+request_order = "CGP"
+
+; 时区
+date.timezone = ${timezone}
+
+; 最大上传大小
+post_max_size = 100M
+
+; 最大上传大小
+upload_max_filesize = 50M
+
+; 最大执行时间
+max_execution_time = 600
+
+; 输出缓冲
+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
+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配置
       \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@^;pid = run/php-fpm.pid@pid = run/php-fpm.pid@" ${php_install_dir}/etc/php-fpm.conf
+      #sed -i "s@^;pid = run/php-fpm.pid@pid = run/php-fpm.pid@" ${php_install_dir}/etc/php-fpm.conf
+
+      # 设置php-fpm.conf配置
+      sed -i "s@^include=@;include=@" ${php_install_dir}/etc/php-fpm.conf
+      tee -a ${php_install_dir}/etc/php-fpm.conf <<EOF
+
+; 进程ID
+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
+
+[${run_user}]
+; 监听
+listen = /dev/shm/php-cgi.sock
+
+; 监听队列
+listen.backlog = -1
+
+; 允许客户端
+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 = 12
+
+; 启动进程数
+pm.start_servers = 8
+
+; 最小空闲进程数
+pm.min_spare_servers = 6
+
+; 最大空闲进程数
+pm.max_spare_servers = 12
+
+; 最大请求数
+pm.max_requests = 2048
+
+; 进程空闲超时
+pm.process_idle_timeout = 10s
+
+; 请求超时
+request_terminate_timeout = 120
+
+; 慢日志超时
+request_slowlog_timeout = 0
+
+; 状态路径
+pm.status_path = /php-fpm_status
+
+; 慢日志
+slowlog = var/log/slow.log
+
+; 文件限制
+rlimit_files = 51200
+
+; 核心限制
+rlimit_core = 0
+
+; 捕获工作者输出
+catch_workers_output = yes
+
+; 环境变量
+env[HOSTNAME] = $HOSTNAME
+env[PATH] = /usr/local/bin:/usr/bin:/bin
+env[TMP] = /tmp
+env[TMPDIR] = /tmp
+env[TEMP] = /tmp
+EOF
+
+      # 设置php-fpm内存优化
+      if [ $Mem -gt 8500 ]; then
+        tee -a ${php_install_dir}/etc/php-fpm.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.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.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.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.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/
@@ -96,4 +329,4 @@ Install_PHP84() {
     popd > /dev/null
   fi
   popd > /dev/null
-}
+}

+ 2 - 2
install.sh

@@ -651,8 +651,8 @@ if [ ${ARG_NUM} == 0 ]; then
           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-3]$ ]]; then
-            echo "${CWARNING}input error! Please only input number 1~13${CEND}"
+          if [[ ! ${php_option} =~ ^[1-9]$|^1[0-4]$ ]]; then
+            echo "${CWARNING}input error! Please only input number 1~14${CEND}"
           else
             break
           fi

+ 5 - 4
versions.txt

@@ -53,6 +53,7 @@ php80_ver=8.0.30
 php81_ver=8.1.27
 php82_ver=8.2.14
 php83_ver=8.3.2
+php84_ver=8.4.4
 
 # Nodejs
 nodejs_ver=20.10.0
@@ -68,7 +69,7 @@ libsodium_ver=1.0.18
 libsodium_up_ver=1.0.19
 libzip_ver=1.2.0
 argon2_ver=20171227
-imagemagick_ver=7.1.1-23
+imagemagick_ver=7.1.1-45
 imagick_ver=3.7.0
 imagick_oldver=3.4.4
 graphicsmagick_ver=1.3.40
@@ -83,7 +84,7 @@ phalcon_ver=5.4.0
 phalcon_oldver=3.4.5
 yaf_ver=3.3.2
 yar_ver=2.2.0
-swoole_ver=5.0.3
+swoole_ver=6.0.1
 swoole_oldver=4.8.12
 xdebug_ver=3.1.2
 xdebug_oldver=2.9.8
@@ -94,7 +95,7 @@ pureftpd_ver=1.0.51
 # Redis
 redis_ver=7.2.3
 redis_oldver=6.2.14
-pecl_redis_ver=6.0.2
+pecl_redis_ver=6.1.0
 
 # Memcached
 memcached_ver=1.6.22
@@ -105,7 +106,7 @@ pecl_memcache_ver=8.2
 pecl_memcache_oldver=4.0.5.2
 
 # MongoDB
-pecl_mongodb_ver=1.16.2
+pecl_mongodb_ver=1.21.0
 pecl_mongodb_oldver=1.9.2
 pecl_mongo_ver=1.6.16