소스 검색

Merge pull request #146 from kaneawk/p1

Clean up the source directory
lj2007331 6 년 전
부모
커밋
15c7187891
5개의 변경된 파일86개의 추가작업 그리고 77개의 파일을 삭제
  1. 2 2
      include/apache-2.2.sh
  2. 6 3
      include/apache-2.4.sh
  3. 25 23
      include/nginx.sh
  4. 26 24
      include/openresty.sh
  5. 27 25
      include/tengine.sh

+ 2 - 2
include/apache-2.2.sh

@@ -36,8 +36,8 @@ Install_Apache22() {
   sed -i '2a # chkconfig: - 85 15' /etc/init.d/httpd
   sed -i '3a # description: Apache is a World Wide Web server. It is used to serve' /etc/init.d/httpd
   chmod +x /etc/init.d/httpd
-  [ "$OS" == 'CentOS' ] && { chkconfig --add httpd; chkconfig httpd on; }
-  [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d httpd defaults
+  [ "${OS}" == 'CentOS' ] && { chkconfig --add httpd; chkconfig httpd on; }
+  [[ ${OS} =~ ^Ubuntu$|^Debian$ ]] && update-rc.d httpd defaults
 
   sed -i "s@^User daemon@User ${run_user}@" ${apache_install_dir}/conf/httpd.conf
   sed -i "s@^Group daemon@Group ${run_user}@" ${apache_install_dir}/conf/httpd.conf

+ 6 - 3
include/apache-2.4.sh

@@ -18,12 +18,12 @@ Install_Apache24() {
   id -u ${run_user} >/dev/null 2>&1
   [ $? -ne 0 ] && useradd -M -s /sbin/nologin ${run_user}
   tar xzf httpd-${apache24_ver}.tar.gz
-  tar xzf nghttp2-${nghttp2_ver}.tar.gz
   tar xzf apr-${apr_ver}.tar.gz
   tar xzf apr-util-${apr_util_ver}.tar.gz
 
   # install nghttp2
   if [ ! -e "/usr/local/lib/libnghttp2.so" ]; then
+    tar xzf nghttp2-${nghttp2_ver}.tar.gz
     pushd nghttp2-${nghttp2_ver}
     ./configure
     make -j ${THREAD} && make install
@@ -44,6 +44,9 @@ Install_Apache24() {
   if [ -e "${apache_install_dir}/conf/httpd.conf" ]; then
     echo "${CSUCCESS}Apache installed successfully! ${CEND}"
     popd
+    rm -rf pcre-${pcre_ver}
+    rm -rf apr-${apr_ver}
+    rm -rf apr-util-${apr_util_ver}
     rm -rf httpd-${apache24_ver}
   else
     rm -rf ${apache_install_dir}
@@ -59,8 +62,8 @@ Install_Apache24() {
   sed -i '2a # chkconfig: - 85 15' /etc/init.d/httpd
   sed -i '3a # description: Apache is a World Wide Web server. It is used to serve' /etc/init.d/httpd
   chmod +x /etc/init.d/httpd
-  [ "$OS" == 'CentOS' ] && { chkconfig --add httpd; chkconfig httpd on; }
-  [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d httpd defaults
+  [ "${OS}" == 'CentOS' ] && { chkconfig --add httpd; chkconfig httpd on; }
+  [[ ${OS} =~ ^Ubuntu$|^Debian$ ]] && update-rc.d httpd defaults
 
   sed -i "s@^User daemon@User ${run_user}@" ${apache_install_dir}/conf/httpd.conf
   sed -i "s@^Group daemon@Group ${run_user}@" ${apache_install_dir}/conf/httpd.conf

+ 25 - 23
include/nginx.sh

@@ -13,10 +13,10 @@ Install_Nginx() {
   id -u ${run_user} >/dev/null 2>&1
   [ $? -ne 0 ] && useradd -M -s /sbin/nologin ${run_user}
 
-  tar xzf pcre-$pcre_ver.tar.gz
-  tar xzf nginx-$nginx_ver.tar.gz
-  tar xzf openssl-$openssl_ver.tar.gz
-  pushd nginx-$nginx_ver
+  tar xzf pcre-${pcre_ver}.tar.gz
+  tar xzf nginx-${nginx_ver}.tar.gz
+  tar xzf openssl-${openssl_ver}.tar.gz
+  pushd nginx-${nginx_ver}
   # Modify Nginx version
   #sed -i 's@#define NGINX_VERSION.*$@#define NGINX_VERSION      "1.2"@' src/core/nginx.h
   #sed -i 's@#define NGINX_VER.*NGINX_VERSION$@#define NGINX_VER          "Linuxeye/" NGINX_VERSION@' src/core/nginx.h
@@ -25,38 +25,40 @@ Install_Nginx() {
   # close debug
   sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc
 
-  [ ! -d "$nginx_install_dir" ] && mkdir -p $nginx_install_dir
-  ./configure --prefix=$nginx_install_dir --user=${run_user} --group=${run_user} --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=../openssl-$openssl_ver --with-pcre=../pcre-$pcre_ver --with-pcre-jit --with-ld-opt='-ljemalloc' $nginx_modules_options
+  [ ! -d "${nginx_install_dir}" ] && mkdir -p ${nginx_install_dir}
+  ./configure --prefix=${nginx_install_dir} --user=${run_user} --group=${run_user} --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=../openssl-${openssl_ver} --with-pcre=../pcre-${pcre_ver} --with-pcre-jit --with-ld-opt='-ljemalloc' ${nginx_modules_options}
   make -j ${THREAD} && make install
-  if [ -e "$nginx_install_dir/conf/nginx.conf" ]; then
+  if [ -e "${nginx_install_dir}/conf/nginx.conf" ]; then
     popd
-    rm -rf nginx-$nginx_ver
+    rm -rf pcre-${pcre_ver}
+    rm -rf openssl-${openssl_ver}
+    rm -rf nginx-${nginx_ver}
     echo "${CSUCCESS}Nginx installed successfully! ${CEND}"
   else
-    rm -rf $nginx_install_dir
+    rm -rf ${nginx_install_dir}
     echo "${CFAILURE}Nginx install failed, Please Contact the author! ${CEND}"
     kill -9 $$
   fi
 
-  [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$nginx_install_dir/sbin:\$PATH" >> /etc/profile
-  [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $nginx_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$nginx_install_dir/sbin:\1@" /etc/profile
+  [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${nginx_install_dir}/sbin:\$PATH" >> /etc/profile
+  [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${nginx_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${nginx_install_dir}/sbin:\1@" /etc/profile
   . /etc/profile
 
-  [ "$OS" == 'CentOS' ] && { /bin/cp ../init.d/Nginx-init-CentOS /etc/init.d/nginx; chkconfig --add nginx; chkconfig nginx on; }
-  [[ $OS =~ ^Ubuntu$|^Debian$ ]] && { /bin/cp ../init.d/Nginx-init-Ubuntu /etc/init.d/nginx; update-rc.d nginx defaults; }
+  [ "${OS}" == 'CentOS' ] && { /bin/cp ../init.d/Nginx-init-CentOS /etc/init.d/nginx; chkconfig --add nginx; chkconfig nginx on; }
+  [[ ${OS} =~ ^Ubuntu$|^Debian$ ]] && { /bin/cp ../init.d/Nginx-init-Ubuntu /etc/init.d/nginx; update-rc.d nginx defaults; }
 
-  sed -i "s@/usr/local/nginx@$nginx_install_dir@g" /etc/init.d/nginx
+  sed -i "s@/usr/local/nginx@${nginx_install_dir}@g" /etc/init.d/nginx
 
-  mv $nginx_install_dir/conf/nginx.conf{,_bk}
+  mv ${nginx_install_dir}/conf/nginx.conf{,_bk}
   if [[ ${apache_option} =~ ^[1-2]$ ]]; then
-    /bin/cp ../config/nginx_apache.conf $nginx_install_dir/conf/nginx.conf
+    /bin/cp ../config/nginx_apache.conf ${nginx_install_dir}/conf/nginx.conf
   elif [[ ${tomcat_option} =~ ^[1-2]$ ]] && [ ! -e "${php_install_dir}/bin/php" ]; then
-    /bin/cp ../config/nginx_tomcat.conf $nginx_install_dir/conf/nginx.conf
+    /bin/cp ../config/nginx_tomcat.conf ${nginx_install_dir}/conf/nginx.conf
   else
-    /bin/cp ../config/nginx.conf $nginx_install_dir/conf/nginx.conf
-    [ "$php_yn" == 'y' ] && [ -z "`grep '/php-fpm_status' $nginx_install_dir/conf/nginx.conf`" ] &&  sed -i "s@index index.html index.php;@index index.html index.php;\n    location ~ /php-fpm_status {\n        #fastcgi_pass remote_php_ip:9000;\n        fastcgi_pass unix:/dev/shm/php-cgi.sock;\n        fastcgi_index index.php;\n        include fastcgi.conf;\n        allow 127.0.0.1;\n        deny all;\n        }@" $nginx_install_dir/conf/nginx.conf
+    /bin/cp ../config/nginx.conf ${nginx_install_dir}/conf/nginx.conf
+    [ "${php_yn}" == 'y' ] && [ -z "`grep '/php-fpm_status' ${nginx_install_dir}/conf/nginx.conf`" ] &&  sed -i "s@index index.html index.php;@index index.html index.php;\n    location ~ /php-fpm_status {\n        #fastcgi_pass remote_php_ip:9000;\n        fastcgi_pass unix:/dev/shm/php-cgi.sock;\n        fastcgi_index index.php;\n        include fastcgi.conf;\n        allow 127.0.0.1;\n        deny all;\n        }@" ${nginx_install_dir}/conf/nginx.conf
   fi
-  cat > $nginx_install_dir/conf/proxy.conf << EOF
+  cat > ${nginx_install_dir}/conf/proxy.conf << EOF
 proxy_connect_timeout 300s;
 proxy_send_timeout 900;
 proxy_read_timeout 900;
@@ -73,9 +75,9 @@ proxy_set_header X-Real-IP \$remote_addr;
 proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
 proxy_set_header X-Forwarded-Proto \$scheme;
 EOF
-  sed -i "s@/data/wwwroot/default@${wwwroot_dir}/default@" $nginx_install_dir/conf/nginx.conf
-  sed -i "s@/data/wwwlogs@${wwwlogs_dir}@g" $nginx_install_dir/conf/nginx.conf
-  sed -i "s@^user www www@user ${run_user} ${run_user}@" $nginx_install_dir/conf/nginx.conf
+  sed -i "s@/data/wwwroot/default@${wwwroot_dir}/default@" ${nginx_install_dir}/conf/nginx.conf
+  sed -i "s@/data/wwwlogs@${wwwlogs_dir}@g" ${nginx_install_dir}/conf/nginx.conf
+  sed -i "s@^user www www@user ${run_user} ${run_user}@" ${nginx_install_dir}/conf/nginx.conf
 
   # logrotate nginx log
   cat > /etc/logrotate.d/nginx << EOF

+ 26 - 24
include/openresty.sh

@@ -13,47 +13,49 @@ Install_OpenResty() {
   id -u ${run_user} >/dev/null 2>&1
   [ $? -ne 0 ] && useradd -M -s /sbin/nologin ${run_user}
 
-  tar xzf pcre-$pcre_ver.tar.gz
-  tar xzf openresty-$openresty_ver.tar.gz
-  tar xzf openssl-$openssl_ver.tar.gz
-  pushd openresty-$openresty_ver
+  tar xzf pcre-${pcre_ver}.tar.gz
+  tar xzf openresty-${openresty_ver}.tar.gz
+  tar xzf openssl-${openssl_ver}.tar.gz
+  pushd openresty-${openresty_ver}
 
   # close debug
   openresty_ver_tmp=${openresty_ver%.*}
-  sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' bundle/nginx-$openresty_ver_tmp/auto/cc/gcc # close debug
+  sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' bundle/nginx-${openresty_ver_tmp}/auto/cc/gcc # close debug
 
-  [ ! -d "$openresty_install_dir" ] && mkdir -p $openresty_install_dir
-  ./configure --prefix=$openresty_install_dir --user=${run_user} --group=${run_user} --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=../openssl-$openssl_ver --with-pcre=../pcre-$pcre_ver --with-pcre-jit --with-ld-opt='-ljemalloc' $nginx_modules_options
+  [ ! -d "${openresty_install_dir}" ] && mkdir -p ${openresty_install_dir}
+  ./configure --prefix=${openresty_install_dir} --user=${run_user} --group=${run_user} --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=../openssl-${openssl_ver} --with-pcre=../pcre-${pcre_ver} --with-pcre-jit --with-ld-opt='-ljemalloc' ${nginx_modules_options}
   make -j ${THREAD} && make install
-  if [ -e "$openresty_install_dir/nginx/conf/nginx.conf" ]; then
+  if [ -e "${openresty_install_dir}/nginx/conf/nginx.conf" ]; then
     popd
-    rm -rf openresty-$openresty_ver
+    rm -rf pcre-${pcre_ver}
+    rm -rf openssl-${openssl_ver}
+    rm -rf openresty-${openresty_ver}
     echo "${CSUCCESS}OpenResty installed successfully! ${CEND}"
   else
-    rm -rf $openresty_install_dir
+    rm -rf ${openresty_install_dir}
     echo "${CFAILURE}OpenResty install failed, Please Contact the author! ${CEND}"
     kill -9 $$
   fi
 
-  [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$openresty_install_dir/nginx/sbin:\$PATH" >> /etc/profile
-  [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $openresty_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$openresty_install_dir/nginx/sbin:\1@" /etc/profile
+  [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${openresty_install_dir}/nginx/sbin:\$PATH" >> /etc/profile
+  [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${openresty_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${openresty_install_dir}/nginx/sbin:\1@" /etc/profile
   . /etc/profile
 
-  [ "$OS" == 'CentOS' ] && { /bin/cp ../init.d/Nginx-init-CentOS /etc/init.d/nginx; chkconfig --add nginx; chkconfig nginx on; }
-  [[ $OS =~ ^Ubuntu$|^Debian$ ]] && { /bin/cp ../init.d/Nginx-init-Ubuntu /etc/init.d/nginx; update-rc.d nginx defaults; }
+  [ "${OS}" == 'CentOS' ] && { /bin/cp ../init.d/Nginx-init-CentOS /etc/init.d/nginx; chkconfig --add nginx; chkconfig nginx on; }
+  [[ ${OS} =~ ^Ubuntu$|^Debian$ ]] && { /bin/cp ../init.d/Nginx-init-Ubuntu /etc/init.d/nginx; update-rc.d nginx defaults; }
 
-  sed -i "s@/usr/local/nginx@$openresty_install_dir/nginx@g" /etc/init.d/nginx
+  sed -i "s@/usr/local/nginx@${openresty_install_dir}/nginx@g" /etc/init.d/nginx
 
-  mv $openresty_install_dir/nginx/conf/nginx.conf{,_bk}
+  mv ${openresty_install_dir}/nginx/conf/nginx.conf{,_bk}
   if [[ ${apache_option} =~ ^[1-2]$ ]]; then
-    /bin/cp ../config/nginx_apache.conf $openresty_install_dir/nginx/conf/nginx.conf
+    /bin/cp ../config/nginx_apache.conf ${openresty_install_dir}/nginx/conf/nginx.conf
   elif [[ ${tomcat_option} =~ ^[1-2]$ ]] && [ ! -e "${php_install_dir}/bin/php" ]; then
-    /bin/cp ../config/nginx_tomcat.conf $openresty_install_dir/nginx/conf/nginx.conf
+    /bin/cp ../config/nginx_tomcat.conf ${openresty_install_dir}/nginx/conf/nginx.conf
   else
-    /bin/cp ../config/nginx.conf $openresty_install_dir/nginx/conf/nginx.conf
-    [ "$php_yn" == 'y' ] && [ -z "`grep '/php-fpm_status' $openresty_install_dir/nginx/conf/nginx.conf`" ] &&  sed -i "s@index index.html index.php;@index index.html index.php;\n    location ~ /php-fpm_status {\n        #fastcgi_pass remote_php_ip:9000;\n        fastcgi_pass unix:/dev/shm/php-cgi.sock;\n        fastcgi_index index.php;\n        include fastcgi.conf;\n        allow 127.0.0.1;\n        deny all;\n        }@" $openresty_install_dir/nginx/conf/nginx.conf
+    /bin/cp ../config/nginx.conf ${openresty_install_dir}/nginx/conf/nginx.conf
+    [ "${php_yn}" == 'y' ] && [ -z "`grep '/php-fpm_status' ${openresty_install_dir}/nginx/conf/nginx.conf`" ] &&  sed -i "s@index index.html index.php;@index index.html index.php;\n    location ~ /php-fpm_status {\n        #fastcgi_pass remote_php_ip:9000;\n        fastcgi_pass unix:/dev/shm/php-cgi.sock;\n        fastcgi_index index.php;\n        include fastcgi.conf;\n        allow 127.0.0.1;\n        deny all;\n        }@" ${openresty_install_dir}/nginx/conf/nginx.conf
   fi
-  cat > $openresty_install_dir/nginx/conf/proxy.conf << EOF
+  cat > ${openresty_install_dir}/nginx/conf/proxy.conf << EOF
 proxy_connect_timeout 300s;
 proxy_send_timeout 900;
 proxy_read_timeout 900;
@@ -70,9 +72,9 @@ proxy_set_header X-Real-IP \$remote_addr;
 proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
 proxy_set_header X-Forwarded-Proto \$scheme;
 EOF
-  sed -i "s@/data/wwwroot/default@${wwwroot_dir}/default@" $openresty_install_dir/nginx/conf/nginx.conf
-  sed -i "s@/data/wwwlogs@${wwwlogs_dir}@g" $openresty_install_dir/nginx/conf/nginx.conf
-  sed -i "s@^user www www@user ${run_user} ${run_user}@" $openresty_install_dir/nginx/conf/nginx.conf
+  sed -i "s@/data/wwwroot/default@${wwwroot_dir}/default@" ${openresty_install_dir}/nginx/conf/nginx.conf
+  sed -i "s@/data/wwwlogs@${wwwlogs_dir}@g" ${openresty_install_dir}/nginx/conf/nginx.conf
+  sed -i "s@^user www www@user ${run_user} ${run_user}@" ${openresty_install_dir}/nginx/conf/nginx.conf
 
   # logrotate nginx log
   cat > /etc/logrotate.d/nginx << EOF

+ 27 - 25
include/tengine.sh

@@ -13,48 +13,50 @@ Install_Tengine() {
   id -u ${run_user} >/dev/null 2>&1
   [ $? -ne 0 ] && useradd -M -s /sbin/nologin ${run_user}
 
-  tar xzf pcre-$pcre_ver.tar.gz
-  tar xzf tengine-$tengine_ver.tar.gz
-  tar xzf openssl-$openssl_ver.tar.gz
-  pushd tengine-$tengine_ver
+  tar xzf pcre-${pcre_ver}.tar.gz
+  tar xzf tengine-${tengine_ver}.tar.gz
+  tar xzf openssl-${openssl_ver}.tar.gz
+  pushd tengine-${tengine_ver}
   # Modify Tengine version
   #sed -i 's@TENGINE "/" TENGINE_VERSION@"Tengine/unknown"@' src/core/nginx.h
 
   # close debug
   sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc
 
-  [ ! -d "$tengine_install_dir" ] && mkdir -p $tengine_install_dir
-  ./configure --prefix=$tengine_install_dir --user=${run_user} --group=${run_user} --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-http_concat_module=shared --with-http_sysguard_module=shared --with-openssl=../openssl-$openssl_ver --with-pcre=../pcre-$pcre_ver --with-pcre-jit --with-jemalloc $nginx_modules_options
+  [ ! -d "${tengine_install_dir}" ] && mkdir -p ${tengine_install_dir}
+  ./configure --prefix=${tengine_install_dir} --user=${run_user} --group=${run_user} --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-http_concat_module=shared --with-http_sysguard_module=shared --with-openssl=../openssl-${openssl_ver} --with-pcre=../pcre-${pcre_ver} --with-pcre-jit --with-jemalloc ${nginx_modules_options}
   make -j ${THREAD} && make install
-  if [ -e "$tengine_install_dir/conf/nginx.conf" ]; then
+  if [ -e "${tengine_install_dir}/conf/nginx.conf" ]; then
     popd
-    rm -rf tengine-$tengine_ver
+    rm -rf pcre-${pcre_ver}
+    rm -rf openssl-${openssl_ver}
+    rm -rf tengine-${tengine_ver}
     echo "${CSUCCESS}Tengine installed successfully! ${CEND}"
   else
-    rm -rf $tengine_install_dir
+    rm -rf ${tengine_install_dir}
     echo "${CFAILURE}Tengine install failed, Please Contact the author! ${CEND}"
     kill -9 $$
   fi
 
-  [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$tengine_install_dir/sbin:\$PATH" >> /etc/profile
-  [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $tengine_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$tengine_install_dir/sbin:\1@" /etc/profile
+  [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${tengine_install_dir}/sbin:\$PATH" >> /etc/profile
+  [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${tengine_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${tengine_install_dir}/sbin:\1@" /etc/profile
   . /etc/profile
 
-  [ "$OS" == 'CentOS' ] && { /bin/cp ../init.d/Nginx-init-CentOS /etc/init.d/nginx; chkconfig --add nginx; chkconfig nginx on; }
-  [[ $OS =~ ^Ubuntu$|^Debian$ ]] && { /bin/cp ../init.d/Nginx-init-Ubuntu /etc/init.d/nginx; update-rc.d nginx defaults; }
+  [ "${OS}" == 'CentOS' ] && { /bin/cp ../init.d/Nginx-init-CentOS /etc/init.d/nginx; chkconfig --add nginx; chkconfig nginx on; }
+  [[ ${OS} =~ ^Ubuntu$|^Debian$ ]] && { /bin/cp ../init.d/Nginx-init-Ubuntu /etc/init.d/nginx; update-rc.d nginx defaults; }
 
-  sed -i "s@/usr/local/nginx@$tengine_install_dir@g" /etc/init.d/nginx
+  sed -i "s@/usr/local/nginx@${tengine_install_dir}@g" /etc/init.d/nginx
 
-  mv $tengine_install_dir/conf/nginx.conf{,_bk}
+  mv ${tengine_install_dir}/conf/nginx.conf{,_bk}
   if [[ ${apache_option} =~ ^[1-2]$ ]]; then
-    /bin/cp ../config/nginx_apache.conf $tengine_install_dir/conf/nginx.conf
+    /bin/cp ../config/nginx_apache.conf ${tengine_install_dir}/conf/nginx.conf
   elif [[ ${tomcat_option} =~ ^[1-2]$ ]] && [ ! -e "${php_install_dir}/bin/php" ]; then
-    /bin/cp ../config/nginx_tomcat.conf $tengine_install_dir/conf/nginx.conf
+    /bin/cp ../config/nginx_tomcat.conf ${tengine_install_dir}/conf/nginx.conf
   else
-    /bin/cp ../config/nginx.conf $tengine_install_dir/conf/nginx.conf
-    [ "$php_yn" == 'y' ] && [ -z "`grep '/php-fpm_status' $tengine_install_dir/conf/nginx.conf`" ] &&  sed -i "s@index index.html index.php;@index index.html index.php;\n    location ~ /php-fpm_status {\n        #fastcgi_pass remote_php_ip:9000;\n        fastcgi_pass unix:/dev/shm/php-cgi.sock;\n        fastcgi_index index.php;\n        include fastcgi.conf;\n        allow 127.0.0.1;\n        deny all;\n        }@" $tengine_install_dir/conf/nginx.conf
+    /bin/cp ../config/nginx.conf ${tengine_install_dir}/conf/nginx.conf
+    [ "${php_yn}" == 'y' ] && [ -z "`grep '/php-fpm_status' ${tengine_install_dir}/conf/nginx.conf`" ] &&  sed -i "s@index index.html index.php;@index index.html index.php;\n    location ~ /php-fpm_status {\n        #fastcgi_pass remote_php_ip:9000;\n        fastcgi_pass unix:/dev/shm/php-cgi.sock;\n        fastcgi_index index.php;\n        include fastcgi.conf;\n        allow 127.0.0.1;\n        deny all;\n        }@" ${tengine_install_dir}/conf/nginx.conf
   fi
-  cat > $tengine_install_dir/conf/proxy.conf << EOF
+  cat > ${tengine_install_dir}/conf/proxy.conf << EOF
 proxy_connect_timeout 300s;
 proxy_send_timeout 900;
 proxy_read_timeout 900;
@@ -71,13 +73,13 @@ proxy_set_header X-Real-IP \$remote_addr;
 proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
 proxy_set_header X-Forwarded-Proto \$scheme;
 EOF
-  sed -i "s@/data/wwwroot/default@${wwwroot_dir}/default@" $tengine_install_dir/conf/nginx.conf
-  sed -i "s@/data/wwwlogs@${wwwlogs_dir}@g" $tengine_install_dir/conf/nginx.conf
-  sed -i "s@^user www www@user ${run_user} ${run_user}@" $tengine_install_dir/conf/nginx.conf
-  uname -r | awk -F'.' '{if ($1$2>=39)S=0;else S=1}{exit S}' && [ -z "`grep 'reuse_port on;' $tengine_install_dir/conf/nginx.conf`" ] && sed -i "s@worker_connections 51200;@worker_connections 51200;\n    reuse_port on;@" $tengine_install_dir/conf/nginx.conf
+  sed -i "s@/data/wwwroot/default@${wwwroot_dir}/default@" ${tengine_install_dir}/conf/nginx.conf
+  sed -i "s@/data/wwwlogs@${wwwlogs_dir}@g" ${tengine_install_dir}/conf/nginx.conf
+  sed -i "s@^user www www@user ${run_user} ${run_user}@" ${tengine_install_dir}/conf/nginx.conf
+  uname -r | awk -F'.' '{if ($1$2>=39)S=0;else S=1}{exit S}' && [ -z "`grep 'reuse_port on;' ${tengine_install_dir}/conf/nginx.conf`" ] && sed -i "s@worker_connections 51200;@worker_connections 51200;\n    reuse_port on;@" ${tengine_install_dir}/conf/nginx.conf
 
   # worker_cpu_affinity
-  sed -i "s@^worker_processes.*@worker_processes auto;\nworker_cpu_affinity auto;\ndso {\n\tload ngx_http_concat_module.so;\n\tload ngx_http_sysguard_module.so;\n}@" $tengine_install_dir/conf/nginx.conf
+  sed -i "s@^worker_processes.*@worker_processes auto;\nworker_cpu_affinity auto;\ndso {\n\tload ngx_http_concat_module.so;\n\tload ngx_http_sysguard_module.so;\n}@" ${tengine_install_dir}/conf/nginx.conf
 
   # logrotate nginx log
   cat > /etc/logrotate.d/nginx << EOF