1
0

mphp.sh 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.cn
  4. #
  5. # Notes: OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+
  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. service php-fpm stop
  16. [ -e "/lib/systemd/system/php-fpm.service" ] && /bin/mv /lib/systemd/system/php-fpm.service{,_bk}
  17. [ -e "/etc/init.d/php-fpm" ] && /bin/mv /etc/init.d/php-fpm{,_bk}
  18. php_install_dir=${php_install_dir}${mphp_ver}
  19. case "${mphp_ver}" in
  20. 53)
  21. . include/php-5.3.sh
  22. Install_PHP53 2>&1 | tee -a ${oneinstack_dir}/install.log
  23. ;;
  24. 54)
  25. . include/php-5.4.sh
  26. Install_PHP54 2>&1 | tee -a ${oneinstack_dir}/install.log
  27. ;;
  28. 55)
  29. . include/php-5.5.sh
  30. Install_PHP55 2>&1 | tee -a ${oneinstack_dir}/install.log
  31. ;;
  32. 56)
  33. . include/php-5.6.sh
  34. Install_PHP56 2>&1 | tee -a ${oneinstack_dir}/install.log
  35. ;;
  36. 70)
  37. . include/php-7.0.sh
  38. Install_PHP70 2>&1 | tee -a ${oneinstack_dir}/install.log
  39. ;;
  40. 71)
  41. . include/php-7.1.sh
  42. Install_PHP71 2>&1 | tee -a ${oneinstack_dir}/install.log
  43. ;;
  44. 72)
  45. . include/php-7.2.sh
  46. Install_PHP72 2>&1 | tee -a ${oneinstack_dir}/install.log
  47. ;;
  48. 73)
  49. . include/php-7.3.sh
  50. Install_PHP73 2>&1 | tee -a ${oneinstack_dir}/install.log
  51. ;;
  52. esac
  53. if [ -e "${php_install_dir}/sbin/php-fpm" ]; then
  54. service php-fpm stop
  55. sed -i "s@/dev/shm/php-cgi.sock@/dev/shm/php${mphp_ver}-cgi.sock@" ${php_install_dir}/etc/php-fpm.conf
  56. [ -e "/lib/systemd/system/php-fpm.service" ] && /bin/mv /lib/systemd/system/php-fpm.service /lib/systemd/system/php${mphp_ver}-fpm.service
  57. [ -e "/etc/init.d/php-fpm" ] && /bin/mv /etc/init.d/php-fpm /etc/init.d/php${mphp_ver}-fpm
  58. [ -e "/lib/systemd/system/php-fpm.service_bk" ] && /bin/mv /lib/systemd/system/php-fpm.service{_bk,}
  59. [ -e "/etc/init.d/php-fpm_bk" ] && /bin/mv /etc/init.d/php-fpm /etc/init.d/php-fpm{_bk,}
  60. if [ -e /bin/systemctl ]; then
  61. systemctl enable php${mphp_ver}-fpm
  62. systemctl enable php-fpm
  63. else
  64. [ "${PM}" == 'yum' ] && { chkconfig --add php-fpm; chkconfig --add php${mphp_ver}-fpm; chkconfig php-fpm on; chkconfig php${mphp_ver}-fpm on; }
  65. [ "${PM}" == 'apt-get' ] && { update-rc.d php-fpm defaults; update-rc.d php${mphp_ver}-fpm defaults; }
  66. fi
  67. service php-fpm start
  68. service php${mphp_ver}-fpm start
  69. sed -i "s@${php_install_dir}/bin:@@" /etc/profile
  70. fi
  71. fi
  72. else
  73. echo "${CWARNING}To use the multiple PHP versions, You need to use PHP-FPM! ${CEND}"
  74. fi
  75. }