php.sh 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. #!/bin/sh
  2. #move to script directory so all relative paths work
  3. cd "$(dirname "$0")"
  4. #includes
  5. . ./config.sh
  6. . ./colors.sh
  7. . ./environment.sh
  8. #send a message
  9. verbose "Configuring PHP"
  10. #add the repository
  11. if [ ."$os_name" = ."Ubuntu" ]; then
  12. #16.10.x - */yakkety/
  13. #16.04.x - */xenial/
  14. #14.04.x - */trusty/
  15. if [ ."$os_codename" = ."trusty" ]; then
  16. which add-apt-repository || apt-get install -y software-properties-common
  17. LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
  18. fi
  19. elif [ ."$cpu_architecture" = ."arm" ]; then
  20. #Pi2 and Pi3 Raspbian, #Odroid
  21. #if [ ."$os_codename" = ."stretch" ]; then
  22. # php_version=7.0
  23. #fi
  24. if [ ."$os_codename" = ."buster" ]; then
  25. php_version=7.3
  26. fi
  27. if [ ."$os_codename" = ."bullseye" ]; then
  28. php_version=7.4
  29. fi
  30. if [ ."$os_codename" = ."bookworm" ]; then
  31. php_version=8.2
  32. fi
  33. else
  34. #11.x - bullseye
  35. #10.x - buster
  36. #9.x - stretch
  37. #8.x - jessie
  38. apt-get -y install apt-transport-https lsb-release ca-certificates
  39. #make sure keyrings directory exits
  40. mkdir /etc/apt/keyrings
  41. if [ ."$os_codename" = ."jessie" ]; then
  42. wget -O - https://packages.sury.org/php/apt.gpg | gpg --dearmor -o /etc/apt/keyrings/php.gpg
  43. 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'
  44. fi
  45. if [ ."$os_codename" = ."stretch" ]; then
  46. wget -O - https://packages.sury.org/php/apt.gpg | gpg --dearmor -o /etc/apt/keyrings/php.gpg
  47. 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'
  48. fi
  49. if [ ."$os_codename" = ."buster" ]; then
  50. wget -O - https://packages.sury.org/php/apt.gpg | gpg --dearmor -o /etc/apt/keyrings/php.gpg
  51. 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'
  52. fi
  53. if [ ."$os_codename" = ."bullseye" ]; then
  54. if [ ."$php_version" = ."8.1" ]; then
  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/sury-php-8.x.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
  58. fi
  59. if [ ."$php_version" = ."8.2" ]; then
  60. /usr/bin/apt -y install apt-transport-https lsb-release ca-certificates curl wget gnupg2
  61. /usr/bin/wget -qO- https://packages.sury.org/php/apt.gpg | gpg --dearmor > /etc/apt/keyrings/sury-php-8.x.gpg
  62. /usr/bin/sh -c 'echo "deb [signed-by=/etc/apt/keyrings/sury-php-8.x.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
  63. fi
  64. fi
  65. if [ ."$os_codename" = ."bookworm" ]; then
  66. if [ ."$php_version" = ."8.1" ]; then
  67. /usr/bin/apt -y install apt-transport-https lsb-release ca-certificates curl wget gnupg2
  68. /usr/bin/wget -qO- https://packages.sury.org/php/apt.gpg | gpg --dearmor > /etc/apt/keyrings/sury-php-8.x.gpg
  69. /usr/bin/chmod 644 /etc/apt/keyrings/sury-php-8.x.gpg
  70. /usr/bin/sh -c 'echo "deb [signed-by=/etc/apt/keyrings/sury-php-8.x.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
  71. fi
  72. if [ ."$php_version" = ."8.2" ]; then
  73. /usr/bin/apt -y install apt-transport-https lsb-release ca-certificates curl wget gnupg2
  74. /usr/bin/wget -qO- https://packages.sury.org/php/apt.gpg | gpg --dearmor > /etc/apt/keyrings/sury-php-8.x.gpg
  75. /usr/bin/chmod 644 /etc/apt/keyrings/sury-php-8.x.gpg
  76. /usr/bin/sh -c 'echo "deb [signed-by=/etc/apt/keyrings/sury-php-8.x.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
  77. fi
  78. fi
  79. fi
  80. apt-get update -y
  81. #install dependencies
  82. apt-get install -y nginx
  83. if [ ."$php_version" = ."" ]; then
  84. apt-get install -y php php-cli php-fpm php-pgsql php-sqlite3 php-odbc php-curl php-imap php-xml php-gd php-inotify
  85. fi
  86. if [ ."$php_version" = ."5.6" ]; then
  87. apt-get install -y php5 php5-cli php5-fpm php5-pgsql php5-sqlite php5-odbc php5-curl php5-imap php5-gd
  88. fi
  89. if [ ."$php_version" = ."7.0" ]; then
  90. apt-get install -y --no-install-recommends php7.0 php7.0-common 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 php7.0-mbstring php7.0-inotify
  91. fi
  92. if [ ."$php_version" = ."7.1" ]; then
  93. apt-get install -y --no-install-recommends php7.1 php7.1-common 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 php7.1-mbstring php7.1-inotify
  94. fi
  95. if [ ."$php_version" = ."7.2" ]; then
  96. apt-get install -y --no-install-recommends php7.2 php7.2-common 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 php7.2-mbstring php7.2-inotify
  97. fi
  98. if [ ."$php_version" = ."7.3" ]; then
  99. apt-get install -y --no-install-recommends php7.3 php7.3-common 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 php7.3-mbstring php7.3-inotify
  100. fi
  101. if [ ."$php_version" = ."7.4" ]; then
  102. apt-get install -y --no-install-recommends php7.4 php7.4-common 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-inotify
  103. fi
  104. if [ ."$php_version" = ."8.1" ]; then
  105. apt-get install -y --no-install-recommends php8.1 php8.1-common 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 php8.1-inotify
  106. fi
  107. if [ ."$php_version" = ."8.2" ]; then
  108. apt-get install -y --no-install-recommends php8.2 php8.2-common 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 php8.2-inotify
  109. fi
  110. #update config if source is being used
  111. if [ ."$php_version" = ."5" ]; then
  112. verbose "version 5.x"
  113. php_ini_file='/etc/php5/fpm/php.ini'
  114. fi
  115. if [ ."$php_version" = ."7.0" ]; then
  116. verbose "version 7.0"
  117. php_ini_file='/etc/php/7.0/fpm/php.ini'
  118. fi
  119. if [ ."$php_version" = ."7.1" ]; then
  120. verbose "version 7.1"
  121. php_ini_file='/etc/php/7.1/fpm/php.ini'
  122. fi
  123. if [ ."$php_version" = ."7.2" ]; then
  124. verbose "version 7.2"
  125. php_ini_file='/etc/php/7.2/fpm/php.ini'
  126. fi
  127. if [ ."$php_version" = ."7.3" ]; then
  128. verbose "version 7.3"
  129. php_ini_file='/etc/php/7.3/fpm/php.ini'
  130. fi
  131. if [ ."$php_version" = ."7.4" ]; then
  132. verbose "version 7.4"
  133. php_ini_file='/etc/php/7.4/fpm/php.ini'
  134. fi
  135. if [ ."$php_version" = ."8.1" ]; then
  136. verbose "version 8.1"
  137. php_ini_file='/etc/php/8.1/fpm/php.ini'
  138. fi
  139. if [ ."$php_version" = ."8.2" ]; then
  140. verbose "version 8.2"
  141. php_ini_file='/etc/php/8.2/fpm/php.ini'
  142. fi
  143. sed 's#post_max_size = .*#post_max_size = 80M#g' -i $php_ini_file
  144. sed 's#upload_max_filesize = .*#upload_max_filesize = 80M#g' -i $php_ini_file
  145. sed 's#;max_input_vars = .*#max_input_vars = 8000#g' -i $php_ini_file
  146. sed 's#; max_input_vars = .*#max_input_vars = 8000#g' -i $php_ini_file
  147. #install ioncube
  148. if [ .$cpu_architecture = .'x86' ]; then
  149. . ./ioncube.sh
  150. fi
  151. #restart php-fpm
  152. systemctl daemon-reload
  153. if [ ."$php_version" = ."5.6" ]; then
  154. systemctl restart php5-fpm
  155. fi
  156. if [ ."$php_version" = ."7.0" ]; then
  157. systemctl restart php7.0-fpm
  158. fi
  159. if [ ."$php_version" = ."7.1" ]; then
  160. systemctl restart php7.1-fpm
  161. fi
  162. if [ ."$php_version" = ."7.2" ]; then
  163. systemctl restart php7.2-fpm
  164. fi
  165. if [ ."$php_version" = ."7.3" ]; then
  166. systemctl restart php7.3-fpm
  167. fi
  168. if [ ."$php_version" = ."7.4" ]; then
  169. systemctl restart php7.4-fpm
  170. fi
  171. if [ ."$php_version" = ."8.1" ]; then
  172. systemctl restart php8.1-fpm
  173. fi
  174. if [ ."$php_version" = ."8.2" ]; then
  175. systemctl restart php8.2-fpm
  176. fi
  177. #init.d
  178. #/usr/sbin/service php5-fpm restart
  179. #/usr/sbin/service php7.0-fpm restart