vhost.sh 18 KB

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