mphp.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/oneinstack/oneinstack
  10. Install_MPHP() {
  11. if [ -e "${php_install_dir}/sbin/php-fpm" ]; then
  12. if [ -e "${php_install_dir}${mphp_ver}/bin/phpize" ]; then
  13. echo "${CWARNING}PHP${mphp_ver} already installed! ${CEND}"
  14. else
  15. [ -e "/lib/systemd/system/php-fpm.service" ] && /bin/mv /lib/systemd/system/php-fpm.service{,_bk}
  16. php_install_dir=${php_install_dir}${mphp_ver}
  17. case "${mphp_ver}" in
  18. 53)
  19. . include/php-5.3.sh
  20. Install_PHP53 2>&1 | tee -a ${oneinstack_dir}/install.log
  21. ;;
  22. 54)
  23. . include/php-5.4.sh
  24. Install_PHP54 2>&1 | tee -a ${oneinstack_dir}/install.log
  25. ;;
  26. 55)
  27. . include/php-5.5.sh
  28. Install_PHP55 2>&1 | tee -a ${oneinstack_dir}/install.log
  29. ;;
  30. 56)
  31. . include/php-5.6.sh
  32. Install_PHP56 2>&1 | tee -a ${oneinstack_dir}/install.log
  33. ;;
  34. 70)
  35. . include/php-7.0.sh
  36. Install_PHP70 2>&1 | tee -a ${oneinstack_dir}/install.log
  37. ;;
  38. 71)
  39. . include/php-7.1.sh
  40. Install_PHP71 2>&1 | tee -a ${oneinstack_dir}/install.log
  41. ;;
  42. 72)
  43. . include/php-7.2.sh
  44. Install_PHP72 2>&1 | tee -a ${oneinstack_dir}/install.log
  45. ;;
  46. 73)
  47. . include/php-7.3.sh
  48. Install_PHP73 2>&1 | tee -a ${oneinstack_dir}/install.log
  49. ;;
  50. 74)
  51. . include/php-7.4.sh
  52. Install_PHP74 2>&1 | tee -a ${oneinstack_dir}/install.log
  53. ;;
  54. 80)
  55. . include/php-8.0.sh
  56. Install_PHP80 2>&1 | tee -a ${oneinstack_dir}/install.log
  57. ;;
  58. 81)
  59. . include/php-8.1.sh
  60. Install_PHP81 2>&1 | tee -a ${oneinstack_dir}/install.log
  61. ;;
  62. 82)
  63. . include/php-8.2.sh
  64. Install_PHP82 2>&1 | tee -a ${oneinstack_dir}/install.log
  65. ;;
  66. 83)
  67. . include/php-8.3.sh
  68. Install_PHP83 2>&1 | tee -a ${oneinstack_dir}/install.log
  69. ;;
  70. esac
  71. if [ -e "${php_install_dir}/sbin/php-fpm" ]; then
  72. systemctl stop php-fpm
  73. sed -i "s@/dev/shm/php-cgi.sock@/dev/shm/php${mphp_ver}-cgi.sock@" ${php_install_dir}/etc/php-fpm.conf
  74. [ -e "/lib/systemd/system/php-fpm.service" ] && /bin/mv /lib/systemd/system/php-fpm.service /lib/systemd/system/php${mphp_ver}-fpm.service
  75. [ -e "/lib/systemd/system/php-fpm.service_bk" ] && /bin/mv /lib/systemd/system/php-fpm.service{_bk,}
  76. systemctl enable php${mphp_ver}-fpm
  77. systemctl enable php-fpm
  78. systemctl start php-fpm
  79. systemctl start php${mphp_ver}-fpm
  80. sed -i "s@${php_install_dir}/bin:@@" /etc/profile
  81. fi
  82. fi
  83. else
  84. echo "${CWARNING}To use the multiple PHP versions, You need to use PHP-FPM! ${CEND}"
  85. fi
  86. }