vhost.sh 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.cn
  4. #
  5. # Notes: OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/oneinstack/oneinstack
  10. export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
  11. clear
  12. printf "
  13. #######################################################################
  14. # OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+ #
  15. # For more information please visit https://oneinstack.com #
  16. #######################################################################
  17. "
  18. # Check if user is root
  19. [ $(id -u) != '0' ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
  20. oneinstack_dir=$(dirname "`readlink -f $0`")
  21. pushd ${oneinstack_dir} > /dev/null
  22. . ./options.conf
  23. . ./include/color.sh
  24. . ./include/check_dir.sh
  25. . ./include/check_os.sh
  26. . ./include/get_char.sh
  27. Show_Help() {
  28. echo
  29. echo "Usage: $0 command ...[parameters]....
  30. --help, -h Show this help message
  31. --quiet, -q quiet operation
  32. --list, -l List Virtualhost
  33. --mphp_ver [53~73] Use another PHP version (PATH: /usr/local/php${mphp_ver})
  34. --add Add Virtualhost
  35. --delete, --del Delete Virtualhost
  36. --httponly Use HTTP Only
  37. --selfsigned Use your own SSL Certificate and Key
  38. --letsencrypt Use Let's Encrypt to Create SSL Certificate and Key
  39. --dnsapi Use dns API to automatically issue Let's Encrypt Cert
  40. "
  41. }
  42. ARG_NUM=$#
  43. TEMP=`getopt -o hql --long help,quiet,list,mphp_ver:,add,delete,del,httponly,selfsigned,letsencrypt,dnsapi -- "$@" 2>/dev/null`
  44. [ $? != 0 ] && echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1
  45. eval set -- "${TEMP}"
  46. while :; do
  47. [ -z "$1" ] && break;
  48. case "$1" in
  49. -h|--help)
  50. Show_Help; exit 0
  51. ;;
  52. -q|--quiet)
  53. quiet_flag=y; shift 1
  54. ;;
  55. -l|--list)
  56. list_flag=y; shift 1
  57. ;;
  58. --mphp_ver)
  59. mphp_ver=$2; mphp_flag=y; shift 2
  60. [[ ! "${mphp_ver}" =~ ^5[3-6]$|^7[0-3]$ ]] && { echo "${CWARNING}mphp_ver input error! Please only input number 53~73${CEND}"; unset mphp_ver mphp_flag; }
  61. ;;
  62. --add)
  63. add_flag=y; shift 1
  64. ;;
  65. --delete|--del)
  66. delete_flag=y; shift 1
  67. ;;
  68. --httponly)
  69. sslquiet_flag=y
  70. httponly_flag=y
  71. Domian_Mode=1
  72. shift 1
  73. ;;
  74. --selfsigned)
  75. sslquiet_flag=y
  76. selfsigned_flag=y
  77. Domian_Mode=2
  78. shift 1
  79. ;;
  80. --letsencrypt)
  81. sslquiet_flag=y
  82. letsencrypt_flag=y
  83. Domian_Mode=3
  84. shift 1
  85. ;;
  86. --dnsapi)
  87. sslquiet_flag=y
  88. dnsapi_flag=y
  89. letsencrypt_flag=y
  90. shift 1
  91. ;;
  92. --)
  93. shift
  94. ;;
  95. *)
  96. echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1
  97. ;;
  98. esac
  99. done
  100. Choose_ENV() {
  101. if [ -e "${apache_install_dir}/bin/apachectl" ];then
  102. [ "$(${apache_install_dir}/bin/apachectl -v | awk -F'.' /version/'{print $2}')" == '4' ] && { Apache_main_ver=24; Apache_grant='Require all granted'; }
  103. [ "$(${apache_install_dir}/bin/apachectl -v | awk -F'.' /version/'{print $2}')" == '2' ] && Apache_main_ver=22
  104. fi
  105. if [ -e "${php_install_dir}/bin/phpize" -a -e "${tomcat_install_dir}/conf/server.xml" -a -e "/usr/bin/hhvm" ]; then
  106. Number=111
  107. while :; do echo
  108. echo "Please choose to use environment:"
  109. echo -e "\t${CMSG}1${CEND}. Use php"
  110. echo -e "\t${CMSG}2${CEND}. Use java"
  111. echo -e "\t${CMSG}3${CEND}. Use hhvm"
  112. read -e -p "Please input a number:(Default 1 press Enter) " ENV_FLAG
  113. ENV_FLAG=${ENV_FLAG:-1}
  114. if [[ ! ${ENV_FLAG} =~ ^[1-3]$ ]]; then
  115. echo "${CWARNING}input error! Please only input number 1~3${CEND}"
  116. else
  117. break
  118. fi
  119. done
  120. case "${ENV_FLAG}" in
  121. 1)
  122. NGX_FLAG=php
  123. ;;
  124. 2)
  125. NGX_FLAG=java
  126. ;;
  127. 3)
  128. NGX_FLAG=hhvm
  129. ;;
  130. esac
  131. elif [ -e "${php_install_dir}/bin/phpize" -a -e "${tomcat_install_dir}/conf/server.xml" -a ! -e "/usr/bin/hhvm" ]; then
  132. Number=110
  133. while :; do echo
  134. echo "Please choose to use environment:"
  135. echo -e "\t${CMSG}1${CEND}. Use php"
  136. echo -e "\t${CMSG}2${CEND}. Use java"
  137. read -e -p "Please input a number:(Default 1 press Enter) " ENV_FLAG
  138. ENV_FLAG=${ENV_FLAG:-1}
  139. if [[ ! ${ENV_FLAG} =~ ^[1-2]$ ]]; then
  140. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  141. else
  142. break
  143. fi
  144. done
  145. [ "${ENV_FLAG}" == '1' ] && NGX_FLAG=php
  146. [ "${ENV_FLAG}" == '2' ] && NGX_FLAG=java
  147. elif [ -e "${php_install_dir}/bin/phpize" -a ! -e "${tomcat_install_dir}/conf/server.xml" -a ! -e "/usr/bin/hhvm" ]; then
  148. Number=100
  149. NGX_FLAG=php
  150. elif [ -e "${php_install_dir}/bin/phpize" -a ! -e "${tomcat_install_dir}/conf/server.xml" -a -e "/usr/bin/hhvm" ]; then
  151. Number=101
  152. while :; do echo
  153. echo "Please choose to use environment:"
  154. echo -e "\t${CMSG}1${CEND}. Use php"
  155. echo -e "\t${CMSG}2${CEND}. Use hhvm"
  156. read -e -p "Please input a number:(Default 1 press Enter) " ENV_FLAG
  157. ENV_FLAG=${ENV_FLAG:-1}
  158. if [[ ! ${ENV_FLAG} =~ ^[1-2]$ ]]; then
  159. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  160. else
  161. break
  162. fi
  163. done
  164. [ "${ENV_FLAG}" == '1' ] && NGX_FLAG=php
  165. [ "${ENV_FLAG}" == '2' ] && NGX_FLAG=hhvm
  166. elif [ ! -e "${php_install_dir}/bin/phpize" -a -e "${tomcat_install_dir}/conf/server.xml" -a -e "/usr/bin/hhvm" ]; then
  167. Number=011
  168. while :; do echo
  169. echo "Please choose to use environment:"
  170. echo -e "\t${CMSG}1${CEND}. Use java"
  171. echo -e "\t${CMSG}2${CEND}. Use hhvm"
  172. read -e -p "Please input a number:(Default 1 press Enter) " ENV_FLAG
  173. ENV_FLAG=${ENV_FLAG:-1}
  174. if [[ ! ${ENV_FLAG} =~ ^[1-2]$ ]]; then
  175. echo "${CWARNING}input error! Please only input number 1~2${CEND}"
  176. else
  177. break
  178. fi
  179. done
  180. [ "${ENV_FLAG}" == '1' ] && NGX_FLAG=java
  181. [ "${ENV_FLAG}" == '2' ] && NGX_FLAG=hhvm
  182. elif [ ! -e "${php_install_dir}/bin/phpize" -a -e "${tomcat_install_dir}/conf/server.xml" -a ! -e "/usr/bin/hhvm" ]; then
  183. Number=010
  184. NGX_FLAG=java
  185. elif [ ! -e "${php_install_dir}/bin/phpize" -a ! -e "${tomcat_install_dir}/conf/server.xml" -a -e "/usr/bin/hhvm" ]; then
  186. Number=001
  187. NGX_FLAG=hhvm
  188. else
  189. Number=000
  190. NGX_FLAG=php
  191. fi
  192. }
  193. Create_SSL() {
  194. if [ "${Domian_Mode}" == '2' ]; then
  195. printf "
  196. You are about to be asked to enter information that will be incorporated
  197. into your certificate request.
  198. What you are about to enter is what is called a Distinguished Name or a DN.
  199. There are quite a few fields but you can leave some blank
  200. For some fields there will be a default value,
  201. If you enter '.', the field will be left blank.
  202. "
  203. echo
  204. read -e -p "Country Name (2 letter code) [CN]: " SELFSIGNEDSSL_C
  205. SELFSIGNEDSSL_C=${SELFSIGNEDSSL_C:-CN}
  206. [ ${#SELFSIGNEDSSL_C} != 2 ] && { echo "${CWARNING}input error, You must input 2 letter code country name${CEND}"; continue; }
  207. echo
  208. read -e -p "State or Province Name (full name) [Shanghai]: " SELFSIGNEDSSL_ST
  209. SELFSIGNEDSSL_ST=${SELFSIGNEDSSL_ST:-Shanghai}
  210. echo
  211. read -e -p "Locality Name (eg, city) [Shanghai]: " SELFSIGNEDSSL_L
  212. SELFSIGNEDSSL_L=${SELFSIGNEDSSL_L:-Shanghai}
  213. echo
  214. read -e -p "Organization Name (eg, company) [Example Inc.]: " SELFSIGNEDSSL_O
  215. SELFSIGNEDSSL_O=${SELFSIGNEDSSL_O:-"Example Inc."}
  216. echo
  217. read -e -p "Organizational Unit Name (eg, section) [IT Dept.]: " SELFSIGNEDSSL_OU
  218. SELFSIGNEDSSL_OU=${SELFSIGNEDSSL_OU:-"IT Dept."}
  219. openssl req -utf8 -new -newkey rsa:2048 -sha256 -nodes -out ${PATH_SSL}/${domain}.csr -keyout ${PATH_SSL}/${domain}.key -subj "/C=${SELFSIGNEDSSL_C}/ST=${SELFSIGNEDSSL_ST}/L=${SELFSIGNEDSSL_L}/O=${SELFSIGNEDSSL_O}/OU=${SELFSIGNEDSSL_OU}/CN=${domain}" > /dev/null 2>&1
  220. openssl x509 -req -days 36500 -sha256 -in ${PATH_SSL}/${domain}.csr -signkey ${PATH_SSL}/${domain}.key -out ${PATH_SSL}/${domain}.crt > /dev/null 2>&1
  221. elif [ "${Domian_Mode}" == '3' -o "${dnsapi_flag}" == 'y' ]; then
  222. if [ "${moredomain}" == "*.${domain}" -o "${dnsapi_flag}" == 'y' ]; then
  223. while :; do echo
  224. echo 'Please select DNS provider:'
  225. echo "${CMSG}dp${CEND},${CMSG}cx${CEND},${CMSG}ali${CEND},${CMSG}cf${CEND},${CMSG}aws${CEND},${CMSG}linode${CEND},${CMSG}he${CEND},${CMSG}namesilo${CEND},${CMSG}dgon${CEND},${CMSG}freedns${CEND},${CMSG}gd${CEND},${CMSG}namecom${CEND} and so on."
  226. echo "${CMSG}More: https://oneinstack.com/faq/letsencrypt${CEND}"
  227. read -e -p "Please enter your DNS provider: " DNS_PRO
  228. if [ -e ~/.acme.sh/dnsapi/dns_${DNS_PRO}.sh ]; then
  229. break
  230. else
  231. echo "${CWARNING}You DNS api mode is not supported${CEND}"
  232. fi
  233. done
  234. while :; do echo
  235. echo "Syntax: export Key1=Value1 ; export Key2=Value1"
  236. read -e -p "Please enter your dnsapi parameters: " DNS_PAR
  237. echo
  238. eval ${DNS_PAR}
  239. if [ $? == 0 ]; then
  240. break
  241. else
  242. echo "${CWARNING}Syntax error! PS: export Ali_Key=LTq ; export Ali_Secret=0q5E${CEND}"
  243. fi
  244. done
  245. [ "${moredomainame_flag}" == 'y' ] && moredomainame_D="$(for D in ${moredomainame}; do echo -d ${D}; done)"
  246. ~/.acme.sh/acme.sh --issue --dns dns_${DNS_PRO} -d ${domain} ${moredomainame_D}
  247. else
  248. if [ "${nginx_ssl_flag}" == 'y' ]; then
  249. [ ! -d ${web_install_dir}/conf/vhost ] && mkdir ${web_install_dir}/conf/vhost
  250. echo "server { server_name ${domain}${moredomainame}; root ${vhostdir}; access_log off; }" > ${web_install_dir}/conf/vhost/${domain}.conf
  251. ${web_install_dir}/sbin/nginx -s reload
  252. fi
  253. if [ "${apache_ssl_flag}" == 'y' ]; then
  254. [ ! -d ${apache_install_dir}/conf/vhost ] && mkdir ${apache_install_dir}/conf/vhost
  255. cat > ${apache_install_dir}/conf/vhost/${domain}.conf << EOF
  256. <VirtualHost *:80>
  257. ServerAdmin admin@example.com
  258. DocumentRoot "${vhostdir}"
  259. ServerName ${domain}
  260. ${Apache_Domain_alias}
  261. <Directory "${vhostdir}">
  262. SetOutputFilter DEFLATE
  263. Options FollowSymLinks ExecCGI
  264. ${Apache_grant}
  265. AllowOverride All
  266. Order allow,deny
  267. Allow from all
  268. DirectoryIndex index.html index.php
  269. </Directory>
  270. </VirtualHost>
  271. EOF
  272. ${apache_install_dir}/bin/apachectl -k graceful
  273. fi
  274. auth_file="`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`".html
  275. auth_str='oneinstack'; echo ${auth_str} > ${vhostdir}/${auth_file}
  276. for D in ${domain} ${moredomainame}
  277. do
  278. curl_str=`curl --connect-timeout 30 -4 -s $D/${auth_file} 2>&1`
  279. [ "${curl_str}" != "${auth_str}" ] && { echo; echo "${CFAILURE}Let's Encrypt Verify error! DNS problem: NXDOMAIN looking up A for ${D}${CEND}"; }
  280. done
  281. rm -f ${vhostdir}/${auth_file}
  282. [ "${moredomainame_flag}" == 'y' ] && moredomainame_D="$(for D in ${moredomainame}; do echo -d ${D}; done)"
  283. ~/.acme.sh/acme.sh --issue -d ${domain} ${moredomainame_D} -w ${vhostdir}
  284. fi
  285. if [ -s ~/.acme.sh/${domain}/fullchain.cer ]; then
  286. [ -e "${PATH_SSL}/${domain}.crt" ] && rm -f ${PATH_SSL}/${domain}.{crt,key}
  287. [ -e /bin/systemctl -a -e /lib/systemd/system/nginx.service ] && Nginx_cmd='/bin/systemctl restart nginx' || Nginx_cmd='/etc/init.d/nginx force-reload'
  288. Apache_cmd="${apache_install_dir}/bin/apachectl -k graceful"
  289. if [ -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/bin/httpd" ]; then
  290. Command="${Nginx_cmd};${Apache_cmd}"
  291. elif [ -e "${web_install_dir}/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" ]; then
  292. Command="${Nginx_cmd}"
  293. elif [ ! -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/bin/httpd" ]; then
  294. Command="${Apache_cmd}"
  295. fi
  296. ~/.acme.sh/acme.sh --install-cert -d ${domain} --fullchain-file ${PATH_SSL}/${domain}.crt --key-file ${PATH_SSL}/${domain}.key --reloadcmd "${Command}" > /dev/null
  297. else
  298. echo "${CFAILURE}Error: Create Let's Encrypt SSL Certificate failed! ${CEND}"
  299. [ -e "${web_install_dir}/conf/vhost/${domain}.conf" ] && rm -f ${web_install_dir}/conf/vhost/${domain}.conf
  300. [ -e "${apache_install_dir}/conf/vhost/${domain}.conf" ] && rm -f ${apache_install_dir}/conf/vhost/${domain}.conf
  301. exit 1
  302. fi
  303. fi
  304. }
  305. Print_SSL() {
  306. if [ "${Domian_Mode}" == '2' ]; then
  307. echo "$(printf "%-30s" "Self-signed SSL Certificate:")${CMSG}${PATH_SSL}/${domain}.crt${CEND}"
  308. echo "$(printf "%-30s" "SSL Private Key:")${CMSG}${PATH_SSL}/${domain}.key${CEND}"
  309. echo "$(printf "%-30s" "SSL CSR File:")${CMSG}${PATH_SSL}/${domain}.csr${CEND}"
  310. elif [ "${Domian_Mode}" == '3' -o "${dnsapi_flag}" == 'y' ]; then
  311. echo "$(printf "%-30s" "Let's Encrypt SSL Certificate:")${CMSG}${PATH_SSL}/${domain}.crt${CEND}"
  312. echo "$(printf "%-30s" "SSL Private Key:")${CMSG}${PATH_SSL}/${domain}.key${CEND}"
  313. fi
  314. }
  315. Input_Add_domain() {
  316. if [ "${sslquiet_flag}" != 'y' ]; then
  317. while :;do
  318. printf "
  319. What Are You Doing?
  320. \t${CMSG}1${CEND}. Use HTTP Only
  321. \t${CMSG}2${CEND}. Use your own SSL Certificate and Key
  322. \t${CMSG}3${CEND}. Use Let's Encrypt to Create SSL Certificate and Key
  323. \t${CMSG}q${CEND}. Exit
  324. "
  325. read -e -p "Please input the correct option: " Domian_Mode
  326. if [[ ! "${Domian_Mode}" =~ ^[1-3,q]$ ]]; then
  327. echo "${CFAILURE}input error! Please only input 1~3 and q${CEND}"
  328. else
  329. break
  330. fi
  331. done
  332. fi
  333. #Multiple_PHP
  334. if [ $(ls /dev/shm/php*-cgi.sock 2> /dev/null | wc -l) -ge 2 ]; then
  335. if [ "${mphp_flag}" != 'y' ]; then
  336. PHP_detail_ver=`${php_install_dir}/bin/php-config --version`
  337. PHP_main_ver=${PHP_detail_ver%.*}
  338. while :; do echo
  339. echo 'Please select a version of the PHP:'
  340. echo -e "\t${CMSG}1${CEND}. PHP ${PHP_main_ver} (default)"
  341. [ -e "/dev/shm/php53-cgi.sock" ] && echo -e "\t${CMSG}2${CEND}. PHP 5.3"
  342. [ -e "/dev/shm/php54-cgi.sock" ] && echo -e "\t${CMSG}3${CEND}. PHP 5.4"
  343. [ -e "/dev/shm/php55-cgi.sock" ] && echo -e "\t${CMSG}4${CEND}. PHP 5.5"
  344. [ -e "/dev/shm/php56-cgi.sock" ] && echo -e "\t${CMSG}5${CEND}. PHP 5.6"
  345. [ -e "/dev/shm/php70-cgi.sock" ] && echo -e "\t${CMSG}6${CEND}. PHP 7.0"
  346. [ -e "/dev/shm/php71-cgi.sock" ] && echo -e "\t${CMSG}7${CEND}. PHP 7.1"
  347. [ -e "/dev/shm/php72-cgi.sock" ] && echo -e "\t${CMSG}8${CEND}. PHP 7.2"
  348. [ -e "/dev/shm/php73-cgi.sock" ] && echo -e "\t${CMSG}9${CEND}. PHP 7.3"
  349. read -e -p "Please input a number:(Default 1 press Enter) " php_option
  350. php_option=${php_option:-1}
  351. if [[ ! ${php_option} =~ ^[1-9]$ ]]; then
  352. echo "${CWARNING}input error! Please only input number 1~9${CEND}"
  353. else
  354. break
  355. fi
  356. done
  357. fi
  358. [ "${php_option}" == '2' ] && mphp_ver=53
  359. [ "${php_option}" == '3' ] && mphp_ver=54
  360. [ "${php_option}" == '4' ] && mphp_ver=55
  361. [ "${php_option}" == '5' ] && mphp_ver=56
  362. [ "${php_option}" == '6' ] && mphp_ver=70
  363. [ "${php_option}" == '7' ] && mphp_ver=71
  364. [ "${php_option}" == '8' ] && mphp_ver=72
  365. [ "${php_option}" == '9' ] && mphp_ver=73
  366. [ ! -e "/dev/shm/php${mphp_ver}-cgi.sock" ] && unset mphp_ver
  367. fi
  368. case "${NGX_FLAG}" in
  369. "php")
  370. NGX_CONF=$(echo -e "location ~ [^/]\.php(/|$) {\n #fastcgi_pass remote_php_ip:9000;\n fastcgi_pass unix:/dev/shm/php${mphp_ver}-cgi.sock;\n fastcgi_index index.php;\n include fastcgi.conf;\n }")
  371. ;;
  372. "java")
  373. NGX_CONF=$(echo -e "location ~ {\n proxy_pass http://127.0.0.1:8080;\n include proxy.conf;\n }")
  374. ;;
  375. "hhvm")
  376. NGX_CONF=$(echo -e "location ~ .*\.(php|php5)?$ {\n fastcgi_pass unix:/var/log/hhvm/sock;\n fastcgi_index index.php;\n fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;\n include fastcgi_params;\n }")
  377. ;;
  378. esac
  379. if [ "${Domian_Mode}" == '3' -o "${dnsapi_flag}" == 'y' ] && [ ! -e ~/.acme.sh/acme.sh ]; then
  380. pushd ${oneinstack_dir}/src > /dev/null
  381. [ ! -e acme.sh-master.tar.gz ] && wget -qc http://mirrors.linuxeye.com/oneinstack/src/acme.sh-master.tar.gz
  382. tar xzf acme.sh-master.tar.gz
  383. pushd acme.sh-master > /dev/null
  384. ./acme.sh --install > /dev/null 2>&1
  385. popd > /dev/null
  386. popd > /dev/null
  387. fi
  388. [ -e ~/.acme.sh/account.conf ] && sed -i '/^CERT_HOME=/d' ~/.acme.sh/account.conf
  389. if [[ "${Domian_Mode}" =~ ^[2-3]$ ]] || [ "${dnsapi_flag}" == 'y' ]; then
  390. if [ -e "${web_install_dir}/sbin/nginx" ]; then
  391. nginx_ssl_flag=y
  392. PATH_SSL=${web_install_dir}/conf/ssl
  393. [ ! -d "${PATH_SSL}" ] && mkdir ${PATH_SSL}
  394. elif [ ! -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/bin/httpd" ]; then
  395. apache_ssl_flag=y
  396. PATH_SSL=${apache_install_dir}/conf/ssl
  397. [ ! -d "${PATH_SSL}" ] && mkdir ${PATH_SSL}
  398. fi
  399. elif [ "${Domian_Mode}" == 'q' ]; then
  400. exit 1
  401. fi
  402. while :; do echo
  403. read -e -p "Please input domain(example: www.example.com): " domain
  404. if [ -z "$(echo ${domain} | grep '.*\..*')" ]; then
  405. echo "${CWARNING}Your ${domain} is invalid! ${CEND}"
  406. else
  407. break
  408. fi
  409. done
  410. if [ -e "${web_install_dir}/conf/vhost/${domain}.conf" -o -e "${apache_install_dir}/conf/vhost/${domain}.conf" -o -e "${tomcat_install_dir}/conf/vhost/${domain}.xml" ]; then
  411. [ -e "${web_install_dir}/conf/vhost/${domain}.conf" ] && echo -e "${domain} in the Nginx/Tengine/OpenResty already exist! \nYou can delete ${CMSG}${web_install_dir}/conf/vhost/${domain}.conf${CEND} and re-create"
  412. [ -e "${apache_install_dir}/conf/vhost/${domain}.conf" ] && echo -e "${domain} in the Apache already exist! \nYou can delete ${CMSG}${apache_install_dir}/conf/vhost/${domain}.conf${CEND} and re-create"
  413. [ -e "${tomcat_install_dir}/conf/vhost/${domain}.xml" ] && echo -e "${domain} in the Tomcat already exist! \nYou can delete ${CMSG}${tomcat_install_dir}/conf/vhost/${domain}.xml${CEND} and re-create"
  414. exit
  415. else
  416. echo "domain=${domain}"
  417. fi
  418. while :; do echo
  419. echo "Please input the directory for the domain:${domain} :"
  420. read -e -p "(Default directory: ${wwwroot_dir}/${domain}): " vhostdir
  421. if [ -n "${vhostdir}" -a -z "$(echo ${vhostdir} | grep '^/')" ]; then
  422. echo "${CWARNING}input error! Press Enter to continue...${CEND}"
  423. else
  424. if [ -z "${vhostdir}" ]; then
  425. vhostdir="${wwwroot_dir}/${domain}"
  426. echo "Virtual Host Directory=${CMSG}${vhostdir}${CEND}"
  427. fi
  428. echo
  429. echo "Create Virtul Host directory......"
  430. mkdir -p ${vhostdir}
  431. echo "set permissions of Virtual Host directory......"
  432. chown -R ${run_user}.${run_user} ${vhostdir}
  433. break
  434. fi
  435. done
  436. while :; do echo
  437. read -e -p "Do you want to add more domain name? [y/n]: " moredomainame_flag
  438. if [[ ! ${moredomainame_flag} =~ ^[y,n]$ ]]; then
  439. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  440. else
  441. break
  442. fi
  443. done
  444. if [ "${moredomainame_flag}" == 'y' ]; then
  445. while :; do echo
  446. read -e -p "Type domainname or IP(example: example.com other.example.com): " moredomain
  447. if [ -z "$(echo ${moredomain} | grep '.*\..*')" ]; then
  448. echo "${CWARNING}Your ${domain} is invalid! ${CEND}"
  449. else
  450. [ "${moredomain}" == "${domain}" ] && echo "${CWARNING}Domain name already exists! ${CND}" && continue
  451. echo domain list="$moredomain"
  452. moredomainame=" $moredomain"
  453. break
  454. fi
  455. done
  456. Apache_Domain_alias=ServerAlias${moredomainame}
  457. Tomcat_Domain_alias=$(for D in $(echo ${moredomainame}); do echo "<Alias>${D}</Alias>"; done)
  458. if [ -e "${web_install_dir}/sbin/nginx" ]; then
  459. while :; do echo
  460. read -e -p "Do you want to redirect from ${moredomain} to ${domain}? [y/n]: " redirect_flag
  461. if [[ ! ${redirect_flag} =~ ^[y,n]$ ]]; then
  462. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  463. else
  464. break
  465. fi
  466. done
  467. [ "${redirect_flag}" == 'y' ] && Nginx_redirect="if (\$host != ${domain}) { return 301 \$scheme://${domain}\$request_uri; }"
  468. fi
  469. fi
  470. if [ "${nginx_ssl_flag}" == 'y' ]; then
  471. while :; do echo
  472. read -e -p "Do you want to redirect all HTTP requests to HTTPS? [y/n]: " https_flag
  473. if [[ ! ${https_flag} =~ ^[y,n]$ ]]; then
  474. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  475. else
  476. break
  477. fi
  478. done
  479. if [[ "$(${web_install_dir}/sbin/nginx -V 2>&1 | grep -Eo 'with-http_v2_module')" = 'with-http_v2_module' ]]; then
  480. LISTENOPT="443 ssl http2"
  481. else
  482. LISTENOPT="443 ssl spdy"
  483. fi
  484. Create_SSL
  485. Nginx_conf=$(echo -e "listen 80;\n listen ${LISTENOPT};\n ssl_certificate ${PATH_SSL}/${domain}.crt;\n ssl_certificate_key ${PATH_SSL}/${domain}.key;\n ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;\n ssl_ciphers TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;\n ssl_prefer_server_ciphers on;\n ssl_session_timeout 10m;\n ssl_session_cache builtin:1000 shared:SSL:10m;\n ssl_buffer_size 1400;\n add_header Strict-Transport-Security max-age=15768000;\n ssl_stapling on;\n ssl_stapling_verify on;\n")
  486. Apache_SSL=$(echo -e "SSLEngine on\n SSLCertificateFile \"${PATH_SSL}/${domain}.crt\"\n SSLCertificateKeyFile \"${PATH_SSL}/${domain}.key\"")
  487. elif [ "$apache_ssl_flag" == 'y' ]; then
  488. Create_SSL
  489. Apache_SSL=$(echo -e "SSLEngine on\n SSLCertificateFile \"${PATH_SSL}/${domain}.crt\"\n SSLCertificateKeyFile \"${PATH_SSL}/${domain}.key\"")
  490. [ -z "$(grep 'Listen 443' ${apache_install_dir}/conf/httpd.conf)" ] && sed -i "s@Listen 80@&\nListen 443@" ${apache_install_dir}/conf/httpd.conf
  491. [ -z "$(grep 'ServerName 0.0.0.0:443' ${apache_install_dir}/conf/httpd.conf)" ] && sed -i "s@ServerName 0.0.0.0:80@&\nServerName 0.0.0.0:443@" ${apache_install_dir}/conf/httpd.conf
  492. else
  493. Nginx_conf="listen 80;"
  494. fi
  495. }
  496. Nginx_anti_hotlinking() {
  497. while :; do echo
  498. read -e -p "Do you want to add hotlink protection? [y/n]: " anti_hotlinking_flag
  499. if [[ ! ${anti_hotlinking_flag} =~ ^[y,n]$ ]]; then
  500. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  501. else
  502. break
  503. fi
  504. done
  505. if [ -n "$(echo ${domain} | grep '.*\..*\..*')" ]; then
  506. domain_allow="*.${domain#*.} ${domain}"
  507. else
  508. domain_allow="*.${domain} ${domain}"
  509. fi
  510. if [ "${anti_hotlinking_flag}" == 'y' ]; then
  511. if [ "${moredomainame_flag}" == 'y' -a "${moredomain}" != "*.${domain}" ]; then
  512. domain_allow_all=${domain_allow}${moredomainame}
  513. else
  514. domain_allow_all=${domain_allow}
  515. fi
  516. domain_allow_all=`echo ${domain_allow_all} | tr ' ' '\n' | awk '!a[$1]++' | xargs`
  517. anti_hotlinking=$(echo -e "location ~ .*\.(wma|wmv|asf|mp3|mmf|zip|rar|jpg|gif|png|swf|flv|mp4)$ {\n valid_referers none blocked ${domain_allow_all};\n if (\$invalid_referer) {\n return 403;\n }\n }")
  518. fi
  519. }
  520. Nginx_rewrite() {
  521. [ ! -d "${web_install_dir}/conf/rewrite" ] && mkdir ${web_install_dir}/conf/rewrite
  522. while :; do echo
  523. read -e -p "Allow Rewrite rule? [y/n]: " rewrite_flag
  524. if [[ ! "${rewrite_flag}" =~ ^[y,n]$ ]]; then
  525. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  526. else
  527. break
  528. fi
  529. done
  530. if [ "${rewrite_flag}" == 'n' ]; then
  531. rewrite="none"
  532. touch "${web_install_dir}/conf/rewrite/${rewrite}.conf"
  533. else
  534. echo
  535. echo "Please input the rewrite of programme :"
  536. echo "${CMSG}wordpress${CEND},${CMSG}opencart${CEND},${CMSG}magento2${CEND},${CMSG}drupal${CEND},${CMSG}joomla${CEND},${CMSG}codeigniter${CEND},${CMSG}laravel${CEND}"
  537. echo "${CMSG}thinkphp${CEND},${CMSG}pathinfo${CEND},${CMSG}discuz${CEND},${CMSG}typecho${CEND},${CMSG}ecshop${CEND},${CMSG}nextcloud${CEND} rewrite was exist."
  538. read -e -p "(Default rewrite: other): " rewrite
  539. if [ "${rewrite}" == "" ]; then
  540. rewrite="other"
  541. fi
  542. echo "You choose rewrite=${CMSG}$rewrite${CEND}"
  543. [ "${NGX_FLAG}" == 'php' -a "${rewrite}" == "joomla" ] && NGX_CONF=$(echo -e "location ~ \\.php\$ {\n #fastcgi_pass remote_php_ip:9000;\n fastcgi_pass unix:/dev/shm/php${mphp_ver}-cgi.sock;\n fastcgi_index index.php;\n include fastcgi.conf;\n }")
  544. [ "${NGX_FLAG}" == 'php' ] && [[ "${rewrite}" =~ ^codeigniter$|^thinkphp$|^pathinfo$ ]] && NGX_CONF=$(echo -e "location ~ [^/]\.php(/|\$) {\n try_files \$uri =404;\n #fastcgi_pass remote_php_ip:9000;\n fastcgi_pass unix:/dev/shm/php${mphp_ver}-cgi.sock;\n fastcgi_index index.php;\n include fastcgi.conf;\n set \$real_script_name \$fastcgi_script_name;\n if (\$fastcgi_script_name ~ \"^(.+?\.php)(/.+)\$\") {\n set \$real_script_name \$1;\n set \$path_info \$2;\n }\n fastcgi_param SCRIPT_FILENAME \$document_root\$real_script_name;\n fastcgi_param SCRIPT_NAME \$real_script_name;\n fastcgi_param PATH_INFO \$path_info;\n }")
  545. [ "${NGX_FLAG}" == 'php' -a "${rewrite}" == "typecho" ] && NGX_CONF=$(echo -e "location ~ .*\.php(\/.*)*\$ {\n #fastcgi_pass remote_php_ip:9000;\n fastcgi_pass unix:/dev/shm/php${mphp_ver}-cgi.sock;\n fastcgi_index index.php;\n include fastcgi.conf;\n set \$path_info \"\";\n set \$real_script_name \$fastcgi_script_name;\n if (\$fastcgi_script_name ~ \"^(.+?\.php)(/.+)\$\") {\n set \$real_script_name \$1;\n set \$path_info \$2;\n }\n fastcgi_param SCRIPT_FILENAME \$document_root\$real_script_name;\n fastcgi_param SCRIPT_NAME \$real_script_name;\n fastcgi_param PATH_INFO \$path_info;\n }")
  546. if [[ ! "${rewrite}" =~ ^magento2$|^pathinfo$ ]]; then
  547. if [ -e "config/${rewrite}.conf" ]; then
  548. /bin/cp config/${rewrite}.conf ${web_install_dir}/conf/rewrite/${rewrite}.conf
  549. else
  550. touch "${web_install_dir}/conf/rewrite/${rewrite}.conf"
  551. fi
  552. fi
  553. fi
  554. }
  555. Nginx_log() {
  556. while :; do echo
  557. read -e -p "Allow Nginx/Tengine/OpenResty access_log? [y/n]: " access_flag
  558. if [[ ! "${access_flag}" =~ ^[y,n]$ ]]; then
  559. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  560. else
  561. break
  562. fi
  563. done
  564. if [ "${access_flag}" == 'n' ]; then
  565. Nginx_log="access_log off;"
  566. else
  567. Nginx_log="access_log ${wwwlogs_dir}/${domain}_nginx.log combined;"
  568. echo "You access log file=${CMSG}${wwwlogs_dir}/${domain}_nginx.log${CEND}"
  569. fi
  570. }
  571. Create_nginx_tomcat_conf() {
  572. [ ! -d ${web_install_dir}/conf/vhost ] && mkdir ${web_install_dir}/conf/vhost
  573. cat > ${web_install_dir}/conf/vhost/${domain}.conf << EOF
  574. server {
  575. ${Nginx_conf}
  576. server_name ${domain}${moredomainame};
  577. ${Nginx_log}
  578. index index.html index.htm index.jsp;
  579. root ${vhostdir};
  580. ${Nginx_redirect}
  581. #error_page 404 /404.html;
  582. #error_page 502 /502.html;
  583. ${anti_hotlinking}
  584. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
  585. expires 30d;
  586. access_log off;
  587. }
  588. location ~ .*\.(js|css)?$ {
  589. expires 7d;
  590. access_log off;
  591. }
  592. location ~ /\.ht {
  593. deny all;
  594. }
  595. ${NGX_CONF}
  596. }
  597. EOF
  598. [ "${https_flag}" == 'y' ] && sed -i "s@^root.*;@&\nif (\$ssl_protocol = \"\") { return 301 https://\$host\$request_uri; }@" ${web_install_dir}/conf/vhost/${domain}.conf
  599. cat > ${tomcat_install_dir}/conf/vhost/${domain}.xml << EOF
  600. <Host name="${domain}" appBase="${vhostdir}" unpackWARs="true" autoDeploy="true"> ${Tomcat_Domain_alias}
  601. <Context path="" docBase="${vhostdir}" reloadable="false" crossContext="true"/>
  602. <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
  603. prefix="${domain}_access_log" suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
  604. <Valve className="org.apache.catalina.valves.RemoteIpValve" remoteIpHeader="X-Forwarded-For"
  605. protocolHeader="X-Forwarded-Proto" protocolHeaderHttpsValue="https"/>
  606. </Host>
  607. EOF
  608. [ -z "$(grep -o "vhost-${domain} SYSTEM" ${tomcat_install_dir}/conf/server.xml)" ] && sed -i "/vhost-localhost SYSTEM/a<\!ENTITY vhost-${domain} SYSTEM \"file://${tomcat_install_dir}/conf/vhost/${domain}.xml\">" ${tomcat_install_dir}/conf/server.xml
  609. [ -z "$(grep -o "vhost-${domain};" ${tomcat_install_dir}/conf/server.xml)" ] && sed -i "s@vhost-localhost;@&\n \&vhost-${domain};@" ${tomcat_install_dir}/conf/server.xml
  610. echo
  611. ${web_install_dir}/sbin/nginx -t
  612. if [ $? == 0 ]; then
  613. echo "Reload Nginx......"
  614. ${web_install_dir}/sbin/nginx -s reload
  615. service tomcat restart
  616. else
  617. rm -f ${web_install_dir}/conf/vhost/${domain}.conf
  618. echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]"
  619. exit 1
  620. fi
  621. printf "
  622. #######################################################################
  623. # OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+ #
  624. # For more information please visit https://oneinstack.com #
  625. #######################################################################
  626. "
  627. echo "$(printf "%-30s" "Your domain:")${CMSG}${domain}${CEND}"
  628. echo "$(printf "%-30s" "Nginx Virtualhost conf:")${CMSG}${web_install_dir}/conf/vhost/${domain}.conf${CEND}"
  629. echo "$(printf "%-30s" "Tomcat Virtualhost conf:")${CMSG}${tomcat_install_dir}/conf/vhost/${domain}.xml${CEND}"
  630. echo "$(printf "%-30s" "Directory of:")${CMSG}${vhostdir}${CEND}"
  631. Print_SSL
  632. }
  633. Create_tomcat_conf() {
  634. cat > ${tomcat_install_dir}/conf/vhost/${domain}.xml << EOF
  635. <Host name="${domain}" appBase="webapps" unpackWARs="true" autoDeploy="true"> ${Tomcat_Domain_alias}
  636. <Context path="" docBase="${vhostdir}" reloadable="false" crossContext="true"/>
  637. <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
  638. prefix="${domain}_access_log" suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
  639. </Host>
  640. EOF
  641. [ -z "$(grep -o "vhost-${domain} SYSTEM" ${tomcat_install_dir}/conf/server.xml)" ] && sed -i "/vhost-localhost SYSTEM/a<\!ENTITY vhost-${domain} SYSTEM \"file://${tomcat_install_dir}/conf/vhost/${domain}.xml\">" ${tomcat_install_dir}/conf/server.xml
  642. [ -z "$(grep -o "vhost-${domain};" ${tomcat_install_dir}/conf/server.xml)" ] && sed -i "s@vhost-localhost;@&\n \&vhost-${domain};@" ${tomcat_install_dir}/conf/server.xml
  643. echo
  644. service tomcat restart
  645. printf "
  646. #######################################################################
  647. # OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+ #
  648. # For more information please visit https://oneinstack.com #
  649. #######################################################################
  650. "
  651. echo "$(printf "%-30s" "Your domain:")${CMSG}${domain}${CEND}"
  652. echo "$(printf "%-30s" "Tomcat Virtualhost conf:")${CMSG}${tomcat_install_dir}/conf/vhost/${domain}.xml${CEND}"
  653. echo "$(printf "%-30s" "Directory of:")${CMSG}${vhostdir}${CEND}"
  654. echo "$(printf "%-30s" "index url:")${CMSG}http://${domain}:8080/${CEND}"
  655. }
  656. Create_nginx_phpfpm_hhvm_conf() {
  657. [ ! -d ${web_install_dir}/conf/vhost ] && mkdir ${web_install_dir}/conf/vhost
  658. cat > ${web_install_dir}/conf/vhost/${domain}.conf << EOF
  659. server {
  660. ${Nginx_conf}
  661. server_name ${domain}${moredomainame};
  662. ${Nginx_log}
  663. index index.html index.htm index.php;
  664. root ${vhostdir};
  665. ${Nginx_redirect}
  666. include ${web_install_dir}/conf/rewrite/${rewrite}.conf;
  667. #error_page 404 /404.html;
  668. #error_page 502 /502.html;
  669. ${anti_hotlinking}
  670. ${NGX_CONF}
  671. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
  672. expires 30d;
  673. access_log off;
  674. }
  675. location ~ .*\.(js|css)?$ {
  676. expires 7d;
  677. access_log off;
  678. }
  679. location ~ /\.ht {
  680. deny all;
  681. }
  682. }
  683. EOF
  684. [ "${rewrite}" == 'pathinfo' ] && sed -i '/pathinfo.conf;$/d' ${web_install_dir}/conf/vhost/${domain}.conf
  685. if [ "${rewrite}" == 'magento2' -a -e "config/${rewrite}.conf" ]; then
  686. /bin/cp config/${rewrite}.conf ${web_install_dir}/conf/vhost/${domain}.conf
  687. sed -i "s@/dev/shm/php-cgi.sock@/dev/shm/php${mphp_ver}-cgi.sock@g" ${web_install_dir}/conf/vhost/${domain}.conf
  688. sed -i "s@^ set \$MAGE_ROOT.*;@ set \$MAGE_ROOT ${vhostdir};@" ${web_install_dir}/conf/vhost/${domain}.conf
  689. sed -i "s@^ server_name.*;@ server_name ${domain}${moredomainame};@" ${web_install_dir}/conf/vhost/${domain}.conf
  690. sed -i "s@^ server_name.*;@&\n ${Nginx_log}@" ${web_install_dir}/conf/vhost/${domain}.conf
  691. [ "${NGX_FLAG}" == 'hhvm' ] && sed -i 's@fastcgi_pass unix:.*;@fastcgi_pass unix:/var/log/hhvm/sock;@g' ${web_install_dir}/conf/vhost/${domain}.conf
  692. if [ "${anti_hotlinking_flag}" == 'y' ]; then
  693. sed -i "s@^ root.*;@&\n }@" ${web_install_dir}/conf/vhost/${domain}.conf
  694. sed -i "s@^ root.*;@&\n }@" ${web_install_dir}/conf/vhost/${domain}.conf
  695. sed -i "s@^ root.*;@&\n return 403;@" ${web_install_dir}/conf/vhost/${domain}.conf
  696. sed -i "s@^ root.*;@&\n rewrite ^/ http://www.linuxeye.com/403.html;@" ${web_install_dir}/conf/vhost/${domain}.conf
  697. sed -i "s@^ root.*;@&\n if (\$invalid_referer) {@" ${web_install_dir}/conf/vhost/${domain}.conf
  698. sed -i "s@^ root.*;@&\n valid_referers none blocked ${domain_allow_all};@" ${web_install_dir}/conf/vhost/${domain}.conf
  699. sed -i "s@^ root.*;@&\n location ~ .*\.(wma|wmv|asf|mp3|mmf|zip|rar|jpg|gif|png|swf|flv|mp4)\$ {@" ${web_install_dir}/conf/vhost/${domain}.conf
  700. fi
  701. [ "${redirect_flag}" == 'y' ] && sed -i "s@^ root.*;@&\n if (\$host != ${domain}) { return 301 \$scheme://${domain}\$request_uri; }@" ${web_install_dir}/conf/vhost/${domain}.conf
  702. if [ "${nginx_ssl_flag}" == 'y' ]; then
  703. sed -i "s@^ listen 80;@&\n listen ${LISTENOPT};@" ${web_install_dir}/conf/vhost/${domain}.conf
  704. sed -i "s@^ server_name.*;@&\n ssl_stapling_verify on;@" ${web_install_dir}/conf/vhost/${domain}.conf
  705. sed -i "s@^ server_name.*;@&\n ssl_stapling on;@" ${web_install_dir}/conf/vhost/${domain}.conf
  706. sed -i "s@^ server_name.*;@&\n add_header Strict-Transport-Security max-age=15768000;@" ${web_install_dir}/conf/vhost/${domain}.conf
  707. sed -i "s@^ server_name.*;@&\n ssl_buffer_size 1400;@" ${web_install_dir}/conf/vhost/${domain}.conf
  708. sed -i "s@^ server_name.*;@&\n ssl_session_cache builtin:1000 shared:SSL:10m;@" ${web_install_dir}/conf/vhost/${domain}.conf
  709. sed -i "s@^ server_name.*;@&\n ssl_session_timeout 10m;@" ${web_install_dir}/conf/vhost/${domain}.conf
  710. sed -i "s@^ server_name.*;@&\n ssl_prefer_server_ciphers on;@" ${web_install_dir}/conf/vhost/${domain}.conf
  711. sed -i "s@^ server_name.*;@&\n ssl_ciphers TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:\!MD5;@" ${web_install_dir}/conf/vhost/${domain}.conf
  712. sed -i "s@^ server_name.*;@&\n ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;@" ${web_install_dir}/conf/vhost/${domain}.conf
  713. sed -i "s@^ server_name.*;@&\n ssl_certificate_key ${PATH_SSL}/${domain}.key;@" ${web_install_dir}/conf/vhost/${domain}.conf
  714. sed -i "s@^ server_name.*;@&\n ssl_certificate ${PATH_SSL}/${domain}.crt;@" ${web_install_dir}/conf/vhost/${domain}.conf
  715. fi
  716. fi
  717. [ "${https_flag}" == 'y' ] && sed -i "s@^ root.*;@&\n if (\$ssl_protocol = \"\") { return 301 https://\$host\$request_uri; }@" ${web_install_dir}/conf/vhost/${domain}.conf
  718. echo
  719. ${web_install_dir}/sbin/nginx -t
  720. if [ $? == 0 ]; then
  721. echo "Reload Nginx......"
  722. ${web_install_dir}/sbin/nginx -s reload
  723. else
  724. rm -f ${web_install_dir}/conf/vhost/${domain}.conf
  725. echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]"
  726. exit 1
  727. fi
  728. printf "
  729. #######################################################################
  730. # OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+ #
  731. # For more information please visit https://oneinstack.com #
  732. #######################################################################
  733. "
  734. echo "$(printf "%-30s" "Your domain:")${CMSG}${domain}${CEND}"
  735. echo "$(printf "%-30s" "Virtualhost conf:")${CMSG}${web_install_dir}/conf/vhost/${domain}.conf${CEND}"
  736. echo "$(printf "%-30s" "Directory of:")${CMSG}${vhostdir}${CEND}"
  737. [ "${rewrite_flag}" == 'y' -a "${rewrite}" != 'magento2' -a "${rewrite}" != 'pathinfo' ] && echo "$(printf "%-30s" "Rewrite rule:")${CMSG}${web_install_dir}/conf/rewrite/${rewrite}.conf${CEND}"
  738. Print_SSL
  739. }
  740. Apache_log() {
  741. while :; do echo
  742. read -e -p "Allow Apache access_log? [y/n]: " access_flag
  743. if [[ ! "${access_flag}" =~ ^[y,n]$ ]]; then
  744. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  745. else
  746. break
  747. fi
  748. done
  749. if [ "${access_flag}" == 'n' ]; then
  750. Apache_log='CustomLog "/dev/null" common'
  751. else
  752. Apache_log="CustomLog \"${wwwlogs_dir}/${domain}_apache.log\" common"
  753. echo "You access log file=${wwwlogs_dir}/${domain}_apache.log"
  754. fi
  755. }
  756. Create_apache_conf() {
  757. if [ "${Apache_main_ver}" == '24' ]; then
  758. if [ -e "${php_install_dir}/sbin/php-fpm" ] && [ -n "`grep -E ^LoadModule.*mod_proxy_fcgi.so ${apache_install_dir}/conf/httpd.conf`" ]; then
  759. Apache_fcgi=$(echo -e "<Files ~ (\\.user.ini|\\.htaccess|\\.git|\\.svn|\\.project|LICENSE|README.md)\$>\n Order allow,deny\n Deny from all\n </Files>\n <FilesMatch \\.php\$>\n SetHandler \"proxy:unix:/dev/shm/php${mphp_ver}-cgi.sock|fcgi://localhost\"\n </FilesMatch>")
  760. fi
  761. fi
  762. [ ! -d ${apache_install_dir}/conf/vhost ] && mkdir ${apache_install_dir}/conf/vhost
  763. cat > ${apache_install_dir}/conf/vhost/${domain}.conf << EOF
  764. <VirtualHost *:80>
  765. ServerAdmin admin@example.com
  766. DocumentRoot "${vhostdir}"
  767. ServerName ${domain}
  768. ${Apache_Domain_alias}
  769. ErrorLog "${wwwlogs_dir}/${domain}_error_apache.log"
  770. ${Apache_log}
  771. ${Apache_fcgi}
  772. <Directory "${vhostdir}">
  773. SetOutputFilter DEFLATE
  774. Options FollowSymLinks ExecCGI
  775. ${Apache_grant}
  776. AllowOverride All
  777. Order allow,deny
  778. Allow from all
  779. DirectoryIndex index.html index.php
  780. </Directory>
  781. </VirtualHost>
  782. EOF
  783. [ "$apache_ssl_flag" == 'y' ] && cat >> ${apache_install_dir}/conf/vhost/${domain}.conf << EOF
  784. <VirtualHost *:443>
  785. ServerAdmin admin@example.com
  786. DocumentRoot "${vhostdir}"
  787. ServerName ${domain}
  788. ${Apache_Domain_alias}
  789. ${Apache_SSL}
  790. ErrorLog "${wwwlogs_dir}/${domain}_error_apache.log"
  791. ${Apache_log}
  792. ${Apache_fcgi}
  793. <Directory "${vhostdir}">
  794. SetOutputFilter DEFLATE
  795. Options FollowSymLinks ExecCGI
  796. ${Apache_grant}
  797. AllowOverride All
  798. Order allow,deny
  799. Allow from all
  800. DirectoryIndex index.html index.php
  801. </Directory>
  802. </VirtualHost>
  803. EOF
  804. echo
  805. ${apache_install_dir}/bin/apachectl -t
  806. if [ $? == 0 ]; then
  807. echo "Restart Apache......"
  808. ${apache_install_dir}/bin/apachectl -k graceful
  809. else
  810. rm -f ${apache_install_dir}/conf/vhost/${domain}.conf
  811. echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]"
  812. exit 1
  813. fi
  814. printf "
  815. #######################################################################
  816. # OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+ #
  817. # For more information please visit https://oneinstack.com #
  818. #######################################################################
  819. "
  820. echo "$(printf "%-30s" "Your domain:")${CMSG}${domain}${CEND}"
  821. echo "$(printf "%-30s" "Virtualhost conf:")${CMSG}${apache_install_dir}/conf/vhost/${domain}.conf${CEND}"
  822. echo "$(printf "%-30s" "Directory of:")${CMSG}${vhostdir}${CEND}"
  823. Print_SSL
  824. }
  825. Create_nginx_apache_modphp_conf() {
  826. # Nginx/Tengine/OpenResty
  827. [ ! -d ${web_install_dir}/conf/vhost ] && mkdir ${web_install_dir}/conf/vhost
  828. cat > ${web_install_dir}/conf/vhost/${domain}.conf << EOF
  829. server {
  830. ${Nginx_conf}
  831. server_name ${domain}${moredomainame};
  832. ${Nginx_log}
  833. index index.html index.htm index.php;
  834. root ${vhostdir};
  835. ${Nginx_redirect}
  836. ${anti_hotlinking}
  837. location / {
  838. try_files \$uri @apache;
  839. }
  840. location @apache {
  841. proxy_pass http://127.0.0.1:88;
  842. include proxy.conf;
  843. }
  844. location ~ .*\.(php|php5|cgi|pl)?$ {
  845. proxy_pass http://127.0.0.1:88;
  846. include proxy.conf;
  847. }
  848. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
  849. expires 30d;
  850. access_log off;
  851. }
  852. location ~ .*\.(js|css)?$ {
  853. expires 7d;
  854. access_log off;
  855. }
  856. location ~ /\.ht {
  857. deny all;
  858. }
  859. }
  860. EOF
  861. [ "${https_flag}" == 'y' ] && sed -i "s@^ root.*;@&\n if (\$ssl_protocol = \"\") { return 301 https://\$host\$request_uri; }@" ${web_install_dir}/conf/vhost/${domain}.conf
  862. echo
  863. ${web_install_dir}/sbin/nginx -t
  864. if [ $? == 0 ]; then
  865. echo "Reload Nginx......"
  866. ${web_install_dir}/sbin/nginx -s reload
  867. else
  868. rm -f ${web_install_dir}/conf/vhost/${domain}.conf
  869. echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]"
  870. fi
  871. # Apache
  872. if [ "${Apache_main_ver}" == '24' ]; then
  873. if [ -e "${php_install_dir}/sbin/php-fpm" ] && [ -n "`grep -E ^LoadModule.*mod_proxy_fcgi.so ${apache_install_dir}/conf/httpd.conf`" ]; then
  874. Apache_fcgi=$(echo -e "<Files ~ (\\.user.ini|\\.htaccess|\\.git|\\.svn|\\.project|LICENSE|README.md)\$>\n Order allow,deny\n Deny from all\n </Files>\n <FilesMatch \\.php\$>\n SetHandler \"proxy:unix:/dev/shm/php${mphp_ver}-cgi.sock|fcgi://localhost\"\n </FilesMatch>")
  875. fi
  876. fi
  877. [ ! -d ${apache_install_dir}/conf/vhost ] && mkdir ${apache_install_dir}/conf/vhost
  878. cat > ${apache_install_dir}/conf/vhost/${domain}.conf << EOF
  879. <VirtualHost *:88>
  880. ServerAdmin admin@example.com
  881. DocumentRoot "${vhostdir}"
  882. ServerName ${domain}
  883. ${Apache_Domain_alias}
  884. ${Apache_SSL}
  885. ErrorLog "${wwwlogs_dir}/${domain}_error_apache.log"
  886. ${Apache_log}
  887. ${Apache_fcgi}
  888. <Directory "${vhostdir}">
  889. SetOutputFilter DEFLATE
  890. Options FollowSymLinks ExecCGI
  891. ${Apache_grant}
  892. AllowOverride All
  893. Order allow,deny
  894. Allow from all
  895. DirectoryIndex index.html index.php
  896. </Directory>
  897. </VirtualHost>
  898. EOF
  899. echo
  900. ${apache_install_dir}/bin/apachectl -t
  901. if [ $? == 0 ]; then
  902. echo "Restart Apache......"
  903. ${apache_install_dir}/bin/apachectl -k graceful
  904. else
  905. rm -f ${apache_install_dir}/conf/vhost/${domain}.conf
  906. exit 1
  907. fi
  908. printf "
  909. #######################################################################
  910. # OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+ #
  911. # For more information please visit https://oneinstack.com #
  912. #######################################################################
  913. "
  914. echo "$(printf "%-30s" "Your domain:")${CMSG}${domain}${CEND}"
  915. echo "$(printf "%-30s" "Nginx Virtualhost conf:")${CMSG}${web_install_dir}/conf/vhost/${domain}.conf${CEND}"
  916. echo "$(printf "%-30s" "Apache Virtualhost conf:")${CMSG}${apache_install_dir}/conf/vhost/${domain}.conf${CEND}"
  917. echo "$(printf "%-30s" "Directory of:")${CMSG}${vhostdir}${CEND}"
  918. Print_SSL
  919. }
  920. Add_Vhost() {
  921. if [ -e "${web_install_dir}/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" ]; then
  922. Choose_ENV
  923. Input_Add_domain
  924. Nginx_anti_hotlinking
  925. if [ "${NGX_FLAG}" == "java" ]; then
  926. Nginx_log
  927. Create_nginx_tomcat_conf
  928. else
  929. Nginx_rewrite
  930. Nginx_log
  931. Create_nginx_phpfpm_hhvm_conf
  932. fi
  933. elif [ ! -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/bin/httpd" ]; then
  934. Choose_ENV
  935. Input_Add_domain
  936. Apache_log
  937. Create_apache_conf
  938. elif [ ! -e "${web_install_dir}/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" -a -e "${tomcat_install_dir}/conf/server.xml" ]; then
  939. Choose_ENV
  940. Input_Add_domain
  941. Create_tomcat_conf
  942. elif [ -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/bin/httpd" ]; then
  943. Choose_ENV
  944. Input_Add_domain
  945. Nginx_anti_hotlinking
  946. if [ "${NGX_FLAG}" == "java" ]; then
  947. Nginx_log
  948. Create_nginx_tomcat_conf
  949. elif [ "${NGX_FLAG}" == "hhvm" ]; then
  950. Nginx_rewrite
  951. Nginx_log
  952. Create_nginx_phpfpm_hhvm_conf
  953. elif [ "${NGX_FLAG}" == "php" ]; then
  954. Nginx_log
  955. Apache_log
  956. Create_nginx_apache_modphp_conf
  957. fi
  958. else
  959. echo "Error! ${CFAILURE}Web server${CEND} not found!"
  960. fi
  961. }
  962. Del_NGX_Vhost() {
  963. if [ -e "${web_install_dir}/sbin/nginx" ]; then
  964. [ -d "${web_install_dir}/conf/vhost" ] && Domain_List=$(ls ${web_install_dir}/conf/vhost | sed "s@.conf@@g")
  965. if [ -n "${Domain_List}" ]; then
  966. echo
  967. echo "Virtualhost list:"
  968. echo ${CMSG}${Domain_List}${CEND}
  969. while :; do echo
  970. read -e -p "Please input a domain you want to delete: " domain
  971. if [ -z "$(echo ${domain} | grep '.*\..*')" ]; then
  972. echo "${CWARNING}Your ${domain} is invalid! ${CEND}"
  973. else
  974. if [ -e "${web_install_dir}/conf/vhost/${domain}.conf" ]; then
  975. Directory=$(grep '^ root' ${web_install_dir}/conf/vhost/${domain}.conf | head -1 | awk -F'[ ;]' '{print $(NF-1)}')
  976. rm -f ${web_install_dir}/conf/vhost/${domain}.conf
  977. [ -e "${web_install_dir}/conf/ssl/${domain}.crt" ] && rm -f ${web_install_dir}/conf/ssl/${domain}.{crt,key}
  978. ${web_install_dir}/sbin/nginx -s reload
  979. while :; do echo
  980. read -e -p "Do you want to delete Virtul Host directory? [y/n]: " Del_Vhost_wwwroot_flag
  981. if [[ ! ${Del_Vhost_wwwroot_flag} =~ ^[y,n]$ ]]; then
  982. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  983. else
  984. break
  985. fi
  986. done
  987. if [ "${Del_Vhost_wwwroot_flag}" == 'y' ]; then
  988. if [ "${quiet_flag}" != 'y' ]; then
  989. echo "Press Ctrl+c to cancel or Press any key to continue..."
  990. char=$(get_char)
  991. fi
  992. rm -rf ${Directory}
  993. fi
  994. echo
  995. echo "${CMSG}Domain: ${domain} has been deleted.${CEND}"
  996. echo
  997. else
  998. echo "${CWARNING}Virtualhost: ${domain} was not exist! ${CEND}"
  999. fi
  1000. break
  1001. fi
  1002. done
  1003. else
  1004. echo "${CWARNING}Virtualhost was not exist! ${CEND}"
  1005. fi
  1006. fi
  1007. }
  1008. Del_Apache_Vhost() {
  1009. if [ -e "${apache_install_dir}/bin/httpd" ]; then
  1010. if [ -e "${web_install_dir}/sbin/nginx" ]; then
  1011. rm -f ${apache_install_dir}/conf/vhost/${domain}.conf
  1012. ${apache_install_dir}/bin/apachectl -k graceful
  1013. else
  1014. Domain_List=$(ls ${apache_install_dir}/conf/vhost | grep -v '0.conf' | sed "s@.conf@@g")
  1015. if [ -n "${Domain_List}" ]; then
  1016. echo
  1017. echo "Virtualhost list:"
  1018. echo ${CMSG}${Domain_List}${CEND}
  1019. while :; do echo
  1020. read -e -p "Please input a domain you want to delete: " domain
  1021. if [ -z "$(echo ${domain} | grep '.*\..*')" ]; then
  1022. echo "${CWARNING}Your ${domain} is invalid! ${CEND}"
  1023. else
  1024. if [ -e "${apache_install_dir}/conf/vhost/${domain}.conf" ]; then
  1025. Directory=$(grep '^<Directory ' ${apache_install_dir}/conf/vhost/${domain}.conf | head -1 | awk -F'"' '{print $2}')
  1026. rm -f ${apache_install_dir}/conf/vhost/${domain}.conf
  1027. [ -e "${apache_install_dir}/conf/ssl/${domain}.crt" ] && rm -f ${apache_install_dir}/conf/ssl/${domain}.{crt,key}
  1028. ${apache_install_dir}/bin/apachectl -k graceful
  1029. while :; do echo
  1030. read -e -p "Do you want to delete Virtul Host directory? [y/n]: " Del_Vhost_wwwroot_flag
  1031. if [[ ! ${Del_Vhost_wwwroot_flag} =~ ^[y,n]$ ]]; then
  1032. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  1033. else
  1034. break
  1035. fi
  1036. done
  1037. if [ "${Del_Vhost_wwwroot_flag}" == 'y' ]; then
  1038. if [ "${quiet_flag}" != 'y' ]; then
  1039. echo "Press Ctrl+c to cancel or Press any key to continue..."
  1040. char=$(get_char)
  1041. fi
  1042. rm -rf ${Directory}
  1043. fi
  1044. echo "${CSUCCESS}Domain: ${domain} has been deleted.${CEND}"
  1045. else
  1046. echo "${CWARNING}Virtualhost: ${domain} was not exist! ${CEND}"
  1047. fi
  1048. break
  1049. fi
  1050. done
  1051. else
  1052. echo "${CWARNING}Virtualhost was not exist! ${CEND}"
  1053. fi
  1054. fi
  1055. fi
  1056. }
  1057. Del_Tomcat_Vhost() {
  1058. if [ -e "${tomcat_install_dir}/conf/server.xml" ]; then
  1059. if [ -e "${web_install_dir}/sbin/nginx" ]; then
  1060. if [ -n "$(echo ${domain} | grep '.*\..*')" ] && [ -n "$(grep vhost-${domain} ${tomcat_install_dir}/conf/server.xml)" ]; then
  1061. sed -i /vhost-${domain}/d ${tomcat_install_dir}/conf/server.xml
  1062. rm -f ${tomcat_install_dir}/conf/vhost/${domain}.xml
  1063. service tomcat restart
  1064. fi
  1065. else
  1066. Domain_List=$(ls ${tomcat_install_dir}/conf/vhost | grep -v 'localhost.xml' | sed "s@.xml@@g")
  1067. if [ -n "${Domain_List}" ]; then
  1068. echo
  1069. echo "Virtualhost list:"
  1070. echo ${CMSG}${Domain_List}${CEND}
  1071. while :; do echo
  1072. read -e -p "Please input a domain you want to delete: " domain
  1073. if [ -z "$(echo ${domain} | grep '.*\..*')" ]; then
  1074. echo "${CWARNING}Your ${domain} is invalid! ${CEND}"
  1075. else
  1076. if [ -n "$(grep vhost-${domain} ${tomcat_install_dir}/conf/server.xml)" ]; then
  1077. sed -i /vhost-${domain}/d ${tomcat_install_dir}/conf/server.xml
  1078. rm -f ${tomcat_install_dir}/conf/vhost/${domain}.xml
  1079. service tomcat restart
  1080. while :; do echo
  1081. read -e -p "Do you want to delete Virtul Host directory? [y/n]: " Del_Vhost_wwwroot_flag
  1082. if [[ ! ${Del_Vhost_wwwroot_flag} =~ ^[y,n]$ ]]; then
  1083. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  1084. else
  1085. break
  1086. fi
  1087. done
  1088. if [ "${Del_Vhost_wwwroot_flag}" == 'y' ]; then
  1089. if [ "${quiet_flag}" != 'y' ]; then
  1090. echo "Press Ctrl+c to cancel or Press any key to continue..."
  1091. char=$(get_char)
  1092. fi
  1093. rm -rf ${Directory}
  1094. fi
  1095. echo "${CSUCCESS}Domain: ${domain} has been deleted.${CEND}"
  1096. else
  1097. echo "${CWARNING}Virtualhost: ${domain} was not exist! ${CEND}"
  1098. fi
  1099. break
  1100. fi
  1101. done
  1102. else
  1103. echo "${CWARNING}Virtualhost was not exist! ${CEND}"
  1104. fi
  1105. fi
  1106. fi
  1107. }
  1108. List_Vhost() {
  1109. [ -e "${tomcat_install_dir}/conf/server.xml" -a ! -d "${web_install_dir}/sbin/nginx" ] && Domain_List=$(ls ${tomcat_install_dir}/conf/vhost | grep -v 'localhost.xml' | sed "s@.xml@@g")
  1110. [ -d "${web_install_dir}/conf/vhost" ] && Domain_List=$(ls ${web_install_dir}/conf/vhost | sed "s@.conf@@g")
  1111. [ -e "${apache_install_dir}/bin/httpd" -a ! -d "${web_install_dir}/conf/vhost" ] && Domain_List=$(ls ${apache_install_dir}/conf/vhost | grep -v '0.conf' | sed "s@.conf@@g")
  1112. if [ -n "${Domain_List}" ]; then
  1113. echo
  1114. echo "Virtualhost list:"
  1115. for D in ${Domain_List}; do echo ${CMSG}${D}${CEND}; done
  1116. else
  1117. echo "${CWARNING}Virtualhost was not exist! ${CEND}"
  1118. fi
  1119. }
  1120. if [ ${ARG_NUM} == 0 ]; then
  1121. Add_Vhost
  1122. else
  1123. [ "${add_flag}" == 'y' -o "${sslquiet_flag}" == 'y' ] && Add_Vhost
  1124. [ "${list_flag}" == 'y' ] && List_Vhost
  1125. [ "${delete_flag}" == 'y' ] && { Del_NGX_Vhost; Del_Apache_Vhost; Del_Tomcat_Vhost; }
  1126. fi