Browse Source

Update apps.conf and Add Apache status

lj2007331 9 years ago
parent
commit
86d81a95c2

+ 8 - 8
README.md

@@ -1,14 +1,14 @@
-This script is written using the shell, in order to quickly deploy `LEMP`/`LAMP`/`LNMP`/`LNMPA`/`LTMP`(Linux, Nginx/Tengine, MySQL in a production environment/MariaDB/Percona, PHP, JAVA), applicable to CentOS 5~7(including redhat), Debian 6~8, Ubuntu 12~15 of 32 and 64.
+This script is written using the shell, in order to quickly deploy `LEMP`/`LAMP`/`LNMP`/`LNMPA`/`LTMP`(Linux, Nginx/Tengine/OpenResty, MySQL in a production environment/MariaDB/Percona, PHP, JAVA), applicable to CentOS 5~7(including redhat), Debian 6~8, Ubuntu 12~15 of 32 and 64.
 
 
 Script properties:
 Script properties:
 - Continually updated
 - Continually updated
 - Source compiler installation, most stable source is the latest version, and download from the official site
 - Source compiler installation, most stable source is the latest version, and download from the official site
 - Some security optimization
 - Some security optimization
 - Providing a plurality of database versions (MySQL-5.7, MySQL-5.6, MySQL-5.5, MariaDB-10.1, MariaDB-10.0, MariaDB-5.5, Percona-5.7, Percona-5.6, Percona-5.5)
 - Providing a plurality of database versions (MySQL-5.7, MySQL-5.6, MySQL-5.5, MariaDB-10.1, MariaDB-10.0, MariaDB-5.5, Percona-5.7, Percona-5.6, Percona-5.5)
-- Providing multiple PHP versions (php-5.3, php-5.4, php-5.5, php-5.6, php-7)
-- Provide Nginx, Tengine
+- Providing multiple PHP versions (php-7, php-5.6, php-5.5, php-5.4, php-5.3)
+- Provide Nginx, Tengine, OpenResty
 - Providing a plurality of Tomcat version (Tomcat-8, Tomcat-7)
 - Providing a plurality of Tomcat version (Tomcat-8, Tomcat-7)
-- Providing a plurality of JDK version (JDK-1.6, JDK-1.7, JDK-1.8)
+- Providing a plurality of JDK version (JDK-1.8, JDK-1.7, JDK-1.6)
 - Providing a plurality of Apache version (Apache-2.4, Apache-2.2)
 - Providing a plurality of Apache version (Apache-2.4, Apache-2.2)
 - According to their needs to install PHP Cache Accelerator provides ZendOPcache, xcache, apcu, eAccelerator. And php encryption and decryption tool ionCube, ZendGuardLoader
 - According to their needs to install PHP Cache Accelerator provides ZendOPcache, xcache, apcu, eAccelerator. And php encryption and decryption tool ionCube, ZendGuardLoader
 - Installation Pureftpd, phpMyAdmin according to their needs
 - Installation Pureftpd, phpMyAdmin according to their needs
