1
0

vhost.sh 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
  6. #
  7. # Project home page:
  8. # http://oneinstack.com
  9. # https://github.com/lj2007331/oneinstack
  10. export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  11. clear
  12. printf "
  13. #######################################################################
  14. # OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ #
  15. # For more information please visit http://oneinstack.com #
  16. #######################################################################
  17. "
  18. . ./options.conf
  19. . ./include/color.sh
  20. # Check if user is root
  21. [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
  22. Choose_env()
  23. {
  24. if [ -e "$php_install_dir" -a -e "$tomcat_install_dir" -a -e "/usr/bin/hhvm" ];then
  25. Number=111
  26. while :
  27. do
  28. echo
  29. echo 'Please choose to use environment:'
  30. echo -e "\t${CMSG}1${CEND}. Use php"
  31. echo -e "\t${CMSG}2${CEND}. Use java"
  32. echo -e "\t${CMSG}3${CEND}. Use hhvm"
  33. read -p "Please input a number:(Default 1 press Enter) " Choose_number
  34. [ -z "$Choose_number" ] && Choose_number=1
  35. if [ $Choose_number != 1 -a $Choose_number != 2 -a $Choose_number != 3 ];then
  36. echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
  37. else
  38. break
  39. fi
  40. done
  41. [ "$Choose_number" == '1' ] && NGX_FLAG=php
  42. [ "$Choose_number" == '2' ] && NGX_FLAG=java
  43. [ "$Choose_number" == '3' ] && NGX_FLAG=hhvm
  44. elif [ -e "$php_install_dir" -a -e "$tomcat_install_dir" -a ! -e "/usr/bin/hhvm" ];then
  45. Number=110
  46. while :
  47. do
  48. echo
  49. echo 'Please choose to use environment:'
  50. echo -e "\t${CMSG}1${CEND}. Use php"
  51. echo -e "\t${CMSG}2${CEND}. Use java"
  52. read -p "Please input a number:(Default 1 press Enter) " Choose_number
  53. [ -z "$Choose_number" ] && Choose_number=1
  54. if [ $Choose_number != 1 -a $Choose_number != 2 ];then
  55. echo "${CWARNING}input error! Please only input number 1,2${CEND}"
  56. else
  57. break
  58. fi
  59. done
  60. [ "$Choose_number" == '1' ] && NGX_FLAG=php
  61. [ "$Choose_number" == '2' ] && NGX_FLAG=java
  62. elif [ -e "$php_install_dir" -a ! -e "$tomcat_install_dir" -a ! -e "/usr/bin/hhvm" ];then
  63. Number=100
  64. NGX_FLAG=php
  65. elif [ -e "$php_install_dir" -a ! -e "$tomcat_install_dir" -a -e "/usr/bin/hhvm" ];then
  66. Number=101
  67. while :
  68. do
  69. echo
  70. echo 'Please choose to use environment:'
  71. echo -e "\t${CMSG}1${CEND}. Use php"
  72. echo -e "\t${CMSG}2${CEND}. Use hhvm"
  73. read -p "Please input a number:(Default 1 press Enter) " Choose_number
  74. [ -z "$Choose_number" ] && Choose_number=1
  75. if [ $Choose_number != 1 -a $Choose_number != 2 ];then
  76. echo "${CWARNING}input error! Please only input number 1,2${CEND}"
  77. else
  78. break
  79. fi
  80. done
  81. [ "$Choose_number" == '1' ] && NGX_FLAG=php
  82. [ "$Choose_number" == '2' ] && NGX_FLAG=hhvm
  83. elif [ ! -e "$php_install_dir" -a -e "$tomcat_install_dir" -a -e "/usr/bin/hhvm" ];then
  84. Number=011
  85. while :
  86. do
  87. echo
  88. echo 'Please choose to use environment:'
  89. echo -e "\t${CMSG}1${CEND}. Use java"
  90. echo -e "\t${CMSG}2${CEND}. Use hhvm"
  91. read -p "Please input a number:(Default 1 press Enter) " Choose_number
  92. [ -z "$Choose_number" ] && Choose_number=1
  93. if [ $Choose_number != 1 -a $Choose_number != 2 ];then
  94. echo "${CWARNING}input error! Please only input number 1,2${CEND}"
  95. else
  96. break
  97. fi
  98. done
  99. [ "$Choose_number" == '1' ] && NGX_FLAG=java
  100. [ "$Choose_number" == '2' ] && NGX_FLAG=hhvm
  101. elif [ ! -e "$php_install_dir" -a -e "$tomcat_install_dir" -a ! -e "/usr/bin/hhvm" ];then
  102. Number=010
  103. NGX_FLAG=java
  104. elif [ ! -e "$php_install_dir" -a ! -e "$tomcat_install_dir" -a -e "/usr/bin/hhvm" ];then
  105. Number=001
  106. NGX_FLAG=hhvm
  107. else
  108. Number=000
  109. exit
  110. fi
  111. if [ "$NGX_FLAG" == 'php' ];then
  112. NGX_CONF="location ~ .*\.(php|php5)?$ {\n\t#fastcgi_pass remote_php_ip:9000;\n\tfastcgi_pass unix:/dev/shm/php-cgi.sock;\n\tfastcgi_index index.php;\n\tinclude fastcgi.conf;\n\t}"
  113. elif [ "$NGX_FLAG" == 'java' ];then
  114. NGX_CONF="location ~ {\n\tproxy_set_header Host \$host;\n\tproxy_set_header X-Real-IP \$remote_addr;\n\tproxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;\n\tproxy_pass http://127.0.0.1:8080;\n\t}"
  115. elif [ "$NGX_FLAG" == 'hhvm' ];then
  116. NGX_CONF="location ~ .*\.(php|php5)?$ {\n\tfastcgi_pass unix:/var/log/hhvm/sock;\n\tfastcgi_index index.php;\n\tfastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;\n\tinclude fastcgi_params;\n\t}"
  117. fi
  118. }
  119. Input_domain()
  120. {
  121. while :
  122. do
  123. echo
  124. read -p "Please input domain(example: www.linuxeye.com): " domain
  125. if [ -z "`echo $domain | grep '.*\..*'`" ]; then
  126. echo "${CWARNING}input error! ${CEND}"
  127. else
  128. break
  129. fi
  130. done
  131. if [ -e "$web_install_dir/conf/vhost/$domain.conf" -o -e "$apache_install_dir/conf/vhost/$domain.conf" ]; then
  132. [ -e "$web_install_dir/conf/vhost/$domain.conf" ] && echo -e "$domain in the Nginx/Tengine already exist! \nYou can delete \033[32m$web_install_dir/conf/vhost/$domain.conf\033[0m and re-create"
  133. [ -e "$apache_install_dir/conf/vhost/$domain.conf" ] && echo -e "$domain in the Apache already exist! \nYou can delete \033[32m$apache_install_dir/conf/vhost/$domain.conf\033[0m and re-create"
  134. exit
  135. else
  136. echo "domain=$domain"
  137. fi
  138. while :
  139. do
  140. echo ''
  141. read -p "Do you want to add more domain name? [y/n]: " moredomainame_yn
  142. if [ "$moredomainame_yn" != 'y' ] && [ "$moredomainame_yn" != 'n' ];then
  143. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  144. else
  145. break
  146. fi
  147. done
  148. if [ "$moredomainame_yn" == 'y' ]; then
  149. while :
  150. do
  151. echo
  152. read -p "Type domainname,example(linuxeye.com www.example.com): " moredomain
  153. if [ -z "`echo $moredomain | grep '.*\..*'`" ]; then
  154. echo "${CWARNING}input error! ${CEND}"
  155. else
  156. [ "$moredomain" == "$domain" ] && echo "${CWARNING}Domain name already exists! ${CND}" && continue
  157. echo domain list="$moredomain"
  158. moredomainame=" $moredomain"
  159. break
  160. fi
  161. done
  162. Domain_alias=ServerAlias$moredomainame
  163. fi
  164. echo
  165. echo "Please input the directory for the domain:$domain :"
  166. read -p "(Default directory: $wwwroot_dir/$domain): " vhostdir
  167. if [ -z "$vhostdir" ]; then
  168. vhostdir="$wwwroot_dir/$domain"
  169. echo "Virtual Host Directory=${CMSG}$vhostdir${CEND}"
  170. fi
  171. echo
  172. echo "Create Virtul Host directory......"
  173. mkdir -p $vhostdir
  174. echo "set permissions of Virtual Host directory......"
  175. chown -R ${run_user}.$run_user $vhostdir
  176. }
  177. Nginx_anti_hotlinking()
  178. {
  179. while :
  180. do
  181. echo ''
  182. read -p "Do you want to add hotlink protection? [y/n]: " anti_hotlinking_yn
  183. if [ "$anti_hotlinking_yn" != 'y' ] && [ "$anti_hotlinking_yn" != 'n' ];then
  184. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  185. else
  186. break
  187. fi
  188. done
  189. if [ -n "`echo $domain | grep '.*\..*\..*'`" ];then
  190. domain_allow="*.${domain#*.} $domain"
  191. else
  192. domain_allow="*.$domain $domain"
  193. fi
  194. if [ "$anti_hotlinking_yn" == 'y' ];then
  195. if [ "$moredomainame_yn" == 'y' ]; then
  196. domain_allow_all=$domain_allow$moredomainame
  197. else
  198. domain_allow_all=$domain_allow
  199. fi
  200. anti_hotlinking=$(echo -e "location ~ .*\.(wma|wmv|asf|mp3|mmf|zip|rar|jpg|gif|png|swf|flv)$ {\n\tvalid_referers none blocked $domain_allow_all;\n\tif (\$invalid_referer) {\n\t\t#rewrite ^/ http://www.linuxeye.com/403.html;\n\t\treturn 403;\n\t\t}\n\t}")
  201. else
  202. anti_hotlinking=
  203. fi
  204. }
  205. Nginx_rewrite()
  206. {
  207. while :
  208. do
  209. echo
  210. read -p "Allow Rewrite rule? [y/n]: " rewrite_yn
  211. if [ "$rewrite_yn" != 'y' ] && [ "$rewrite_yn" != 'n' ];then
  212. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  213. else
  214. break
  215. fi
  216. done
  217. if [ "$rewrite_yn" == 'n' ];then
  218. rewrite="none"
  219. touch "$web_install_dir/conf/$rewrite.conf"
  220. else
  221. echo
  222. echo "Please input the rewrite of programme :"
  223. echo "${CMSG}wordpress${CEND},${CMSG}discuz${CEND},${CMSG}opencart${CEND},${CMSG}laravel${CEND},${CMSG}typecho${CEND},${CMSG}ecshop${CEND},${CMSG}drupal${CEND},${CMSG}joomla${CEND} rewrite was exist."
  224. read -p "(Default rewrite: other):" rewrite
  225. if [ "$rewrite" == "" ]; then
  226. rewrite="other"
  227. fi
  228. echo "You choose rewrite=${CMSG}$rewrite${CEND}"
  229. if [ -s "conf/$rewrite.conf" ];then
  230. /bin/cp config/$rewrite.conf $web_install_dir/conf/$rewrite.conf
  231. else
  232. touch "$web_install_dir/conf/$rewrite.conf"
  233. fi
  234. fi
  235. }
  236. Nginx_log()
  237. {
  238. while :
  239. do
  240. echo
  241. read -p "Allow Nginx/Tengine access_log? [y/n]: " access_yn
  242. if [ "$access_yn" != 'y' ] && [ "$access_yn" != 'n' ];then
  243. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  244. else
  245. break
  246. fi
  247. done
  248. if [ "$access_yn" == 'n' ]; then
  249. N_log="access_log off;"
  250. else
  251. N_log="access_log $wwwlogs_dir/${domain}_nginx.log combined;"
  252. echo "You access log file=${CMSG}$wwwlogs_dir/${domain}_nginx.log${CEND}"
  253. fi
  254. }
  255. Create_nginx_tomcat_conf()
  256. {
  257. [ -n "`grep $vhostdir $tomcat_install_dir/conf/server.xml`" ] && { echo -e "\n$vhostdir in the tomcat already exist! \nYou must manually modify the file=${MSG}$tomcat_install_dir/conf/server.xml${CEND}"; exit; }
  258. [ ! -d $web_install_dir/conf/vhost ] && mkdir $web_install_dir/conf/vhost
  259. cat > $web_install_dir/conf/vhost/$domain.conf << EOF
  260. server {
  261. listen 80;
  262. server_name $domain$moredomainame;
  263. $N_log
  264. index index.html index.htm index.jsp index.php;
  265. root $vhostdir;
  266. #error_page 404 /404.html;
  267. #if ( \$query_string ~* ".*[\;'\<\>].*" ){
  268. # return 404;
  269. # }
  270. $anti_hotlinking
  271. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
  272. expires 30d;
  273. }
  274. location ~ .*\.(js|css)?$ {
  275. expires 7d;
  276. }
  277. `echo -e $NGX_CONF`
  278. }
  279. EOF
  280. sed -i "s@autoDeploy=\"true\">@autoDeploy=\"true\">\n\t<Context path=\"\" docBase=\"$vhostdir\" debug=\"0\" reloadable=\"true\" crossContext=\"true\"/>@" $tomcat_install_dir/conf/server.xml
  281. echo
  282. $web_install_dir/sbin/nginx -t
  283. if [ $? == 0 ];then
  284. echo "Restart Nginx......"
  285. $web_install_dir/sbin/nginx -s reload
  286. else
  287. rm -rf $web_install_dir/conf/vhost/$domain.conf
  288. echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]"
  289. exit 1
  290. fi
  291. printf "
  292. #######################################################################
  293. # OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ #
  294. # For more information please visit http://oneinstack.com #
  295. #######################################################################
  296. "
  297. echo "`printf "%-32s" "Your domain:"`${CMSG}$domain${CEND}"
  298. echo "`printf "%-32s" "Virtualhost conf:"`${CMSG}$web_install_dir/conf/vhost/$domain.conf${CEND}"
  299. echo "`printf "%-32s" "Directory of:"`${CMSG}$vhostdir${CEND}"
  300. }
  301. Create_nginx_php-fpm_conf()
  302. {
  303. [ ! -d $web_install_dir/conf/vhost ] && mkdir $web_install_dir/conf/vhost
  304. cat > $web_install_dir/conf/vhost/$domain.conf << EOF
  305. server {
  306. listen 80;
  307. server_name $domain$moredomainame;
  308. $N_log
  309. index index.html index.htm index.jsp index.php;
  310. include $rewrite.conf;
  311. root $vhostdir;
  312. #error_page 404 /404.html;
  313. if ( \$query_string ~* ".*[\;'\<\>].*" ){
  314. return 404;
  315. }
  316. $anti_hotlinking
  317. `echo -e $NGX_CONF`
  318. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
  319. expires 30d;
  320. }
  321. location ~ .*\.(js|css)?$ {
  322. expires 7d;
  323. }
  324. }
  325. EOF
  326. echo
  327. $web_install_dir/sbin/nginx -t
  328. if [ $? == 0 ];then
  329. echo "Restart Nginx......"
  330. $web_install_dir/sbin/nginx -s reload
  331. else
  332. rm -rf $web_install_dir/conf/vhost/$domain.conf
  333. echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]"
  334. exit 1
  335. fi
  336. printf "
  337. #######################################################################
  338. # OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ #
  339. # For more information please visit http://oneinstack.com #
  340. #######################################################################
  341. "
  342. echo "`printf "%-32s" "Your domain:"`${CMSG}$domain${CEND}"
  343. echo "`printf "%-32s" "Virtualhost conf:"`${CMSG}$web_install_dir/conf/vhost/$domain.conf${CEND}"
  344. echo "`printf "%-32s" "Directory of:"`${CMSG}$vhostdir${CEND}"
  345. [ "$rewrite_yn" == 'y' ] && echo "`printf "%-32s" "Rewrite rule:"`${CMSG}$rewrite${CEND}"
  346. }
  347. Apache_log()
  348. {
  349. while :
  350. do
  351. echo
  352. read -p "Allow Apache access_log? [y/n]: " access_yn
  353. if [ "$access_yn" != 'y' ] && [ "$access_yn" != 'n' ];then
  354. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  355. else
  356. break
  357. fi
  358. done
  359. if [ "$access_yn" == 'n' ]; then
  360. A_log='CustomLog "/dev/null" common'
  361. else
  362. A_log="CustomLog \"$wwwlogs_dir/${domain}_apache.log\" common"
  363. echo "You access log file=$wwwlogs_dir/${domain}_apache.log"
  364. fi
  365. }
  366. Create_apache_conf()
  367. {
  368. [ "`$apache_install_dir/bin/apachectl -v | awk -F'.' /version/'{print $2}'`" == '4' ] && R_TMP='Require all granted' || R_TMP=
  369. [ ! -d $apache_install_dir/conf/vhost ] && mkdir $apache_install_dir/conf/vhost
  370. cat > $apache_install_dir/conf/vhost/$domain.conf << EOF
  371. <VirtualHost *:80>
  372. ServerAdmin admin@linuxeye.com
  373. DocumentRoot "$vhostdir"
  374. ServerName $domain
  375. $Domain_alias
  376. ErrorLog "$wwwlogs_dir/${domain}_error_apache.log"
  377. $A_log
  378. <Directory "$vhostdir">
  379. SetOutputFilter DEFLATE
  380. Options FollowSymLinks
  381. $R_TMP
  382. AllowOverride All
  383. Order allow,deny
  384. Allow from all
  385. DirectoryIndex index.html index.php
  386. </Directory>
  387. </VirtualHost>
  388. EOF
  389. echo
  390. $apache_install_dir/bin/apachectl -t
  391. if [ $? == 0 ];then
  392. echo "Restart Apache......"
  393. /etc/init.d/httpd restart
  394. else
  395. rm -rf $apache_install_dir/conf/vhost/$domain.conf
  396. echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]"
  397. exit 1
  398. fi
  399. printf "
  400. #######################################################################
  401. # OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ #
  402. # For more information please visit http://oneinstack.com #
  403. #######################################################################
  404. "
  405. echo "`printf "%-32s" "Your domain:"`${CMSG}$domain${CEND}"
  406. echo "`printf "%-32s" "Virtualhost conf:"`${CMSG}$apache_install_dir/conf/vhost/$domain.conf${CEND}"
  407. echo "`printf "%-32s" "Directory of $domain:"`${CMSG}$vhostdir${CEND}"
  408. }
  409. Create_nginx_apache_mod-php_conf()
  410. {
  411. # Nginx/Tengine
  412. [ ! -d $web_install_dir/conf/vhost ] && mkdir $web_install_dir/conf/vhost
  413. cat > $web_install_dir/conf/vhost/$domain.conf << EOF
  414. server {
  415. listen 80;
  416. server_name $domain$moredomainame;
  417. $N_log
  418. index index.html index.htm index.jsp index.php;
  419. root $vhostdir;
  420. #error_page 404 /404.html;
  421. if ( \$query_string ~* ".*[\;'\<\>].*" ){
  422. return 404;
  423. }
  424. $anti_hotlinking
  425. location / {
  426. try_files \$uri @apache;
  427. }
  428. location @apache {
  429. internal;
  430. proxy_pass http://127.0.0.1:9090;
  431. }
  432. location ~ .*\.(php|php5)?$ {
  433. proxy_pass http://127.0.0.1:9090;
  434. }
  435. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
  436. expires 30d;
  437. }
  438. location ~ .*\.(js|css)?$ {
  439. expires 7d;
  440. }
  441. }
  442. EOF
  443. echo
  444. $web_install_dir/sbin/nginx -t
  445. if [ $? == 0 ];then
  446. echo "Restart Nginx......"
  447. $web_install_dir/sbin/nginx -s reload
  448. else
  449. rm -rf $web_install_dir/conf/vhost/$domain.conf
  450. echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]"
  451. fi
  452. # Apache
  453. [ "`$apache_install_dir/bin/apachectl -v | awk -F'.' /version/'{print $2}'`" == '4' ] && R_TMP='Require all granted' || R_TMP=
  454. [ ! -d $apache_install_dir/conf/vhost ] && mkdir $apache_install_dir/conf/vhost
  455. cat > $apache_install_dir/conf/vhost/$domain.conf << EOF
  456. <VirtualHost *:9090>
  457. ServerAdmin admin@linuxeye.com
  458. DocumentRoot "$vhostdir"
  459. ServerName $domain
  460. $Domain_alias
  461. ErrorLog "$wwwlogs_dir/${domain}_error_apache.log"
  462. $A_log
  463. <Directory "$vhostdir">
  464. SetOutputFilter DEFLATE
  465. Options FollowSymLinks
  466. $R_TMP
  467. AllowOverride All
  468. Order allow,deny
  469. Allow from all
  470. DirectoryIndex index.html index.php
  471. </Directory>
  472. </VirtualHost>
  473. EOF
  474. echo
  475. $apache_install_dir/bin/apachectl -t
  476. if [ $? == 0 ];then
  477. echo "Restart Apache......"
  478. /etc/init.d/httpd restart
  479. else
  480. rm -rf $apache_install_dir/conf/vhost/$domain.conf
  481. exit 1
  482. fi
  483. printf "
  484. #######################################################################
  485. # OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ #
  486. # For more information please visit http://oneinstack.com #
  487. #######################################################################
  488. "
  489. echo "`printf "%-32s" "Your domain:"`${CMSG}$domain${CEND}"
  490. echo "`printf "%-32s" "Nginx Virtualhost conf:"`${CMSG}$web_install_dir/conf/vhost/$domain.conf${CEND}"
  491. echo "`printf "%-32s" "Apache Virtualhost conf:"`${CMSG}$apache_install_dir/conf/vhost/$domain.conf${CEND}"
  492. echo "`printf "%-32s" "Directory of:"`${CMSG}$vhostdir${CEND}"
  493. [ "$rewrite_yn" == 'y' ] && echo "`printf "%-32s" "Rewrite rule:"`${CMSG}$rewrite${CEND}"
  494. }
  495. if [ -d "$web_install_dir" -a ! -d "$apache_install_dir" -a "$web_install_dir" != "$apache_install_dir" ];then
  496. Choose_env
  497. Input_domain
  498. Nginx_anti_hotlinking
  499. if [ "$NGX_FLAG" == 'java' ];then
  500. Nginx_log
  501. Create_nginx_tomcat_conf
  502. else
  503. Nginx_rewrite
  504. Nginx_log
  505. Create_nginx_php-fpm_conf
  506. fi
  507. elif [ -d "$web_install_dir" -a -d "$apache_install_dir" -a "$web_install_dir" == "$apache_install_dir" ];then
  508. Choose_env
  509. Input_domain
  510. Apache_log
  511. Create_apache_conf
  512. elif [ -d "$web_install_dir" -a -d "$apache_install_dir" -a "$web_install_dir" != "$apache_install_dir" ];then
  513. Choose_env
  514. Input_domain
  515. Nginx_anti_hotlinking
  516. if [ "$NGX_FLAG" == 'java' ];then
  517. Nginx_log
  518. Create_nginx_tomcat_conf
  519. else
  520. #Nginx_rewrite
  521. Nginx_log
  522. Apache_log
  523. Create_nginx_apache_mod-php_conf
  524. fi
  525. fi