vhost.sh 18 KB

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