@@ -22,16 +22,16 @@ Script properties:
 ## How to use 
 ## How to use 
 If your server system: CentOS/Redhat (Do not enter "//" and "// subsequent sentence)
 If your server system: CentOS/Redhat (Do not enter "//" and "// subsequent sentence)
 ```bash
 ```bash
-yum -y install wget screen   // for CentOS / Redhat
+yum -y install wget screen python   // for CentOS / Redhat
 wget http://mirrors.linuxeye.com/oneinstack-full.tar.gz   // Contains the source code
 wget http://mirrors.linuxeye.com/oneinstack-full.tar.gz   // Contains the source code
 tar xzf oneinstack-full.tar.gz
 tar xzf oneinstack-full.tar.gz
-cd oneinstack    // If you need to modify the directory (installation, data storage, Nginx logs), modify options.conf file
+cd oneinstack   // If you need to modify the directory (installation, data storage, Nginx logs), modify options.conf file
 screen -S oneinstack    // If network interruption, you can execute the command `screen -r oneinstack` reconnect install window
 screen -S oneinstack    // If network interruption, you can execute the command `screen -r oneinstack` reconnect install window
 ./install.sh   // Do not sh install.sh or bash install.sh such execution
 ./install.sh   // Do not sh install.sh or bash install.sh such execution
 ```
 ```
 If your server system: Debian/Ubuntu (Do not enter "//" and "// subsequent sentence)
 If your server system: Debian/Ubuntu (Do not enter "//" and "// subsequent sentence)
 ```bash
 ```bash
-apt-get -y install wget screen    // for Debian / Ubuntu
+apt-get -y install wget screen python    // for Debian / Ubuntu
 wget http://mirrors.linuxeye.com/oneinstack-full.tar.gz   // Contains the source code
 wget http://mirrors.linuxeye.com/oneinstack-full.tar.gz   // Contains the source code
 tar xzf oneinstack-full.tar.gz
 tar xzf oneinstack-full.tar.gz
 cd oneinstack    // If you need to modify the directory (installation, data storage, Nginx logs), modify options.conf file
 cd oneinstack    // If you need to modify the directory (installation, data storage, Nginx logs), modify options.conf file
@@ -71,7 +71,7 @@ crontab -l    // Can be added to scheduled tasks, such as automatic backups ever
 ```
 ```
 
 
 ## How to manage service
 ## How to manage service
-Nginx/Tengine:
+Nginx/Tengine/OpenResty:
 ```bash
 ```bash
 service nginx {start|stop|status|restart|reload|configtest}
 service nginx {start|stop|status|restart|reload|configtest}
 ```
 ```

+ 2 - 1
apps.conf

@@ -2,12 +2,13 @@
 # Web
 # Web
 nginx_version=1.9.14
 nginx_version=1.9.14
 tengine_version=2.1.1
 tengine_version=2.1.1
+openresty_version=1.9.7.4
 
 
 tomcat_7_version=7.0.68
 tomcat_7_version=7.0.68
 tomcat_8_version=8.0.30
 tomcat_8_version=8.0.30
 
 
 apache_2_version=2.2.31
 apache_2_version=2.2.31
-apache_4_version=2.4.18
+apache_4_version=2.4.20
 pcre_version=8.38
 pcre_version=8.38
 apr_version=1.5.2
 apr_version=1.5.2
 apr_util_version=1.5.4
 apr_util_version=1.5.4

+ 9 - 3
include/apache-2.2.sh

@@ -44,11 +44,11 @@ chmod +x /etc/init.d/httpd
 
 
 sed -i "s@^User daemon@User $run_user@" $apache_install_dir/conf/httpd.conf
 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
 sed -i "s@^Group daemon@Group $run_user@" $apache_install_dir/conf/httpd.conf
-if [ "$Nginx_version" == '3' -a ! -e "$web_install_dir/sbin/nginx" ];then
+if [ "$Nginx_version" == '4' -a ! -e "$web_install_dir/sbin/nginx" ];then
     sed -i 's/^#ServerName www.example.com:80/ServerName 0.0.0.0:80/' $apache_install_dir/conf/httpd.conf
     sed -i 's/^#ServerName www.example.com:80/ServerName 0.0.0.0:80/' $apache_install_dir/conf/httpd.conf
     TMP_PORT=80
     TMP_PORT=80
     TMP_IP=$IPADDR
     TMP_IP=$IPADDR
-elif [ "$Nginx_version" == '1' -o "$Nginx_version" == '2' -o -e "$web_install_dir/sbin/nginx" ];then
+elif [[ $Nginx_version =~ ^[1-3]$ ]] || [ -e "$web_install_dir/sbin/nginx" ];then 
     sed -i 's/^#ServerName www.example.com:80/ServerName 127.0.0.1:88/' $apache_install_dir/conf/httpd.conf
     sed -i 's/^#ServerName www.example.com:80/ServerName 127.0.0.1:88/' $apache_install_dir/conf/httpd.conf
     sed -i 's@^Listen.*@Listen 127.0.0.1:88@' $apache_install_dir/conf/httpd.conf
     sed -i 's@^Listen.*@Listen 127.0.0.1:88@' $apache_install_dir/conf/httpd.conf
     TMP_PORT=88
     TMP_PORT=88
@@ -96,6 +96,12 @@ NameVirtualHost *:$TMP_PORT
     Allow from all
     Allow from all
     DirectoryIndex index.html index.php
     DirectoryIndex index.html index.php
 </Directory>
 </Directory>
+<Location /server-status>
+    SetHandler server-status
+    Order Deny,Allow
+    Deny from all
+    Allow from 127.0.0.1 
+</Location>
 </VirtualHost>
 </VirtualHost>
 EOF
 EOF
 
 
@@ -115,7 +121,7 @@ ServerSignature Off
 Include conf/vhost/*.conf
 Include conf/vhost/*.conf
 EOF
 EOF
 
 
-if [ "$Nginx_version" != '3' -o -e "$web_install_dir/sbin/nginx" ];then
+if [ "$Nginx_version" != '4' -o -e "$web_install_dir/sbin/nginx" ];then
     src_url=http://mirrors.linuxeye.com/oneinstack/src/mod_remoteip.c && Download_src
     src_url=http://mirrors.linuxeye.com/oneinstack/src/mod_remoteip.c && Download_src
     $apache_install_dir/bin/apxs -i -c -n mod_remoteip.so mod_remoteip.c
     $apache_install_dir/bin/apxs -i -c -n mod_remoteip.so mod_remoteip.c
     cat > $apache_install_dir/conf/extra/httpd-remoteip.conf << EOF
     cat > $apache_install_dir/conf/extra/httpd-remoteip.conf << EOF

+ 9 - 3
include/apache-2.4.sh

@@ -57,11 +57,11 @@ chmod +x /etc/init.d/httpd
 
 
 sed -i "s@^User daemon@User $run_user@" $apache_install_dir/conf/httpd.conf
 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
 sed -i "s@^Group daemon@Group $run_user@" $apache_install_dir/conf/httpd.conf
-if [ "$Nginx_version" == '3' -a ! -e "$web_install_dir/sbin/nginx" ];then
+if [ "$Nginx_version" == '4' -a ! -e "$web_install_dir/sbin/nginx" ];then
     sed -i 's/^#ServerName www.example.com:80/ServerName 0.0.0.0:80/' $apache_install_dir/conf/httpd.conf
     sed -i 's/^#ServerName www.example.com:80/ServerName 0.0.0.0:80/' $apache_install_dir/conf/httpd.conf
     TMP_PORT=80
     TMP_PORT=80
     TMP_IP=$IPADDR
     TMP_IP=$IPADDR
-elif [ "$Nginx_version" == '1' -o "$Nginx_version" == '2' -o -e "$web_install_dir/sbin/nginx" ];then
+elif [[ $Nginx_version =~ ^[1-3]$ ]] || [ -e "$web_install_dir/sbin/nginx" ];then 
     sed -i 's/^#ServerName www.example.com:80/ServerName 127.0.0.1:88/' $apache_install_dir/conf/httpd.conf
     sed -i 's/^#ServerName www.example.com:80/ServerName 127.0.0.1:88/' $apache_install_dir/conf/httpd.conf
     sed -i 's@^Listen.*@Listen 127.0.0.1:88@' $apache_install_dir/conf/httpd.conf
     sed -i 's@^Listen.*@Listen 127.0.0.1:88@' $apache_install_dir/conf/httpd.conf
     TMP_PORT=88
     TMP_PORT=88
@@ -109,6 +109,12 @@ cat >> $apache_install_dir/conf/vhost/0.conf << EOF
     Allow from all
     Allow from all
     DirectoryIndex index.html index.php
     DirectoryIndex index.html index.php
 </Directory>
 </Directory>
+<Location /server-status>
+    SetHandler server-status
+    Order Deny,Allow
+    Deny from all
+    Allow from 127.0.0.1 
+</Location>
 </VirtualHost>
 </VirtualHost>
 EOF
 EOF
 
 
@@ -128,7 +134,7 @@ ServerSignature Off
 Include conf/vhost/*.conf
 Include conf/vhost/*.conf
 EOF
 EOF
 
 
-if [ "$Nginx_version" != '3' -o -e "$web_install_dir/sbin/nginx" ];then
+if [ "$Nginx_version" != '4' -o -e "$web_install_dir/sbin/nginx" ];then
     cat > $apache_install_dir/conf/extra/httpd-remoteip.conf << EOF
     cat > $apache_install_dir/conf/extra/httpd-remoteip.conf << EOF
 LoadModule remoteip_module modules/mod_remoteip.so
 LoadModule remoteip_module modules/mod_remoteip.so
 RemoteIPHeader X-Forwarded-For
 RemoteIPHeader X-Forwarded-For

+ 1 - 0
include/check_web.sh

@@ -10,3 +10,4 @@
 
 
 [ -e "$nginx_install_dir/sbin/nginx" ] && web_install_dir=$nginx_install_dir
 [ -e "$nginx_install_dir/sbin/nginx" ] && web_install_dir=$nginx_install_dir
 [ -e "$tengine_install_dir/sbin/nginx" ] && web_install_dir=$tengine_install_dir
 [ -e "$tengine_install_dir/sbin/nginx" ] && web_install_dir=$tengine_install_dir
+[ -e "$openresty_install_dir/nginx/sbin/nginx" ] && web_install_dir=$openresty_install_dir/nginx

+ 1 - 0
include/demo.sh

@@ -39,5 +39,6 @@ if [ -e "$php_install_dir/bin/php" ];then
     fi
     fi
 fi
 fi
 chown -R ${run_user}.$run_user $wwwroot_dir/default
 chown -R ${run_user}.$run_user $wwwroot_dir/default
+[ -e /usr/bin/systemctl ] && systemctl daemon-reload
 cd ..
 cd ..
 }
 }

+ 4 - 3
include/init_CentOS.sh

@@ -96,6 +96,7 @@ ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
 sed -i 's/net.ipv4.tcp_syncookies.*$/net.ipv4.tcp_syncookies = 1/g' /etc/sysctl.conf
 sed -i 's/net.ipv4.tcp_syncookies.*$/net.ipv4.tcp_syncookies = 1/g' /etc/sysctl.conf
 [ -z "`cat /etc/sysctl.conf | grep 'fs.file-max'`" ] && cat >> /etc/sysctl.conf << EOF
 [ -z "`cat /etc/sysctl.conf | grep 'fs.file-max'`" ] && cat >> /etc/sysctl.conf << EOF
 fs.file-max=65535
 fs.file-max=65535
+fs.inotify.max_user_instances = 1024
 net.ipv4.tcp_fin_timeout = 30 
 net.ipv4.tcp_fin_timeout = 30 
 net.ipv4.tcp_tw_reuse = 1
 net.ipv4.tcp_tw_reuse = 1
 net.ipv4.tcp_tw_recycle = 1
 net.ipv4.tcp_tw_recycle = 1
@@ -179,15 +180,15 @@ service sshd restart
 if [ ! -e "`which tmux`" ];then
 if [ ! -e "`which tmux`" ];then
     cd src
     cd src
     src_url=http://mirrors.linuxeye.com/oneinstack/src/libevent-2.0.22-stable.tar.gz && Download_src 
     src_url=http://mirrors.linuxeye.com/oneinstack/src/libevent-2.0.22-stable.tar.gz && Download_src 
-    src_url=http://mirrors.linuxeye.com/oneinstack/src/tmux-2.1.tar.gz && Download_src 
+    src_url=http://mirrors.linuxeye.com/oneinstack/src/tmux-2.2.tar.gz && Download_src 
     tar xzf libevent-2.0.22-stable.tar.gz
     tar xzf libevent-2.0.22-stable.tar.gz
     cd libevent-2.0.22-stable
     cd libevent-2.0.22-stable
     ./configure
     ./configure
     make && make install
     make && make install
     cd ..
     cd ..
 
 
-    tar xzf tmux-2.1.tar.gz
-    cd tmux-2.1
+    tar xzf tmux-2.2.tar.gz
+    cd tmux-2.2
     CFLAGS="-I/usr/local/include" LDFLAGS="-L//usr/local/lib" ./configure
     CFLAGS="-I/usr/local/include" LDFLAGS="-L//usr/local/lib" ./configure
     make && make install
     make && make install
     cd ../../
     cd ../../

+ 1 - 0
include/init_Debian.sh

@@ -66,6 +66,7 @@ sed -i 's@^# alias@alias@g' ~/.bashrc
 # /etc/sysctl.conf
 # /etc/sysctl.conf
 [ -z "`cat /etc/sysctl.conf | grep 'fs.file-max'`" ] && cat >> /etc/sysctl.conf << EOF
 [ -z "`cat /etc/sysctl.conf | grep 'fs.file-max'`" ] && cat >> /etc/sysctl.conf << EOF
 fs.file-max=65535
 fs.file-max=65535
+fs.inotify.max_user_instances = 1024
 net.ipv4.tcp_syncookies = 1
 net.ipv4.tcp_syncookies = 1
 net.ipv4.tcp_fin_timeout = 30
 net.ipv4.tcp_fin_timeout = 30
 net.ipv4.tcp_tw_reuse = 1
 net.ipv4.tcp_tw_reuse = 1

+ 1 - 0
include/init_Ubuntu.sh

@@ -85,6 +85,7 @@ ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
 # /etc/sysctl.conf
 # /etc/sysctl.conf
 [ -z "`cat /etc/sysctl.conf | grep 'fs.file-max'`" ] && cat >> /etc/sysctl.conf << EOF
 [ -z "`cat /etc/sysctl.conf | grep 'fs.file-max'`" ] && cat >> /etc/sysctl.conf << EOF
 fs.file-max=65535
 fs.file-max=65535
+fs.inotify.max_user_instances = 1024
 net.ipv4.tcp_syncookies = 1
 net.ipv4.tcp_syncookies = 1
 net.ipv4.tcp_fin_timeout = 30 
 net.ipv4.tcp_fin_timeout = 30 
 net.ipv4.tcp_tw_reuse = 1
 net.ipv4.tcp_tw_reuse = 1

+ 111 - 0
include/openresty.sh

@@ -0,0 +1,111 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.com
+#
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       http://oneinstack.com
+#       https://github.com/lj2007331/oneinstack
+
+Install_OpenResty() {
+cd $oneinstack_dir/src
+src_url=http://mirrors.linuxeye.com/oneinstack/src/pcre-$pcre_version.tar.gz && Download_src
+src_url=https://openresty.org/download/openresty-$openresty_version.tar.gz && Download_src
+
+tar xzf pcre-$pcre_version.tar.gz
+cd pcre-$pcre_version
+./configure
+make && make install
+cd ..
+
+id -u $run_user >/dev/null 2>&1
+[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user 
+
+tar xzf openresty-$openresty_version.tar.gz
+cd openresty-$openresty_version
+
+# close debug
+openresty_version_tmp=${openresty_version%.*}
+sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' bundle/nginx-$openresty_version_tmp/auto/cc/gcc # close debug
+
+if [ "$je_tc_malloc" == '1' ];then
+    malloc_module="--with-ld-opt='-ljemalloc'"
+elif [ "$je_tc_malloc" == '2' ];then
+    malloc_module='--with-google_perftools_module'
+    mkdir /tmp/tcmalloc
+    chown -R ${run_user}.$run_user /tmp/tcmalloc
+fi
+
+[ ! -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-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module $malloc_module
+make && make install
+if [ -e "$openresty_install_dir/nginx/conf/nginx.conf" ];then
+    cd ..
+    rm -rf openresty-$openresty_version
+    echo "${CSUCCESS}OpenResty install successfully! ${CEND}"
+else
+    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
+. /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; }
+cd ..
+
+sed -i "s@/usr/local/nginx@$openresty_install_dir/nginx@g" /etc/init.d/nginx
+
+mv $openresty_install_dir/nginx/conf/nginx.conf{,_bk}
+if [[ $Apache_version =~ ^[1-2]$ ]];then
+    /bin/cp config/nginx_apache.conf $openresty_install_dir/nginx/conf/nginx.conf
+elif [[ $Tomcat_version =~ ^[1-2]$ ]] && [ ! -e "$php_install_dir/bin/php" ];then
+    /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
+fi
+cat > $openresty_install_dir/nginx/conf/proxy.conf << EOF
+proxy_connect_timeout 300s;
+proxy_send_timeout 900;
+proxy_read_timeout 900;
+proxy_buffer_size 32k;
+proxy_buffers 4 64k;
+proxy_busy_buffers_size 128k;
+proxy_redirect off;
+proxy_hide_header Vary;
+proxy_set_header Accept-Encoding '';
+proxy_set_header Referer \$http_referer;
+proxy_set_header Cookie \$http_cookie;
+proxy_set_header Host \$host;
+proxy_set_header X-Real-IP \$remote_addr;
+proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
+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
+[ "$je_tc_malloc" == '2' ] && sed -i 's@^pid\(.*\)@pid\1\ngoogle_perftools_profiles /tmp/tcmalloc;@' $openresty_install_dir/nginx/conf/nginx.conf 
+
+# logrotate nginx log
+cat > /etc/logrotate.d/nginx << EOF
+$wwwlogs_dir/*nginx.log {
+daily
+rotate 5
+missingok
+dateext
+compress
+notifempty
+sharedscripts
+postrotate
+    [ -e /var/run/nginx.pid ] && kill -USR1 \`cat /var/run/nginx.pid\`
+endscript
+}
+EOF
+
+ldconfig
+service nginx start
+}

+ 57 - 0
include/upgrade_web.sh

@@ -49,6 +49,7 @@ if [ -e "nginx-$NEW_Nginx_version.tar.gz" ];then
         /bin/mv $nginx_install_dir/sbin/nginx $nginx_install_dir/sbin/nginx$(date +%m%d)
         /bin/mv $nginx_install_dir/sbin/nginx $nginx_install_dir/sbin/nginx$(date +%m%d)
         /bin/cp objs/nginx $nginx_install_dir/sbin/nginx
         /bin/cp objs/nginx $nginx_install_dir/sbin/nginx
         kill -USR2 `cat /var/run/nginx.pid`
         kill -USR2 `cat /var/run/nginx.pid`
+        sleep 1
         kill -QUIT `cat /var/run/nginx.pid.oldbin`
         kill -QUIT `cat /var/run/nginx.pid.oldbin`
         echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_Nginx_version${CEND} to ${CWARNING}$NEW_Nginx_version${CEND}"
         echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_Nginx_version${CEND} to ${CWARNING}$NEW_Nginx_version${CEND}"
     else
     else
@@ -105,6 +106,7 @@ if [ -e "tengine-$NEW_Tengine_version.tar.gz" ];then
         chmod +x $tengine_install_dir/sbin/*
         chmod +x $tengine_install_dir/sbin/*
         make install
         make install
         kill -USR2 `cat /var/run/nginx.pid`
         kill -USR2 `cat /var/run/nginx.pid`
+        sleep 1
         kill -QUIT `cat /var/run/nginx.pid.oldbin`
         kill -QUIT `cat /var/run/nginx.pid.oldbin`
         echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_Tengine_version${CEND} to ${CWARNING}$NEW_Tengine_version${CEND}"
         echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_Tengine_version${CEND} to ${CWARNING}$NEW_Tengine_version${CEND}"
     else
     else
@@ -114,3 +116,58 @@ if [ -e "tengine-$NEW_Tengine_version.tar.gz" ];then
 fi
 fi
 cd ..
 cd ..
 }
 }
+
+Upgrade_OpenResty() {
+cd $oneinstack_dir/src
+[ ! -e "$openresty_install_dir/nginx/sbin/nginx" ] && echo "${CWARNING}The OpenResty is not installed on your system! ${CEND}" && exit 1
+OLD_OpenResty_version_tmp=`$openresty_install_dir/nginx/sbin/nginx -v 2>&1`
+OLD_OpenResty_version="`echo ${OLD_OpenResty_version_tmp#*/} | awk '{print $1}'`"
+echo
+echo "Current OpenResty Version: ${CMSG}$OLD_OpenResty_version${CEND}"
+while :
+do
+    echo
+    read -p "Please input upgrade OpenResty Version(example: 1.9.7.19): " NEW_OpenResty_version
+    if [ "$NEW_OpenResty_version" != "$OLD_OpenResty_version" ];then
+        [ ! -e "openresty-$NEW_OpenResty_version.tar.gz" ] && wget --no-check-certificate -c https://openresty.org/download/openresty-$NEW_OpenResty_version.tar.gz > /dev/null 2>&1
+        if [ -e "openresty-$NEW_OpenResty_version.tar.gz" ];then
+            echo "Download [${CMSG}openresty-$NEW_OpenResty_version.tar.gz${CEND}] successfully! "
+            break
+        else
+            echo "${CWARNING}OpenResty version does not exist! ${CEND}"
+        fi
+    else
+        echo "${CWARNING}input error! The upgrade OpenResty version is the same as the old version${CEND}"
+    fi
+done
+
+if [ -e "openresty-$NEW_OpenResty_version.tar.gz" ];then
+    echo "[${CMSG}openresty-$NEW_OpenResty_version.tar.gz${CEND}] found"
+    echo "Press Ctrl+c to cancel or Press any key to continue..."
+    char=`get_char`
+    tar xzf openresty-$NEW_OpenResty_version.tar.gz
+    cd openresty-$NEW_OpenResty_version
+    make clean
+    openresty_version_tmp=${NEW_OpenResty_version%.*}
+    sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' bundle/nginx-$openresty_version_tmp/auto/cc/gcc # close debug
+    $openresty_install_dir/nginx/sbin/nginx -V &> $$
+    openresty_configure_arguments=`cat $$ | grep 'configure arguments:' | awk -F: '{print $2}'`
+    rm -rf $$
+    [ -n "`echo $openresty_configure_arguments | grep jemalloc`"] && malloc_module="--with-ld-opt='-ljemalloc'"
+    [ -n "`echo $openresty_configure_arguments | grep perftools`" ] && malloc_module='--with-google_perftools_module'
+    ./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-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module $malloc_module
+    make
+    if [ -f "build/nginx-$openresty_version_tmp/objs/nginx" ];then
+        /bin/mv $openresty_install_dir/nginx/sbin/nginx $openresty_install_dir/nginx/sbin/nginx$(date +%m%d)
+        make install
+        kill -USR2 `cat /var/run/nginx.pid`
+        sleep 1
+        kill -QUIT `cat /var/run/nginx.pid.oldbin`
+        echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_OpenResty_version${CEND} to ${CWARNING}$NEW_OpenResty_version${CEND}"
+    else
+        echo "${CFAILURE}Upgrade OpenResty failed! ${CEND}" 
+    fi
+    cd ..
+fi
+cd ..
+}

+ 1 - 1
include/zendopcache.sh

@@ -22,7 +22,7 @@ make && make install
 if [ -f "`$php_install_dir/bin/php-config --extension-dir`/opcache.so" ];then
 if [ -f "`$php_install_dir/bin/php-config --extension-dir`/opcache.so" ];then
     cat > $php_install_dir/etc/php.d/ext-opcache.ini << EOF
     cat > $php_install_dir/etc/php.d/ext-opcache.ini << EOF
 [opcache]
 [opcache]
-zend_extension=opcache.so
+zend_extension=`$php_install_dir/bin/php-config --extension-dir`/opcache.so
 opcache.enable=1
 opcache.enable=1
 opcache.memory_consumption=$Memory_limit
 opcache.memory_consumption=$Memory_limit
 opcache.interned_strings_buffer=8
 opcache.interned_strings_buffer=8

+ 15 - 10
install.sh

@@ -67,19 +67,21 @@ while :; do echo
         echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
         echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
     else
     else
         if [ "$Web_yn" == 'y' ];then
         if [ "$Web_yn" == 'y' ];then
-            # Nginx/Tegine
+            # Nginx/Tegine/OpenResty
             while :; do echo
             while :; do echo
                 echo 'Please select Nginx server:'
                 echo 'Please select Nginx server:'
                 echo -e "\t${CMSG}1${CEND}. Install Nginx"
                 echo -e "\t${CMSG}1${CEND}. Install Nginx"
                 echo -e "\t${CMSG}2${CEND}. Install Tengine"
                 echo -e "\t${CMSG}2${CEND}. Install Tengine"
-                echo -e "\t${CMSG}3${CEND}. Do not install"
+                echo -e "\t${CMSG}3${CEND}. Install OpenResty"
+                echo -e "\t${CMSG}4${CEND}. Do not install"
                 read -p "Please input a number:(Default 1 press Enter) " Nginx_version
                 read -p "Please input a number:(Default 1 press Enter) " Nginx_version
                 [ -z "$Nginx_version" ] && Nginx_version=1
                 [ -z "$Nginx_version" ] && Nginx_version=1
-                if [[ ! $Nginx_version =~ ^[1-3]$ ]];then
-                    echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
+                if [[ ! $Nginx_version =~ ^[1-4]$ ]];then
+                    echo "${CWARNING}input error! Please only input number 1,2,3,4${CEND}"
                 else
                 else
-                    [ "$Nginx_version" != '3' -a -e "$nginx_install_dir/sbin/nginx" ] && { echo "${CWARNING}Nginx already installed! ${CEND}"; Nginx_version=Other; }
-                    [ "$Nginx_version" != '3' -a -e "$tengine_install_dir/sbin/nginx" ] && { echo "${CWARNING}Tengine already installed! ${CEND}"; Nginx_version=Other; }
+                    [ "$Nginx_version" != '4' -a -e "$nginx_install_dir/sbin/nginx" ] && { echo "${CWARNING}Nginx already installed! ${CEND}"; Nginx_version=Other; }
+                    [ "$Nginx_version" != '4' -a -e "$tengine_install_dir/sbin/nginx" ] && { echo "${CWARNING}Tengine already installed! ${CEND}"; Nginx_version=Other; }
+                    [ "$Nginx_version" != '4' -a -e "$openresty_install_dir/sbin/nginx" ] && { echo "${CWARNING}OpenResty already installed! ${CEND}"; Nginx_version=Other; }
                     break
                     break
                 fi
                 fi
             done
             done
@@ -393,7 +395,7 @@ while :; do echo
 done
 done
 
 
 # check jemalloc or tcmalloc 
 # check jemalloc or tcmalloc 
-if [ "$Nginx_version" == '1' -o "$Nginx_version" == '2' -o "$DB_yn" == 'y' ];then
+if [[ $Nginx_version =~ ^[1-3]$ ]] || [ "$DB_yn" == 'y' ];then
     while :; do echo
     while :; do echo
         read -p "Do you want to use jemalloc or tcmalloc optimize Database and Web server? [y/n]: " je_tc_malloc_yn
         read -p "Do you want to use jemalloc or tcmalloc optimize Database and Web server? [y/n]: " je_tc_malloc_yn
         if [[ ! $je_tc_malloc_yn =~ ^[y,n]$ ]];then
         if [[ ! $je_tc_malloc_yn =~ ^[y,n]$ ]];then
@@ -567,6 +569,9 @@ if [ "$Nginx_version" == '1' ];then
 elif [ "$Nginx_version" == '2' ];then
 elif [ "$Nginx_version" == '2' ];then
     . include/tengine.sh
     . include/tengine.sh
     Install_Tengine 2>&1 | tee -a $oneinstack_dir/install.log
     Install_Tengine 2>&1 | tee -a $oneinstack_dir/install.log
+elif [ "$Nginx_version" == '3' ];then
+    . include/openresty.sh
+    Install_OpenResty 2>&1 | tee -a $oneinstack_dir/install.log
 fi
 fi
 
 
 # JDK
 # JDK
@@ -637,9 +642,9 @@ fi
 [ -d "$db_install_dir/support-files" -a -z "`ps -ef | grep -v grep | grep mysql`" ] && /etc/init.d/mysqld start
 [ -d "$db_install_dir/support-files" -a -z "`ps -ef | grep -v grep | grep mysql`" ] && /etc/init.d/mysqld start
 
 
 echo "####################Congratulations########################"
 echo "####################Congratulations########################"
-[ "$Web_yn" == 'y' -a "$Nginx_version" != '3' -a "$Apache_version" == '3' ] && echo -e "\n`printf "%-32s" "Nginx/Tengine install dir":`${CMSG}$web_install_dir${CEND}"
-[ "$Web_yn" == 'y' -a "$Nginx_version" != '3' -a "$Apache_version" != '3' ] && echo -e "\n`printf "%-32s" "Nginx/Tengine install dir":`${CMSG}$web_install_dir${CEND}\n`printf "%-32s" "Apache install  dir":`${CMSG}$apache_install_dir${CEND}" 
-[ "$Web_yn" == 'y' -a "$Nginx_version" == '3' -a "$Apache_version" != '3' ] && echo -e "\n`printf "%-32s" "Apache install dir":`${CMSG}$apache_install_dir${CEND}"
+[ "$Web_yn" == 'y' -a "$Nginx_version" != '4' -a "$Apache_version" == '3' ] && echo -e "\n`printf "%-32s" "Nginx install dir":`${CMSG}$web_install_dir${CEND}"
+[ "$Web_yn" == 'y' -a "$Nginx_version" != '4' -a "$Apache_version" != '3' ] && echo -e "\n`printf "%-32s" "Nginx install dir":`${CMSG}$web_install_dir${CEND}\n`printf "%-32s" "Apache install  dir":`${CMSG}$apache_install_dir${CEND}" 
+[ "$Web_yn" == 'y' -a "$Nginx_version" == '4' -a "$Apache_version" != '3' ] && echo -e "\n`printf "%-32s" "Apache install dir":`${CMSG}$apache_install_dir${CEND}"
 [[ "$Tomcat_version" =~ ^[1,2]$ ]] && echo -e "\n`printf "%-32s" "Tomcat install dir":`${CMSG}$tomcat_install_dir${CEND}"
 [[ "$Tomcat_version" =~ ^[1,2]$ ]] && echo -e "\n`printf "%-32s" "Tomcat install dir":`${CMSG}$tomcat_install_dir${CEND}"
 [ "$DB_yn" == 'y' ] && echo -e "\n`printf "%-32s" "Database install dir:"`${CMSG}$db_install_dir${CEND}"
 [ "$DB_yn" == 'y' ] && echo -e "\n`printf "%-32s" "Database install dir:"`${CMSG}$db_install_dir${CEND}"
 [ "$DB_yn" == 'y' ] && echo "`printf "%-32s" "Database data dir:"`${CMSG}$db_data_dir${CEND}"
 [ "$DB_yn" == 'y' ] && echo "`printf "%-32s" "Database data dir:"`${CMSG}$db_data_dir${CEND}"

+ 1 - 0
options.conf

@@ -7,6 +7,7 @@ run_user=www
 # set the default install path, you can freely specify
 # set the default install path, you can freely specify
 nginx_install_dir=/usr/local/nginx
 nginx_install_dir=/usr/local/nginx
 tengine_install_dir=/usr/local/tengine
 tengine_install_dir=/usr/local/tengine
+openresty_install_dir=/usr/local/openresty
 apache_install_dir=/usr/local/apache
 apache_install_dir=/usr/local/apache
 tomcat_install_dir=/usr/local/tomcat
 tomcat_install_dir=/usr/local/tomcat
 
 

+ 2 - 0
uninstall.sh

@@ -62,6 +62,7 @@ echo "${CWARNING}You will uninstall OneinStack, Please backup your configure fil
 Print_web() {
 Print_web() {
 [ -d "$nginx_install_dir" ] && echo "$nginx_install_dir" 
 [ -d "$nginx_install_dir" ] && echo "$nginx_install_dir" 
 [ -d "$tengine_install_dir" ] && echo "$tengine_install_dir"
 [ -d "$tengine_install_dir" ] && echo "$tengine_install_dir"
+[ -d "$openresty_install_dir" ] && echo "$openresty_install_dir"
 [ -e "/etc/init.d/nginx" ] && echo '/etc/init.d/nginx'
 [ -e "/etc/init.d/nginx" ] && echo '/etc/init.d/nginx'
 [ -e "/etc/logrotate.d/nginx" ] && echo '/etc/logrotate.d/nginx'
 [ -e "/etc/logrotate.d/nginx" ] && echo '/etc/logrotate.d/nginx'
 
 
@@ -78,6 +79,7 @@ Print_web() {
 Uninstall_Web() {
 Uninstall_Web() {
 [ -d "$nginx_install_dir" ] && { killall nginx > /dev/null 2>&1; rm -rf $nginx_install_dir /etc/init.d/nginx /etc/logrotate.d/nginx; sed -i "s@$nginx_install_dir/sbin:@@" /etc/profile; }
 [ -d "$nginx_install_dir" ] && { killall nginx > /dev/null 2>&1; rm -rf $nginx_install_dir /etc/init.d/nginx /etc/logrotate.d/nginx; sed -i "s@$nginx_install_dir/sbin:@@" /etc/profile; }
 [ -d "$tengine_install_dir" ] && { killall nginx > /dev/null 2>&1; rm -rf $tengine_install_dir /etc/init.d/nginx /etc/logrotate.d/nginx; sed -i "s@$tengine_install_dir/sbin:@@" /etc/profile; }
 [ -d "$tengine_install_dir" ] && { killall nginx > /dev/null 2>&1; rm -rf $tengine_install_dir /etc/init.d/nginx /etc/logrotate.d/nginx; sed -i "s@$tengine_install_dir/sbin:@@" /etc/profile; }
+[ -d "$openresty_install_dir" ] && { killall nginx > /dev/null 2>&1; rm -rf $openresty_install_dir /etc/init.d/nginx /etc/logrotate.d/nginx; sed -i "s@$openresty_install_dir/nginx/sbin:@@" /etc/profile; }
 [ -d "$apache_install_dir" ] && { service httpd stop > /dev/null 2>&1; rm -rf $apache_install_dir /etc/init.d/httpd /etc/logrotate.d/apache; sed -i "s@$apache_install_dir/bin:@@" /etc/profile; }
 [ -d "$apache_install_dir" ] && { service httpd stop > /dev/null 2>&1; rm -rf $apache_install_dir /etc/init.d/httpd /etc/logrotate.d/apache; sed -i "s@$apache_install_dir/bin:@@" /etc/profile; }
 [ -d "$tomcat_install_dir" ] && { killall java > /dev/null 2>&1; rm -rf $tomcat_install_dir /etc/init.d/tomcat; /etc/logrotate.d/tomcat; }
 [ -d "$tomcat_install_dir" ] && { killall java > /dev/null 2>&1; rm -rf $tomcat_install_dir /etc/init.d/tomcat; /etc/logrotate.d/tomcat; }
 [ -d "/usr/java" ] && { rm -rf /usr/java; sed -i '/export JAVA_HOME=/d' /etc/profile; sed -i '/export CLASSPATH=/d' /etc/profile; sed -i 's@\$JAVA_HOME/bin:@@' /etc/profile; }
 [ -d "/usr/java" ] && { rm -rf /usr/java; sed -i '/export JAVA_HOME=/d' /etc/profile; sed -i '/export CLASSPATH=/d' /etc/profile; sed -i 's@\$JAVA_HOME/bin:@@' /etc/profile; }

+ 6 - 2
upgrade.sh

@@ -42,7 +42,7 @@ PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
 Usage(){
 Usage(){
 printf "
 printf "
 Usage: $0 [ ${CMSG}web${CEND} | ${CMSG}db${CEND} | ${CMSG}php${CEND} | ${CMSG}redis${CEND} | ${CMSG}phpmyadmin${CEND} ]
 Usage: $0 [ ${CMSG}web${CEND} | ${CMSG}db${CEND} | ${CMSG}php${CEND} | ${CMSG}redis${CEND} | ${CMSG}phpmyadmin${CEND} ]
-${CMSG}web${CEND}            --->Upgrade Nginx/Tengine
+${CMSG}web${CEND}            --->Upgrade Nginx/Tengine/OpenResty
 ${CMSG}db${CEND}             --->Upgrade MySQL/MariaDB/Percona
 ${CMSG}db${CEND}             --->Upgrade MySQL/MariaDB/Percona
 ${CMSG}php${CEND}            --->Upgrade PHP
 ${CMSG}php${CEND}            --->Upgrade PHP
 ${CMSG}redis${CEND}          --->Upgrade Redis
 ${CMSG}redis${CEND}          --->Upgrade Redis
@@ -56,7 +56,7 @@ while :
 do
 do
     printf "
     printf "
 What Are You Doing?
 What Are You Doing?
-\t${CMSG}1${CEND}. Upgrade Nginx/Tengine
+\t${CMSG}1${CEND}. Upgrade Nginx/Tengine/OpenResty
 \t${CMSG}2${CEND}. Upgrade MySQL/MariaDB/Percona
 \t${CMSG}2${CEND}. Upgrade MySQL/MariaDB/Percona
 \t${CMSG}3${CEND}. Upgrade PHP
 \t${CMSG}3${CEND}. Upgrade PHP
 \t${CMSG}4${CEND}. Upgrade Redis
 \t${CMSG}4${CEND}. Upgrade Redis
@@ -74,6 +74,8 @@ What Are You Doing?
                 Upgrade_Nginx
                 Upgrade_Nginx
             elif [ -e "$tengine_install_dir/sbin/nginx" ];then
             elif [ -e "$tengine_install_dir/sbin/nginx" ];then
                 Upgrade_Tengine
                 Upgrade_Tengine
+            elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ];then
+                Upgrade_OpenResty
             fi
             fi
             ;;
             ;;
 
 
@@ -109,6 +111,8 @@ elif [ $# == 1 ];then
             Upgrade_Nginx
             Upgrade_Nginx
         elif [ -e "$tengine_install_dir/sbin/nginx" ];then
         elif [ -e "$tengine_install_dir/sbin/nginx" ];then
             Upgrade_Tengine
             Upgrade_Tengine
+        elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ];then
+            Upgrade_OpenResty
         fi
         fi
         ;;
         ;;