Ver Fonte

Update php-8.4.sh

Fix install succeed, but print failed.
Delete Chinese comments.
Helov há 3 meses atrás
pai
commit
154cecb4ce
1 ficheiros alterados com 45 adições e 146 exclusões
  1. 45 146
      include/php-8.4.sh

+ 45 - 146
include/php-8.4.sh

@@ -69,244 +69,132 @@ Install_PHP84() {
     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
-
-      # 设置php.ini配置
       tee -a ${php_install_dir}/etc/php.ini <<EOF
 
-; 内存限制
-memory_limit = 256M
-
-; 输出缓冲
+;Modify php.ini Config by User
+memory_limit = 512M
 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
-
-; 输出缓冲
+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配置
+      # 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@^;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
+;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配置
+      # 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 = -1
-
-; 允许客户端
+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 = 12
-
-; 启动进程数
-pm.start_servers = 8
-
-; 最小空闲进程数
-pm.min_spare_servers = 6
-
-; 最大空闲进程数
-pm.max_spare_servers = 12
-
-; 最大请求数
-pm.max_requests = 2048
-
-; 进程空闲超时
+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
-
-; 请求超时
-request_terminate_timeout = 120
-
-; 慢日志超时
-request_slowlog_timeout = 0
-
-; 状态路径
 pm.status_path = /php-fpm_status
 
-; 慢日志
+request_terminate_timeout = 300
+request_slowlog_timeout = 10s
 slowlog = var/log/slow.log
-
-; 文件限制
-rlimit_files = 51200
-
-; 核心限制
+rlimit_files = 65535
 rlimit_core = 0
-
-; 捕获工作者输出
 catch_workers_output = yes
 
-; 环境变量
-env[HOSTNAME] = $HOSTNAME
+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[PATH] = /usr/local/bin:/usr/bin:/bin
 env[TMP] = /tmp
 env[TMPDIR] = /tmp
 env[TEMP] = /tmp
+
 EOF
 
-      # 设置php-fpm内存优化
+      # 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
@@ -314,7 +202,18 @@ EOF
       # 启动脚本
       \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 php-fpm
+      systemctl enable --now php-fpm.service
+
+      # 检测php-fpm是否启动成功,没有成功则重启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