openssl.sh 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/oneinstack/oneinstack
  10. if openssl version | grep -Eqi 'OpenSSL 1.0.2*'; then
  11. php5_with_openssl="--with-openssl"
  12. php70_with_openssl="--with-openssl"
  13. php71_with_openssl="--with-openssl"
  14. php72_with_openssl="--with-openssl"
  15. php73_with_openssl="--with-openssl"
  16. php74_with_openssl="--with-openssl"
  17. php80_with_openssl="--with-openssl"
  18. php81_with_openssl="--with-openssl"
  19. php82_with_openssl="--with-openssl"
  20. php83_with_openssl="--with-openssl"
  21. php5_with_ssl="--with-ssl"
  22. php70_with_ssl="--with-ssl"
  23. php71_with_ssl="--with-ssl"
  24. php72_with_ssl="--with-ssl"
  25. php73_with_ssl="--with-ssl"
  26. php74_with_ssl="--with-ssl"
  27. php80_with_ssl="--with-ssl"
  28. php81_with_ssl="--with-ssl"
  29. php82_with_ssl="--with-ssl"
  30. php83_with_ssl="--with-ssl"
  31. php5_with_curl="--with-curl"
  32. php70_with_curl="--with-curl"
  33. php71_with_curl="--with-curl"
  34. php72_with_curl="--with-curl"
  35. php73_with_curl="--with-curl"
  36. php74_with_curl="--with-curl"
  37. php80_with_curl="--with-curl"
  38. php81_with_curl="--with-curl"
  39. php82_with_curl="--with-curl"
  40. php83_with_curl="--with-curl"
  41. elif openssl version | grep -Eqi 'OpenSSL 1.1.*'; then
  42. php5_with_openssl="--with-openssl=${openssl_install_dir}"
  43. php70_with_openssl="--with-openssl"
  44. php71_with_openssl="--with-openssl"
  45. php72_with_openssl="--with-openssl"
  46. php73_with_openssl="--with-openssl"
  47. php74_with_openssl="--with-openssl"
  48. php80_with_openssl="--with-openssl"
  49. php81_with_openssl="--with-openssl"
  50. php82_with_openssl="--with-openssl"
  51. php83_with_openssl="--with-openssl"
  52. php5_with_ssl="--with-ssl=${openssl_install_dir}"
  53. php70_with_ssl="--with-ssl"
  54. php71_with_ssl="--with-ssl"
  55. php72_with_ssl="--with-ssl"
  56. php73_with_ssl="--with-ssl"
  57. php74_with_ssl="--with-ssl"
  58. php80_with_ssl="--with-ssl"
  59. php81_with_ssl="--with-ssl"
  60. php82_with_ssl="--with-ssl"
  61. php83_with_ssl="--with-ssl"
  62. php5_with_curl="--with-curl=${curl_install_dir}"
  63. php70_with_curl="--with-curl"
  64. php71_with_curl="--with-curl"
  65. php72_with_curl="--with-curl"
  66. php73_with_curl="--with-curl"
  67. php74_with_curl="--with-curl"
  68. php80_with_curl="--with-curl"
  69. php81_with_curl="--with-curl"
  70. php82_with_curl="--with-curl"
  71. php83_with_curl="--with-curl"
  72. [[ ${php_option} =~ ^[1-4]$ ]] || [[ "${mphp_ver}" =~ ^5[3-6]$ ]] && with_old_openssl_flag=y
  73. elif openssl version | grep -Eqi 'OpenSSL 3.*'; then
  74. php5_with_openssl="--with-openssl=${openssl_install_dir}"
  75. php70_with_openssl="--with-openssl=${openssl_install_dir}"
  76. php71_with_openssl="--with-openssl"
  77. php72_with_openssl="--with-openssl"
  78. php73_with_openssl="--with-openssl"
  79. php74_with_openssl="--with-openssl"
  80. php80_with_openssl="--with-openssl"
  81. php81_with_openssl="--with-openssl"
  82. php82_with_openssl="--with-openssl"
  83. php83_with_openssl="--with-openssl"
  84. php5_with_ssl="--with-ssl=${openssl_install_dir}"
  85. php70_with_ssl="--with-ssl=${openssl_install_dir}"
  86. php71_with_ssl="--with-ssl"
  87. php72_with_ssl="--with-ssl"
  88. php73_with_ssl="--with-ssl"
  89. php74_with_ssl="--with-ssl"
  90. php80_with_ssl="--with-ssl"
  91. php81_with_ssl="--with-ssl"
  92. php82_with_ssl="--with-ssl"
  93. php83_with_ssl="--with-ssl"
  94. php5_with_curl="--with-curl=${curl_install_dir}"
  95. php70_with_curl="--with-curl=${curl_install_dir}"
  96. php71_with_curl="--with-curl"
  97. php72_with_curl="--with-curl"
  98. php73_with_curl="--with-curl"
  99. php74_with_curl="--with-curl"
  100. php80_with_curl="--with-curl"
  101. php81_with_curl="--with-curl"
  102. php82_with_curl="--with-curl"
  103. php83_with_curl="--with-curl"
  104. [[ ${php_option} =~ ^[1-5]$ ]] || [[ "${mphp_ver}" =~ ^5[3-6]$|^70$ ]] && with_old_openssl_flag=y
  105. else
  106. php5_with_openssl="--with-openssl=${openssl_install_dir}"
  107. php70_with_openssl="--with-openssl=${openssl_install_dir}"
  108. php71_with_openssl="--with-openssl=${openssl_install_dir}"
  109. php72_with_openssl="--with-openssl=${openssl_install_dir}"
  110. php73_with_openssl="--with-openssl=${openssl_install_dir}"
  111. php74_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}"
  112. php80_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}"
  113. php81_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}"
  114. php82_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}"
  115. php83_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}"
  116. php5_with_ssl="--with-ssl=${openssl_install_dir}"
  117. php70_with_ssl="--with-ssl=${openssl_install_dir}"
  118. php71_with_ssl="--with-ssl=${openssl_install_dir}"
  119. php72_with_ssl="--with-ssl=${openssl_install_dir}"
  120. php73_with_ssl="--with-ssl=${openssl_install_dir}"
  121. php74_with_ssl="--with-ssl=${openssl_install_dir}"
  122. php80_with_ssl="--with-ssl=${openssl_install_dir}"
  123. php81_with_ssl="--with-ssl=${openssl_install_dir}"
  124. php82_with_ssl="--with-ssl=${openssl_install_dir}"
  125. php83_with_ssl="--with-ssl=${openssl_install_dir}"
  126. php5_with_curl="--with-curl=${curl_install_dir}"
  127. php70_with_curl="--with-curl=${curl_install_dir}"
  128. php71_with_curl="--with-curl=${curl_install_dir}"
  129. php72_with_curl="--with-curl=${curl_install_dir}"
  130. php73_with_curl="--with-curl=${curl_install_dir}"
  131. php74_with_curl="--with-curl=${curl_install_dir}"
  132. php80_with_curl="--with-curl=${curl_install_dir}"
  133. php81_with_curl="--with-curl=${curl_install_dir}"
  134. php82_with_curl="--with-curl=${curl_install_dir}"
  135. php83_with_curl="--with-curl=${curl_install_dir}"
  136. with_old_openssl_flag=y
  137. fi
  138. Install_openSSL() {
  139. if [ "${with_old_openssl_flag}" == 'y' ]; then
  140. if [ ! -e "${openssl_install_dir}/lib/libssl.a" ]; then
  141. pushd ${oneinstack_dir}/src > /dev/null
  142. tar xzf openssl-${openssl_ver}.tar.gz
  143. pushd openssl-${openssl_ver} > /dev/null
  144. make clean
  145. ./config -Wl,-rpath=${openssl_install_dir}/lib -fPIC --prefix=${openssl_install_dir} --openssldir=${openssl_install_dir}
  146. make depend
  147. make -j ${THREAD} && make install
  148. popd > /dev/null
  149. if [ -f "${openssl_install_dir}/lib/libcrypto.a" ]; then
  150. echo "${CSUCCESS}openSSL installed successfully! ${CEND}"
  151. /bin/cp cacert.pem ${openssl_install_dir}/cert.pem
  152. rm -rf openssl-${openssl_ver}
  153. else
  154. echo "${CFAILURE}openSSL install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
  155. kill -9 $$; exit 1;
  156. fi
  157. popd > /dev/null
  158. fi
  159. fi
  160. }