mphp.sh 3.3 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 8+ 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. [ -e "/etc/init.d/php-fpm" ] && /bin/mv /etc/init.d/php-fpm{,_bk}
  17. php_install_dir=${php_install_dir}${mphp_ver}
  18. case "${mphp_ver}" in
  19. 53)
  20. . include/php-5.3.sh
  21. Install_PHP53 2>&1 | tee -a ${oneinstack_dir}/install.log
  22. ;;
  23. 54)
  24. . include/php-5.4.sh
  25. Install_PHP54 2>&1 | tee -a ${oneinstack_dir}/install.log
  26. ;;
  27. 55)
  28. . include/php-5.5.sh
  29. Install_PHP55 2>&1 | tee -a ${oneinstack_dir}/install.log
  30. ;;
  31. 56)
  32. . include/php-5.6.sh
  33. Install_PHP56 2>&1 | tee -a ${oneinstack_dir}/install.log
  34. ;;
  35. 70)
  36. . include/php-7.0.sh
  37. Install_PHP70 2>&1 | tee -a ${oneinstack_dir}/install.log
  38. ;;
  39. 71)
  40. . include/php-7.1.sh
  41. Install_PHP71 2>&1 | tee -a ${oneinstack_dir}/install.log
  42. ;;
  43. 72)
  44. . include/php-7.2.sh
  45. Install_PHP72 2>&1 | tee -a ${oneinstack_dir}/install.log
  46. ;;
  47. 73)
  48. . include/php-7.3.sh
  49. Install_PHP73 2>&1 | tee -a ${oneinstack_dir}/install.log
  50. ;;
  51. 74)
  52. . include/php-7.4.sh
  53. Install_PHP74 2>&1 | tee -a ${oneinstack_dir}/install.log
  54. ;;
  55. 80)
  56. . include/php-8.0.sh
  57. Install_PHP80 2>&1 | tee -a ${oneinstack_dir}/install.log
  58. ;;
  59. 81)
  60. . include/php-8.1.sh
  61. Install_PHP81 2>&1 | tee -a ${oneinstack_dir}/install.log
  62. ;;
  63. esac
  64. if [ -e "${php_install_dir}/sbin/php-fpm" ]; then
  65. service php-fpm stop
  66. sed -i "s@/dev/shm/php-cgi.sock@/dev/shm/php${mphp_ver}-cgi.sock@" ${php_install_dir}/etc/php-fpm.conf
  67. [ -e "/lib/systemd/system/php-fpm.service" ] && /bin/mv /lib/systemd/system/php-fpm.service /lib/systemd/system/php${mphp_ver}-fpm.service
  68. [ -e "/etc/init.d/php-fpm" ] && /bin/mv /etc/init.d/php-fpm /etc/init.d/php${mphp_ver}-fpm
  69. [ -e "/lib/systemd/system/php-fpm.service_bk" ] && /bin/mv /lib/systemd/system/php-fpm.service{_bk,}
  70. [ -e "/etc/init.d/php-fpm_bk" ] && /bin/mv /etc/init.d/php-fpm{_bk,}
  71. if [ -e /bin/systemctl ]; then
  72. systemctl enable php${mphp_ver}-fpm
  73. systemctl enable php-fpm
  74. else
  75. [ "${PM}" == 'yum' ] && { chkconfig --add php-fpm; chkconfig --add php${mphp_ver}-fpm; chkconfig php-fpm on; chkconfig php${mphp_ver}-fpm on; }
  76. [ "${PM}" == 'apt-get' ] && { update-rc.d php-fpm defaults; update-rc.d php${mphp_ver}-fpm defaults; }
  77. fi
  78. service php-fpm start
  79. service php${mphp_ver}-fpm start
  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. }