php.sh 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #!/bin/sh
  2. #move to script directory so all relative paths work
  3. cd "$(dirname "$0")"
  4. #includes
  5. . ../config.sh
  6. #remove php5
  7. /usr/bin/apt remove -y php5 php5-cli php5-fpm php5-pgsql php5-sqlite php5-odbc php5-curl php5-imap php5-gd
  8. #remove php 7.0
  9. /usr/bin/apt remove -y php7.0 php7.0-cli php7.0-fpm php7.0-pgsql php7.0-sqlite3 php7.0-odbc php7.0-curl php7.0-imap php7.0-xml php7.0-gd
  10. #remove php 7.1
  11. /usr/bin/apt remove -y php7.1 php7.1-cli php7.1-fpm php7.1-pgsql php7.1-sqlite3 php7.1-odbc php7.1-curl php7.1-imap php7.1-xml php7.1-gd
  12. #remove php 7.2
  13. /usr/bin/apt remove -y php7.2 php7.2-cli php7.2-fpm php7.2-pgsql php7.2-sqlite3 php7.2-odbc php7.2-curl php7.2-imap php7.2-xml php7.2-gd
  14. #remove php 7.3
  15. /usr/bin/apt remove -y php7.3 php7.3-cli php7.3-fpm php7.3-pgsql php7.3-sqlite3 php7.3-odbc php7.3-curl php7.3-imap php7.3-xml php7.3-gd
  16. #remove php 7.4
  17. /usr/bin/apt remove -y php7.4 php7.4-cli php7.4-fpm php7.4-pgsql php7.4-sqlite3 php7.4-odbc php7.4-curl php7.4-imap php7.4-xml php7.4-gd
  18. #remove php 8.1
  19. /usr/bin/apt remove -y php8.1 php8.1-cli php8.1-dev php8.1-fpm php8.1-pgsql php8.1-sqlite3 php8.1-odbc php8.1-curl php8.1-imap php8.1-xml php8.1-gd php8.1-mbstring php8.1-ldap
  20. #remove php 8.2
  21. /usr/bin/apt remove -y php8.2 php8.2-cli php8.2-dev php8.2-fpm php8.2-pgsql php8.2-sqlite3 php8.2-odbc php8.2-curl php8.2-imap php8.2-xml php8.2-gd php8.2-mbstring php8.2-ldap
  22. #remove php 8.3
  23. /usr/bin/apt remove -y php8.3 php8.3-cli php8.3-dev php8.3-fpm php8.3-pgsql php8.3-sqlite3 php8.3-odbc php8.3-curl php8.3-imap php8.3-xml php8.3-gd php8.3-mbstring php8.3-ldap
  24. #remove php 8.4
  25. /usr/bin/apt remove -y php8.4 php8.4-cli php8.4-dev php8.4-fpm php8.4-pgsql php8.4-sqlite3 php8.4-odbc php8.4-curl php8.4-imap php8.4-xml php8.4-gd php8.4-mbstring php8.4-ldap
  26. #install php update and set the unix socket
  27. if [ ."$php_version" = ."8.4" ]; then
  28. #add a repo for php 8.x
  29. /usr/bin/apt -y install apt-transport-https lsb-release ca-certificates curl wget gnupg2
  30. /usr/bin/wget -qO- https://packages.sury.org/php/apt.gpg | gpg --dearmor > /etc/apt/keyrings/sury-php-8.x.gpg
  31. /usr/bin/sh -c 'echo "deb [signed-by=/etc/apt/keyrings/php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
  32. /usr/bin/apt-get update
  33. #install php 8.4
  34. apt-get install -y php8.4 php8.4-cli php8.4-dev php8.4-fpm php8.4-pgsql php8.4-sqlite3 php8.4-odbc php8.4-curl php8.4-imap php8.4-xml php8.4-gd php8.4-mbstring php8.4-ldap
  35. #update the unix socket name
  36. /usr/bin/sed -i /etc/nginx/sites-available/fusionpbx -e 's#unix:.*;#unix:/var/run/php/php8.2-fpm.sock;#g'
  37. #set the PHP ini file path
  38. php_ini_file='/etc/php/8.4/fpm/php.ini'
  39. fi
  40. if [ ."$php_version" = ."8.3" ]; then
  41. #add a repo for php 8.x
  42. /usr/bin/apt -y install apt-transport-https lsb-release ca-certificates curl wget gnupg2
  43. /usr/bin/wget -qO- https://packages.sury.org/php/apt.gpg | gpg --dearmor > /etc/apt/keyrings/sury-php-8.x.gpg
  44. /usr/bin/sh -c 'echo "deb [signed-by=/etc/apt/keyrings/php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
  45. /usr/bin/apt-get update
  46. #install php 8.2
  47. apt-get install -y php8.3 php8.3-cli php8.3-dev php8.3-fpm php8.3-pgsql php8.3-sqlite3 php8.3-odbc php8.3-curl php8.3-imap php8.3-xml php8.3-gd php8.3-mbstring php8.3-ldap
  48. #update the unix socket name
  49. /usr/bin/sed -i /etc/nginx/sites-available/fusionpbx -e 's#unix:.*;#unix:/var/run/php/php8.2-fpm.sock;#g'
  50. #set the PHP ini file path
  51. php_ini_file='/etc/php/8.3/fpm/php.ini'
  52. fi
  53. if [ ."$php_version" = ."8.2" ]; then
  54. #add a repo for php 8.x
  55. /usr/bin/apt -y install apt-transport-https lsb-release ca-certificates curl wget gnupg2
  56. /usr/bin/wget -qO- https://packages.sury.org/php/apt.gpg | gpg --dearmor > /etc/apt/keyrings/sury-php-8.x.gpg
  57. /usr/bin/sh -c 'echo "deb [signed-by=/etc/apt/keyrings/php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
  58. /usr/bin/apt-get update
  59. #install php 8.2
  60. apt-get install -y php8.2 php8.2-cli php8.2-dev php8.2-fpm php8.2-pgsql php8.2-sqlite3 php8.2-odbc php8.2-curl php8.2-imap php8.2-xml php8.2-gd php8.2-mbstring php8.2-ldap
  61. #update the unix socket name
  62. /usr/bin/sed -i /etc/nginx/sites-available/fusionpbx -e 's#unix:.*;#unix:/var/run/php/php8.2-fpm.sock;#g'
  63. #set the PHP ini file path
  64. php_ini_file='/etc/php/8.2/fpm/php.ini'
  65. fi
  66. if [ ."$php_version" = ."8.1" ]; then
  67. #add a repo for php 7.x
  68. /usr/bin/apt -y install apt-transport-https lsb-release ca-certificates curl wget gnupg2
  69. /usr/bin/wget -qO- https://packages.sury.org/php/apt.gpg | gpg --dearmor > /etc/apt/keyrings/sury-php-8.x.gpg
  70. /usr/bin/sh -c 'echo "deb [signed-by=/etc/apt/keyrings/php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
  71. /usr/bin/apt-get update
  72. #install php 8.1
  73. /usr/bin/apt-get install -y php8.1 php8.1-cli php8.1-dev php8.1-fpm php8.1-pgsql php8.1-sqlite3 php8.1-odbc php8.1-curl php8.1-imap php8.1-xml php8.1-gd php8.1-mbstring php8.1-ldap
  74. #update the unix socket name
  75. /usr/bin/sed -i /etc/nginx/sites-available/fusionpbx -e 's#unix:.*;#unix:/var/run/php/php8.1-fpm.sock;#g'
  76. #set the PHP ini file path
  77. php_ini_file='/etc/php/8.1/fpm/php.ini'
  78. fi
  79. if [ ."$php_version" = ."7.4" ]; then
  80. #remove the sury PHP repo
  81. /usr/bin/rm -f -- /etc/apt/sources.list.d/php.list
  82. /usr/bin/apt update
  83. #install php 7.4
  84. /usr/bin/apt-get install -y php7.4 php7.4-cli php7.4-dev php7.4-fpm php7.4-pgsql php7.4-sqlite3 php7.4-odbc php7.4-curl php7.4-imap php7.4-xml php7.4-gd php7.4-mbstring php7.4-ldap
  85. #update the unix socket name
  86. /usr/bin/sed -i /etc/nginx/sites-available/fusionpbx -e 's#unix:.*;#unix:/var/run/php/php7.4-fpm.sock;#g'
  87. #set the PHP ini file path
  88. php_ini_file='/etc/php/7.4/fpm/php.ini'
  89. fi
  90. #update config if source is being used
  91. /usr/bin/sed 's#post_max_size = .*#post_max_size = 80M#g' -i $php_ini_file
  92. /usr/bin/sed 's#upload_max_filesize = .*#upload_max_filesize = 80M#g' -i $php_ini_file
  93. /usr/bin/sed 's#;max_input_vars = .*#max_input_vars = 8000#g' -i $php_ini_file
  94. /usr/bin/sed 's#; max_input_vars = .*#max_input_vars = 8000#g' -i $php_ini_file
  95. #restart nginx
  96. /usr/sbin/service nginx restart