openssl.sh 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. php5_with_ssl="--with-ssl"
  20. php70_with_ssl="--with-ssl"
  21. php71_with_ssl="--with-ssl"
  22. php72_with_ssl="--with-ssl"
  23. php73_with_ssl="--with-ssl"
  24. php74_with_ssl="--with-ssl"
  25. php80_with_ssl="--with-ssl"
  26. php81_with_ssl="--with-ssl"
  27. php5_with_curl="--with-curl"
  28. php70_with_curl="--with-curl"
  29. php71_with_curl="--with-curl"
  30. php72_with_curl="--with-curl"
  31. php73_with_curl="--with-curl"
  32. php74_with_curl="--with-curl"
  33. php80_with_curl="--with-curl"
  34. php81_with_curl="--with-curl"
  35. elif openssl version | grep -Eqi 'OpenSSL 1.1.*'; then
  36. php5_with_openssl="--with-openssl=${openssl_install_dir}"
  37. php70_with_openssl="--with-openssl"
  38. php71_with_openssl="--with-openssl"
  39. php72_with_openssl="--with-openssl"
  40. php73_with_openssl="--with-openssl"
  41. php74_with_openssl="--with-openssl"
  42. php80_with_openssl="--with-openssl"
  43. php81_with_openssl="--with-openssl"
  44. php5_with_ssl="--with-ssl=${openssl_install_dir}"
  45. php70_with_ssl="--with-ssl"
  46. php71_with_ssl="--with-ssl"
  47. php72_with_ssl="--with-ssl"
  48. php73_with_ssl="--with-ssl"
  49. php74_with_ssl="--with-ssl"
  50. php80_with_ssl="--with-ssl"
  51. php81_with_ssl="--with-ssl"
  52. php5_with_curl="--with-curl=${curl_install_dir}"
  53. php70_with_curl="--with-curl"
  54. php71_with_curl="--with-curl"
  55. php72_with_curl="--with-curl"
  56. php73_with_curl="--with-curl"
  57. php74_with_curl="--with-curl"
  58. php80_with_curl="--with-curl"
  59. php81_with_curl="--with-curl"
  60. [[ ${php_option} =~ ^[1-4]$ ]] || [[ "${mphp_ver}" =~ ^5[3-6]$ ]] && with_old_openssl_flag=y
  61. elif openssl version | grep -Eqi 'OpenSSL 3.*'; then
  62. php5_with_openssl="--with-openssl=${openssl_install_dir}"
  63. php70_with_openssl="--with-openssl=${openssl_install_dir}"
  64. php71_with_openssl="--with-openssl"
  65. php72_with_openssl="--with-openssl"
  66. php73_with_openssl="--with-openssl"
  67. php74_with_openssl="--with-openssl"
  68. php80_with_openssl="--with-openssl"
  69. php81_with_openssl="--with-openssl"
  70. php5_with_ssl="--with-ssl=${openssl_install_dir}"
  71. php70_with_ssl="--with-ssl=${openssl_install_dir}"
  72. php71_with_ssl="--with-ssl"
  73. php72_with_ssl="--with-ssl"
  74. php73_with_ssl="--with-ssl"
  75. php74_with_ssl="--with-ssl"
  76. php80_with_ssl="--with-ssl"
  77. php81_with_ssl="--with-ssl"
  78. php5_with_curl="--with-curl=${curl_install_dir}"
  79. php70_with_curl="--with-curl=${curl_install_dir}"
  80. php71_with_curl="--with-curl"
  81. php72_with_curl="--with-curl"
  82. php73_with_curl="--with-curl"
  83. php74_with_curl="--with-curl"
  84. php80_with_curl="--with-curl"
  85. php81_with_curl="--with-curl"
  86. [[ ${php_option} =~ ^[1-5]$ ]] || [[ "${mphp_ver}" =~ ^5[3-6]$|^70$ ]] && with_old_openssl_flag=y
  87. else
  88. php5_with_openssl="--with-openssl=${openssl_install_dir}"
  89. php70_with_openssl="--with-openssl=${openssl_install_dir}"
  90. php71_with_openssl="--with-openssl=${openssl_install_dir}"
  91. php72_with_openssl="--with-openssl=${openssl_install_dir}"
  92. php73_with_openssl="--with-openssl=${openssl_install_dir}"
  93. php74_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}"
  94. php80_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}"
  95. php81_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}"
  96. php5_with_ssl="--with-ssl=${openssl_install_dir}"
  97. php70_with_ssl="--with-ssl=${openssl_install_dir}"
  98. php71_with_ssl="--with-ssl=${openssl_install_dir}"
  99. php72_with_ssl="--with-ssl=${openssl_install_dir}"
  100. php73_with_ssl="--with-ssl=${openssl_install_dir}"
  101. php74_with_ssl="--with-ssl=${openssl_install_dir}"
  102. php80_with_ssl="--with-ssl=${openssl_install_dir}"
  103. php81_with_ssl="--with-ssl=${openssl_install_dir}"
  104. php5_with_curl="--with-curl=${curl_install_dir}"
  105. php70_with_curl="--with-curl=${curl_install_dir}"
  106. php71_with_curl="--with-curl=${curl_install_dir}"
  107. php72_with_curl="--with-curl=${curl_install_dir}"
  108. php73_with_curl="--with-curl=${curl_install_dir}"
  109. php74_with_curl="--with-curl=${curl_install_dir}"
  110. php80_with_curl="--with-curl=${curl_install_dir}"
  111. php81_with_curl="--with-curl=${curl_install_dir}"
  112. with_old_openssl_flag=y
  113. fi
  114. Install_openSSL() {
  115. if [ "${with_old_openssl_flag}" == 'y' ]; then
  116. if [ ! -e "${openssl_install_dir}/lib/libssl.a" ]; then
  117. pushd ${oneinstack_dir}/src > /dev/null
  118. tar xzf openssl-${openssl_ver}.tar.gz
  119. pushd openssl-${openssl_ver} > /dev/null
  120. make clean
  121. ./config -Wl,-rpath=${openssl_install_dir}/lib -fPIC --prefix=${openssl_install_dir} --openssldir=${openssl_install_dir}
  122. make depend
  123. make -j ${THREAD} && make install
  124. popd > /dev/null
  125. if [ -f "${openssl_install_dir}/lib/libcrypto.a" ]; then
  126. echo "${CSUCCESS}openSSL installed successfully! ${CEND}"
  127. /bin/cp cacert.pem ${openssl_install_dir}/cert.pem
  128. rm -rf openssl-${openssl_ver}
  129. else
  130. echo "${CFAILURE}openSSL install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
  131. kill -9 $$; exit 1;
  132. fi
  133. popd > /dev/null
  134. fi
  135. fi
  136. }