mphp.sh 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RedHat 6+ Debian 8+ and Ubuntu 14+
  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. esac
  60. if [ -e "${php_install_dir}/sbin/php-fpm" ]; then
  61. service php-fpm stop
  62. sed -i "s@/dev/shm/php-cgi.sock@/dev/shm/php${mphp_ver}-cgi.sock@" ${php_install_dir}/etc/php-fpm.conf
  63. [ -e "/lib/systemd/system/php-fpm.service" ] && /bin/mv /lib/systemd/system/php-fpm.service /lib/systemd/system/php${mphp_ver}-fpm.service
  64. [ -e "/etc/init.d/php-fpm" ] && /bin/mv /etc/init.d/php-fpm /etc/init.d/php${mphp_ver}-fpm
  65. [ -e "/lib/systemd/system/php-fpm.service_bk" ] && /bin/mv /lib/systemd/system/php-fpm.service{_bk,}
  66. [ -e "/etc/init.d/php-fpm_bk" ] && /bin/mv /etc/init.d/php-fpm{_bk,}
  67. if [ -e /bin/systemctl ]; then
  68. systemctl enable php${mphp_ver}-fpm
  69. systemctl enable php-fpm
  70. else
  71. [ "${PM}" == 'yum' ] && { chkconfig --add php-fpm; chkconfig --add php${mphp_ver}-fpm; chkconfig php-fpm on; chkconfig php${mphp_ver}-fpm on; }
  72. [ "${PM}" == 'apt-get' ] && { update-rc.d php-fpm defaults; update-rc.d php${mphp_ver}-fpm defaults; }
  73. fi
  74. service php-fpm start
  75. service php${mphp_ver}-fpm start
  76. sed -i "s@${php_install_dir}/bin:@@" /etc/profile
  77. fi
  78. fi
  79. else
  80. echo "${CWARNING}To use the multiple PHP versions, You need to use PHP-FPM! ${CEND}"
  81. fi
  82. }