|
@@ -120,7 +120,7 @@ elif [ ! -e "$php_install_dir/bin/phpize" -a ! -e "$tomcat_install_dir/conf/serv
|
|
|
NGX_FLAG=hhvm
|
|
|
else
|
|
|
Number=000
|
|
|
- exit
|
|
|
+ NGX_FLAG=php
|
|
|
fi
|
|
|
|
|
|
if [ "$NGX_FLAG" == 'php' ];then
|
|
@@ -132,7 +132,69 @@ elif [ "$NGX_FLAG" == 'hhvm' ];then
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
+Nginx_ssl() {
|
|
|
+printf "
|
|
|
+You are about to be asked to enter information that will be incorporated
|
|
|
+into your certificate request.
|
|
|
+What you are about to enter is what is called a Distinguished Name or a DN.
|
|
|
+There are quite a few fields but you can leave some blank
|
|
|
+For some fields there will be a default value,
|
|
|
+If you enter '.', the field will be left blank.
|
|
|
+"
|
|
|
+
|
|
|
+echo
|
|
|
+read -p "Country Name (2 letter code) [CN]: " SELFSIGNEDSSL_C
|
|
|
+[ -z "$SELFSIGNEDSSL_C" ] && SELFSIGNEDSSL_C=CN
|
|
|
+
|
|
|
+echo
|
|
|
+read -p "State or Province Name (full name) [Shanghai]: " SELFSIGNEDSSL_ST
|
|
|
+[ -z "$SELFSIGNEDSSL_ST" ] && SELFSIGNEDSSL_ST=Shanghai
|
|
|
+
|
|
|
+echo
|
|
|
+read -p "Locality Name (eg, city) [Shanghai]: " SELFSIGNEDSSL_L
|
|
|
+[ -z "$SELFSIGNEDSSL_L" ] && SELFSIGNEDSSL_L=Shanghai
|
|
|
+
|
|
|
+echo
|
|
|
+read -p "Organization Name (eg, company) [LinuxEye Inc.]: " SELFSIGNEDSSL_O
|
|
|
+[ -z "$SELFSIGNEDSSL_O" ] && SELFSIGNEDSSL_O='LinuxEye Inc.'
|
|
|
+
|
|
|
+echo
|
|
|
+read -p "Organizational Unit Name (eg, section) [IT Dept.]: " SELFSIGNEDSSL_OU
|
|
|
+[ -z "$SELFSIGNEDSSL_OU" ] && SELFSIGNEDSSL_OU='IT Dept.'
|
|
|
+
|
|
|
+if [[ "$($web_install_dir/sbin/nginx -V 2>&1 | grep -Eo 'with-http_v2_module')" = 'with-http_v2_module' ]]; then
|
|
|
+ LISTENOPT='443 ssl http2'
|
|
|
+else
|
|
|
+ LISTENOPT='443 ssl spdy'
|
|
|
+fi
|
|
|
+
|
|
|
+openssl req -new -newkey rsa:2048 -sha256 -nodes -out $web_install_dir/conf/${domain}.csr -keyout $web_install_dir/conf/${domain}.key -subj "/C=${SELFSIGNEDSSL_C}/ST=${SELFSIGNEDSSL_ST}/L=${SELFSIGNEDSSL_L}/O=${SELFSIGNEDSSL_O}/OU=${SELFSIGNEDSSL_OU}/CN=${domain}" > /dev/null 2>&1
|
|
|
+/bin/cp $web_install_dir/conf/${domain}.csr{,_bk.`date +%Y-%m-%d_%H%M`}
|
|
|
+/bin/cp $web_install_dir/conf/${domain}.key{,_bk.`date +%Y-%m-%d_%H%M`}
|
|
|
+openssl x509 -req -days 36500 -sha256 -in $web_install_dir/conf/${domain}.csr -signkey $web_install_dir/conf/${domain}.key -out $web_install_dir/conf/${domain}.crt > /dev/null 2>&1
|
|
|
+}
|
|
|
+
|
|
|
+Print_ssl() {
|
|
|
+echo "`printf "%-30s" "Self-signed SSL Certificate:"`${CMSG}$web_install_dir/conf/${domain}.crt${CEND}"
|
|
|
+echo "`printf "%-30s" "SSL Private Key:"`${CMSG}$web_install_dir/conf/${domain}.key${CEND}"
|
|
|
+echo "`printf "%-30s" "SSL CSR File:"`${CMSG}$web_install_dir/conf/${domain}.csr${CEND}"
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
Input_Add_domain() {
|
|
|
+if [ -e "$web_install_dir/sbin/nginx" ];then
|
|
|
+ while :
|
|
|
+ do
|
|
|
+ echo
|
|
|
+ read -p "Do you want to setup SSL under Nginx? [y/n]: " nginx_ssl_yn
|
|
|
+ if [ "$nginx_ssl_yn" != 'y' ] && [ "$nginx_ssl_yn" != 'n' ];then
|
|
|
+ echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
|
|
|
+ else
|
|
|
+ break
|
|
|
+ fi
|
|
|
+ done
|
|
|
+fi
|
|
|
+
|
|
|
while :
|
|
|
do
|
|
|
echo
|
|
@@ -153,14 +215,21 @@ else
|
|
|
echo "domain=$domain"
|
|
|
fi
|
|
|
|
|
|
+if [ "$nginx_ssl_yn" == 'y' ]; then
|
|
|
+ Nginx_ssl
|
|
|
+ Nginx_conf=$(echo -e "listen $LISTENOPT;\nssl_certificate $web_install_dir/conf/$domain.crt;\nssl_certificate_key $web_install_dir/conf/$domain.key;\nssl_session_timeout 10m;\nssl_protocols TLSv1 TLSv1.1 TLSv1.2;\nssl_prefer_server_ciphers on;\nssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:RC4-SHA:\!aNULL:\!eNULL:\!EXPORT:\!DES:\!3DES:\!MD5:\!DSS:\!PKS";\nssl_session_cache builtin:1000 shared:SSL:10m;\nresolver 8.8.8.8 8.8.4.4 valid=300s;\nresolver_timeout 5s;")
|
|
|
+else
|
|
|
+ Nginx_conf='listen 80;'
|
|
|
+fi
|
|
|
+
|
|
|
while :
|
|
|
do
|
|
|
echo
|
|
|
- read -p "Do you want to add more domain name? [y/n]: " moredomainame_yn
|
|
|
+ read -p "Do you want to add more domain name? [y/n]: " moredomainame_yn
|
|
|
if [ "$moredomainame_yn" != 'y' ] && [ "$moredomainame_yn" != 'n' ];then
|
|
|
echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
|
|
|
else
|
|
|
- break
|
|
|
+ break
|
|
|
fi
|
|
|
done
|
|
|
|
|
@@ -168,7 +237,7 @@ if [ "$moredomainame_yn" == 'y' ]; then
|
|
|
while :
|
|
|
do
|
|
|
echo
|
|
|
- read -p "Type domainname,example(linuxeye.com www.example.com): " moredomain
|
|
|
+ read -p "Type domainname or IP(example: linuxeye.com 121.43.8.8): " moredomain
|
|
|
if [ -z "`echo $moredomain | grep '.*\..*'`" ]; then
|
|
|
echo "${CWARNING}input error! ${CEND}"
|
|
|
else
|
|
@@ -180,20 +249,41 @@ if [ "$moredomainame_yn" == 'y' ]; then
|
|
|
done
|
|
|
Apache_Domain_alias=ServerAlias$moredomainame
|
|
|
Tomcat_Domain_alias=$(for D in `echo $moredomainame`; do echo "<Alias>$D</Alias>"; done)
|
|
|
-fi
|
|
|
|
|
|
-echo
|
|
|
-echo "Please input the directory for the domain:$domain :"
|
|
|
-read -p "(Default directory: $wwwroot_dir/$domain): " vhostdir
|
|
|
-if [ -z "$vhostdir" ]; then
|
|
|
- vhostdir="$wwwroot_dir/$domain"
|
|
|
- echo "Virtual Host Directory=${CMSG}$vhostdir${CEND}"
|
|
|
+ while :
|
|
|
+ do
|
|
|
+ echo
|
|
|
+ read -p "Do you want to redirect from $moredomain to $domain? [y/n]: " redirect_yn
|
|
|
+ if [ "$redirect_yn" != 'y' ] && [ "$redirect_yn" != 'n' ];then
|
|
|
+ echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
|
|
|
+ else
|
|
|
+ break
|
|
|
+ fi
|
|
|
+ done
|
|
|
+ [ "$nginx_ssl_yn" == 'y' ] && HTTP_flag=https || HTTP_flag=http
|
|
|
+ [ "$redirect_yn" == 'y' ] && Nginx_redirect=$(echo -e "if (\$host != $domain) {\n\trewrite ^/(.*)\$ $HTTP_flag://$domain/\$1 permanent;\n\t}")
|
|
|
fi
|
|
|
-echo
|
|
|
-echo "Create Virtul Host directory......"
|
|
|
-mkdir -p $vhostdir
|
|
|
-echo "set permissions of Virtual Host directory......"
|
|
|
-chown -R ${run_user}.$run_user $vhostdir
|
|
|
+
|
|
|
+while :
|
|
|
+do
|
|
|
+ echo
|
|
|
+ echo "Please input the directory for the domain:$domain :"
|
|
|
+ read -p "(Default directory: $wwwroot_dir/$domain): " vhostdir
|
|
|
+ if [ -n "$vhostdir" -a -z "`echo $vhostdir | grep '^/'`" ];then
|
|
|
+ echo "${CWARNING}input error! Press Enter to continue...${CEND}"
|
|
|
+ else
|
|
|
+ if [ -z "$vhostdir" ]; then
|
|
|
+ vhostdir="$wwwroot_dir/$domain"
|
|
|
+ echo "Virtual Host Directory=${CMSG}$vhostdir${CEND}"
|
|
|
+ fi
|
|
|
+ echo
|
|
|
+ echo "Create Virtul Host directory......"
|
|
|
+ mkdir -p $vhostdir
|
|
|
+ echo "set permissions of Virtual Host directory......"
|
|
|
+ chown -R ${run_user}.$run_user $vhostdir
|
|
|
+ break
|
|
|
+ fi
|
|
|
+done
|
|
|
}
|
|
|
|
|
|
Nginx_anti_hotlinking() {
|
|
@@ -281,11 +371,12 @@ Create_nginx_tomcat_conf() {
|
|
|
[ ! -d $web_install_dir/conf/vhost ] && mkdir $web_install_dir/conf/vhost
|
|
|
cat > $web_install_dir/conf/vhost/$domain.conf << EOF
|
|
|
server {
|
|
|
-listen 80;
|
|
|
+$Nginx_conf
|
|
|
server_name $domain$moredomainame;
|
|
|
$N_log
|
|
|
index index.html index.htm index.jsp;
|
|
|
root $vhostdir;
|
|
|
+$Nginx_redirect
|
|
|
$anti_hotlinking
|
|
|
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
|
|
|
expires 30d;
|
|
@@ -327,10 +418,11 @@ printf "
|
|
|
# For more information please visit http://oneinstack.com #
|
|
|
#######################################################################
|
|
|
"
|
|
|
-echo "`printf "%-28s" "Your domain:"`${CMSG}$domain${CEND}"
|
|
|
-echo "`printf "%-28s" "Nginx Virtualhost conf:"`${CMSG}$web_install_dir/conf/vhost/$domain.conf${CEND}"
|
|
|
-echo "`printf "%-28s" "Tomcat Virtualhost conf:"`${CMSG}$tomcat_install_dir/conf/vhost/$domain.xml${CEND}"
|
|
|
-echo "`printf "%-28s" "Directory of:"`${CMSG}$vhostdir${CEND}"
|
|
|
+echo "`printf "%-30s" "Your domain:"`${CMSG}$domain${CEND}"
|
|
|
+echo "`printf "%-30s" "Nginx Virtualhost conf:"`${CMSG}$web_install_dir/conf/vhost/$domain.conf${CEND}"
|
|
|
+echo "`printf "%-30s" "Tomcat Virtualhost conf:"`${CMSG}$tomcat_install_dir/conf/vhost/$domain.xml${CEND}"
|
|
|
+echo "`printf "%-30s" "Directory of:"`${CMSG}$vhostdir${CEND}"
|
|
|
+[ "$nginx_ssl_yn" == 'y' ] && Print_ssl
|
|
|
|
|
|
}
|
|
|
|
|
@@ -338,12 +430,13 @@ Create_nginx_php-fpm_hhvm_conf() {
|
|
|
[ ! -d $web_install_dir/conf/vhost ] && mkdir $web_install_dir/conf/vhost
|
|
|
cat > $web_install_dir/conf/vhost/$domain.conf << EOF
|
|
|
server {
|
|
|
-listen 80;
|
|
|
+$Nginx_conf
|
|
|
server_name $domain$moredomainame;
|
|
|
$N_log
|
|
|
index index.html index.htm index.php;
|
|
|
-include $rewrite.conf;
|
|
|
+include $web_install_dir/conf/$rewrite.conf;
|
|
|
root $vhostdir;
|
|
|
+$Nginx_redirect
|
|
|
$anti_hotlinking
|
|
|
$NGX_CONF
|
|
|
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
|
|
@@ -374,10 +467,11 @@ printf "
|
|
|
# For more information please visit http://oneinstack.com #
|
|
|
#######################################################################
|
|
|
"
|
|
|
-echo "`printf "%-20s" "Your domain:"`${CMSG}$domain${CEND}"
|
|
|
-echo "`printf "%-20s" "Virtualhost conf:"`${CMSG}$web_install_dir/conf/vhost/$domain.conf${CEND}"
|
|
|
-echo "`printf "%-20s" "Directory of:"`${CMSG}$vhostdir${CEND}"
|
|
|
-[ "$rewrite_yn" == 'y' ] && echo "`printf "%-20s" "Rewrite rule:"`${CMSG}$rewrite${CEND}"
|
|
|
+echo "`printf "%-30s" "Your domain:"`${CMSG}$domain${CEND}"
|
|
|
+echo "`printf "%-30s" "Virtualhost conf:"`${CMSG}$web_install_dir/conf/vhost/$domain.conf${CEND}"
|
|
|
+echo "`printf "%-30s" "Directory of:"`${CMSG}$vhostdir${CEND}"
|
|
|
+[ "$rewrite_yn" == 'y' ] && echo "`printf "%-20s" "Rewrite rule:"`${CMSG}$web_install_dir/conf/$rewrite.conf${CEND}"
|
|
|
+[ "$nginx_ssl_yn" == 'y' ] && Print_ssl
|
|
|
}
|
|
|
|
|
|
Apache_log() {
|
|
@@ -450,11 +544,12 @@ Create_nginx_apache_mod-php_conf() {
|
|
|
[ ! -d $web_install_dir/conf/vhost ] && mkdir $web_install_dir/conf/vhost
|
|
|
cat > $web_install_dir/conf/vhost/$domain.conf << EOF
|
|
|
server {
|
|
|
-listen 80;
|
|
|
+$Nginx_conf
|
|
|
server_name $domain$moredomainame;
|
|
|
$N_log
|
|
|
index index.html index.htm index.php;
|
|
|
root $vhostdir;
|
|
|
+$Nginx_redirect
|
|
|
$anti_hotlinking
|
|
|
location / {
|
|
|
try_files \$uri @apache;
|
|
@@ -527,11 +622,12 @@ printf "
|
|
|
# For more information please visit http://oneinstack.com #
|
|
|
#######################################################################
|
|
|
"
|
|
|
-echo "`printf "%-28s" "Your domain:"`${CMSG}$domain${CEND}"
|
|
|
-echo "`printf "%-28s" "Nginx Virtualhost conf:"`${CMSG}$web_install_dir/conf/vhost/$domain.conf${CEND}"
|
|
|
-echo "`printf "%-28s" "Apache Virtualhost conf:"`${CMSG}$apache_install_dir/conf/vhost/$domain.conf${CEND}"
|
|
|
-echo "`printf "%-28s" "Directory of:"`${CMSG}$vhostdir${CEND}"
|
|
|
-[ "$rewrite_yn" == 'y' ] && echo "`printf "%-28s" "Rewrite rule:"`${CMSG}$rewrite${CEND}"
|
|
|
+echo "`printf "%-30s" "Your domain:"`${CMSG}$domain${CEND}"
|
|
|
+echo "`printf "%-30s" "Nginx Virtualhost conf:"`${CMSG}$web_install_dir/conf/vhost/$domain.conf${CEND}"
|
|
|
+echo "`printf "%-30s" "Apache Virtualhost conf:"`${CMSG}$apache_install_dir/conf/vhost/$domain.conf${CEND}"
|
|
|
+echo "`printf "%-30s" "Directory of:"`${CMSG}$vhostdir${CEND}"
|
|
|
+[ "$rewrite_yn" == 'y' ] && echo "`printf "%-28s" "Rewrite rule:"`${CMSG}$web_install_dir/conf/$rewrite.conf${CEND}"
|
|
|
+[ "$nginx_ssl_yn" == 'y' ] && Print_ssl
|
|
|
}
|
|
|
|
|
|
Add_Vhost() {
|