mphp.sh 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. esac
  63. if [ -e "${php_install_dir}/sbin/php-fpm" ]; then
  64. systemctl stop php-fpm
  65. sed -i "s@/dev/shm/php-cgi.sock@/dev/shm/php${mphp_ver}-cgi.sock@" ${php_install_dir}/etc/php-fpm.conf
  66. [ -e "/lib/systemd/system/php-fpm.service" ] && /bin/mv /lib/systemd/system/php-fpm.service /lib/systemd/system/php${mphp_ver}-fpm.service
  67. [ -e "/lib/systemd/system/php-fpm.service_bk" ] && /bin/mv /lib/systemd/system/php-fpm.service{_bk,}
  68. systemctl enable php${mphp_ver}-fpm
  69. systemctl enable php-fpm
  70. systemctl start php-fpm
  71. systemctl start php${mphp_ver}-fpm
  72. sed -i "s@${php_install_dir}/bin:@@" /etc/profile
  73. fi
  74. fi
  75. else
  76. echo "${CWARNING}To use the multiple PHP versions, You need to use PHP-FPM! ${CEND}"
  77. fi
  78. }