migrate_ngnix_apache_nginx-php-fpm.sh 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/bash
  2. # Function Description
  3. # Manual upgrade script from Nginx + Apache2 + PHP-FPM to Nginx + PHP-FPM
  4. #----------------------------------------------------------#
  5. # Variable&Function #
  6. #----------------------------------------------------------#
  7. # Includes
  8. # shellcheck source=/etc/hestiacp/hestia.conf
  9. source /etc/hestiacp/hestia.conf
  10. # shellcheck source=/usr/local/hestia/func/main.sh
  11. source $HESTIA/func/main.sh
  12. # shellcheck source=/usr/local/hestia/conf/hestia.conf
  13. source $HESTIA/conf/hestia.conf
  14. #----------------------------------------------------------#
  15. # Verifications #
  16. #----------------------------------------------------------#
  17. if [ "$WEB_BACKEND" != "php-fpm" ]; then
  18. check_result $E_NOTEXISTS "PHP-FPM is not enabled" > /dev/null
  19. exit 1
  20. fi
  21. if [ "$WEB_SYSTEM" != "apache2" ]; then
  22. check_result $E_NOTEXISTS "Apache2 is not enabled" > /dev/null
  23. exit 1
  24. fi
  25. #----------------------------------------------------------#
  26. # Action #
  27. #----------------------------------------------------------#
  28. # Remove apache2 from config
  29. sed -i "/^WEB_PORT/d" $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
  30. sed -i "/^WEB_SSL/d" $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
  31. sed -i "/^WEB_SSL_PORT/d" $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
  32. sed -i "/^WEB_RGROUPS/d" $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
  33. sed -i "/^WEB_SYSTEM/d" $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
  34. # Remove nginx (proxy) from config
  35. sed -i "/^PROXY_PORT/d" $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
  36. sed -i "/^PROXY_SSL_PORT/d" $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
  37. sed -i "/^PROXY_SYSTEM/d" $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
  38. # Add Nginx settings to config
  39. echo "WEB_PORT='80'" >> $HESTIA/conf/hestia.conf
  40. echo "WEB_SSL='openssl'" >> $HESTIA/conf/hestia.conf
  41. echo "WEB_SSL_PORT='443'" >> $HESTIA/conf/hestia.conf
  42. echo "WEB_SYSTEM='nginx'" >> $HESTIA/conf/hestia.conf
  43. # Add Nginx settings to config
  44. echo "WEB_PORT='80'" >> $HESTIA/conf/defaults/hestia.conf
  45. echo "WEB_SSL='openssl'" >> $HESTIA/conf/defaults/hestia.conf
  46. echo "WEB_SSL_PORT='443'" >> $HESTIA/conf/defaults/hestia.conf
  47. echo "WEB_SYSTEM='nginx'" >> $HESTIA/conf/defaults/hestia.conf
  48. rm $HESTIA/conf/defaults/hestia.conf
  49. cp $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
  50. # Rebuild web config
  51. for user in $($BIN/v-list-users plain | cut -f1); do
  52. echo $user
  53. for domain in $($BIN/v-list-web-domains $user plain | cut -f1); do
  54. $BIN/v-change-web-domain-tpl $user $domain 'default'
  55. $BIN/v-rebuild-web-domain $user $domain no
  56. done
  57. done
  58. systemctl restart nginx