1
0

php-8.4.sh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/bin/bash
  2. Install_PHP84() {
  3. # Check CentOS version
  4. if [ -f /etc/redhat-release ]; then
  5. OS_VERSION=$(grep -oE '[0-9]+\.[0-9]+' /etc/redhat-release | cut -d'.' -f1)
  6. if [ "${OS_VERSION}" -lt "8" ]; then
  7. echo "${CFAILURE}Error: PHP 8.4 cannot be installed on CentOS ${OS_VERSION}. Minimum required version is CentOS 8.${CEND}"
  8. kill -9 $$; exit 1;
  9. fi
  10. fi
  11. pushd ${oneinstack_dir}/src > /dev/null
  12. if [ ! -e "${php_install_dir}/bin/phpize" ]; then
  13. PHP_version=8.4.4
  14. PHP_main_ver=84
  15. # 下载和校验
  16. src_url=https://www.php.net/distributions/php-${PHP_version}.tar.gz && Download_src
  17. # 编译安装
  18. tar xzf php-${PHP_version}.tar.gz
  19. pushd php-${PHP_version} > /dev/null
  20. make clean
  21. [ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir}
  22. # PHP 8.4 特定的编译选项
  23. ./configure --prefix=${php_install_dir} \
  24. --with-config-file-path=${php_install_dir}/etc \
  25. --with-config-file-scan-dir=${php_install_dir}/etc/php.d \
  26. --with-fpm-user=${run_user} \
  27. --with-fpm-group=${run_user} \
  28. --enable-mysqlnd \
  29. --with-mysqli=mysqlnd \
  30. --with-pdo-mysql=mysqlnd \
  31. --with-sqlite3 \
  32. --with-pdo-sqlite \
  33. --with-openssl \
  34. --with-zlib \
  35. --with-zip \
  36. --with-curl \
  37. --with-iconv \
  38. --with-gettext \
  39. --with-readline \
  40. --with-ldapsasl \
  41. --with-sodium \
  42. --enable-bcmath \
  43. --enable-fpm \
  44. --enable-xml \
  45. --enable-sysvsem \
  46. --enable-sysvshm \
  47. --enable-sysvmsg \
  48. --enable-shmop \
  49. --enable-sockets \
  50. --enable-mbstring \
  51. --enable-pcntl \
  52. --enable-soap \
  53. --enable-gd \
  54. --enable-intl \
  55. --enable-opcache \
  56. --enable-ftp \
  57. --enable-exif \
  58. --enable-calendar \
  59. --without-pear \
  60. --disable-phar \
  61. --disable-rpath
  62. make -j ${THREAD} && make install
  63. if [ -e "${php_install_dir}/bin/phpize" ]; then
  64. # 配置文件
  65. mkdir -p ${php_install_dir}/etc/php.d
  66. \cp php.ini-production ${php_install_dir}/etc/php.ini
  67. # PHP-FPM配置
  68. \cp sapi/fpm/php-fpm.conf.in ${php_install_dir}/etc/php-fpm.conf
  69. \cp sapi/fpm/www.conf.in ${php_install_dir}/etc/php-fpm.d/www.conf
  70. sed -i "s@^;pid = run/php-fpm.pid@pid = run/php-fpm.pid@" ${php_install_dir}/etc/php-fpm.conf
  71. # 启动脚本
  72. \cp ${oneinstack_dir}/init.d/php-fpm.service /lib/systemd/system/
  73. sed -i "s@/usr/local/php@${php_install_dir}@g" /lib/systemd/system/php-fpm.service
  74. systemctl enable php-fpm
  75. # 环境变量
  76. echo "export PATH=${php_install_dir}/bin:\$PATH" > /etc/profile.d/php.sh
  77. echo "${CSUCCESS}PHP ${PHP_version} installed successfully! ${CEND}"
  78. rm -rf php-${PHP_version}
  79. else
  80. rm -rf ${php_install_dir}
  81. echo "${CFAILURE}PHP ${PHP_version} install failed, Please Contact the author! ${CEND}"
  82. kill -9 $$; exit 1;
  83. fi
  84. popd > /dev/null
  85. fi
  86. popd > /dev/null
  87. }