Browse Source

Update Apache

lj2007331 8 years ago
parent
commit
88cf363678
9 changed files with 85 additions and 83 deletions
  1. 1 1
      README.md
  2. 2 3
      addons.sh
  3. 35 34
      include/apache-2.2.sh
  4. 41 38
      include/apache-2.4.sh
  5. 1 2
      include/xcache.sh
  6. 1 1
      init.d/Memcached-init-CentOS
  7. 2 2
      init.d/Redis-server-init
  8. 1 1
      install.sh
  9. 1 1
      uninstall.sh

+ 1 - 1
README.md

@@ -6,7 +6,7 @@ Script properties:
 - Continually updated
 - Source compiler installation, most stable source is the latest version, and download from the official site
 - 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, AliSQL-5.6)
 - 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, Tomcat-6)

+ 2 - 3
addons.sh

@@ -132,7 +132,7 @@ EOF
   if [ -e "/root/.local/share/letsencrypt/bin/letsencrypt" ] && certbot-auto -h | grep '\-\-standalone' > /dev/null ; then
     echo; echo "${CSUCCESS}Let's Encrypt client installed successfully! ${CEND}"
   else
-    echo; echo "${CSUCCESS}Let's Encrypt client install failed, Please try again! ${CEND}"
+    echo; echo "${CFAILURE}Let's Encrypt client install failed, Please try again! ${CEND}"
   fi
 }
 
@@ -346,12 +346,11 @@ What Are You Doing?
           pushd ${oneinstack_dir}/src
           src_url=http://www.php.net/distributions/php-${PHP_detail_version}.tar.gz && Download_src
           tar xzf php-${PHP_detail_version}.tar.gz
-          popd
           pushd php-${PHP_detail_version}/ext/fileinfo
           ${php_install_dir}/bin/phpize
           ./configure --with-php-config=${php_install_dir}/bin/php-config
           make -j ${THREAD} && make install
-          popd
+          popd;popd
           echo "extension=fileinfo.so" > ${php_install_dir}/etc/php.d/ext-fileinfo.ini
           Check_succ
         else

+ 35 - 34
include/apache-2.2.sh

@@ -15,9 +15,10 @@ Install_Apache-2-2() {
   tar xzf httpd-$apache_2_version.tar.gz
   pushd httpd-$apache_2_version
   [ ! -d "$apache_install_dir" ] && mkdir -p $apache_install_dir
-  [ "$ZendGuardLoader_yn" == 'y' -o "$ionCube_yn" == 'y' ] && MPM=prefork || MPM=worker
-  ./configure --prefix=$apache_install_dir --enable-headers --enable-deflate --enable-mime-magic --enable-so --enable-rewrite --enable-ssl --with-ssl --enable-expires --enable-static-support --enable-suexec --disable-userdir --with-included-apr --with-mpm=$MPM --disable-userdir
+  [ "${Ubuntu_version}" == "12" ] && sed -i '@SSL_PROTOCOL_SSLV2@d' modules/ssl/ssl_engine_io.c
+  LDFLAGS=-ldl ./configure --prefix=$apache_install_dir --with-mpm=prefork --with-included-apr --enable-headers --enable-deflate --enable-so --enable-rewrite --enable-ssl --with-ssl --enable-expires --enable-static-support --enable-suexec --enable-modules=all --enable-mods-shared=all
   make -j ${THREAD} && make install
+  unset LDFLAGS
   if [ -e "$apache_install_dir/conf/httpd.conf" ]; then
     echo "${CSUCCESS}Apache installed successfully! ${CEND}"
     popd
@@ -61,16 +62,16 @@ Install_Apache-2-2() {
   #logrotate apache log
   cat > /etc/logrotate.d/apache << EOF
 $wwwlogs_dir/*apache.log {
-daily
-rotate 5
-missingok
-dateext
-compress
-notifempty
-sharedscripts
-postrotate
-[ -f $apache_install_dir/logs/httpd.pid ] && kill -USR1 \`cat $apache_install_dir/logs/httpd.pid\`
-endscript
+  daily
+  rotate 5
+  missingok
+  dateext
+  compress
+  notifempty
+  sharedscripts
+  postrotate
+    [ -f $apache_install_dir/logs/httpd.pid ] && kill -USR1 \`cat $apache_install_dir/logs/httpd.pid\`
+  endscript
 }
 EOF
 
@@ -78,37 +79,37 @@ EOF
   cat >> $apache_install_dir/conf/vhost/0.conf << EOF
 NameVirtualHost *:$TMP_PORT
 <VirtualHost *:$TMP_PORT>
-    ServerAdmin admin@linuxeye.com
-    DocumentRoot "$wwwroot_dir/default"
-    ServerName $TMP_IP
-    ErrorLog "$wwwlogs_dir/error_apache.log"
-    CustomLog "$wwwlogs_dir/access_apache.log" common
+  ServerAdmin admin@linuxeye.com
+  DocumentRoot "$wwwroot_dir/default"
+  ServerName $TMP_IP
+  ErrorLog "$wwwlogs_dir/error_apache.log"
+  CustomLog "$wwwlogs_dir/access_apache.log" common
 <Directory "$wwwroot_dir/default">
-    SetOutputFilter DEFLATE
-    Options FollowSymLinks ExecCGI
-    AllowOverride All
-    Order allow,deny
-    Allow from all
-    DirectoryIndex index.html index.php
+  SetOutputFilter DEFLATE
+  Options FollowSymLinks ExecCGI
+  AllowOverride All
+  Order allow,deny
+  Allow from all
+  DirectoryIndex index.html index.php
 </Directory>
 <Location /server-status>
-    SetHandler server-status
-    Order Deny,Allow
-    Deny from all
-    Allow from 127.0.0.1
+  SetHandler server-status
+  Order Deny,Allow
+  Deny from all
+  Allow from 127.0.0.1
 </Location>
 </VirtualHost>
 EOF
 
   cat >> $apache_install_dir/conf/httpd.conf <<EOF
 <IfModule mod_headers.c>
-    AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript
-    <FilesMatch "\.(js|css|html|htm|png|jpg|swf|pdf|shtml|xml|flv|gif|ico|jpeg)\$">
-        RequestHeader edit "If-None-Match" "^(.*)-gzip(.*)\$" "\$1\$2"
-        Header edit "ETag" "^(.*)-gzip(.*)\$" "\$1\$2"
-    </FilesMatch>
-    DeflateCompressionLevel 6
-    SetOutputFilter DEFLATE
+  AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript
+  <FilesMatch "\.(js|css|html|htm|png|jpg|swf|pdf|shtml|xml|flv|gif|ico|jpeg)\$">
+    RequestHeader edit "If-None-Match" "^(.*)-gzip(.*)\$" "\$1\$2"
+    Header edit "ETag" "^(.*)-gzip(.*)\$" "\$1\$2"
+  </FilesMatch>
+  DeflateCompressionLevel 6
+  SetOutputFilter DEFLATE
 </IfModule>
 
 ServerTokens ProductOnly

+ 41 - 38
include/apache-2.4.sh

@@ -24,9 +24,9 @@ Install_Apache-2-4() {
   [ ! -d "$apache_install_dir" ] && mkdir -p $apache_install_dir
   /bin/cp -R ../apr-$apr_version ./srclib/apr
   /bin/cp -R ../apr-util-$apr_util_version ./srclib/apr-util
-  [ "$ZendGuardLoader_yn" == 'y' -o "$ionCube_yn" == 'y' ] && MPM=prefork || MPM=worker
-  ./configure --prefix=$apache_install_dir --enable-headers --enable-deflate --enable-mime-magic --enable-so --enable-rewrite --enable-ssl --with-ssl --enable-expires --enable-static-support --enable-suexec --disable-userdir --with-included-apr --with-mpm=$MPM --disable-userdir
+  LDFLAGS=-ldl ./configure --prefix=$apache_install_dir --with-mpm=prefork --with-included-apr --enable-headers --enable-deflate --enable-so --enable-dav --enable-rewrite --enable-ssl --with-ssl --enable-expires --enable-static-support --enable-suexec --enable-modules=all --enable-mods-shared=all
   make -j ${THREAD} && make install
+  unset LDFLAGS
   if [ -e "$apache_install_dir/conf/httpd.conf" ]; then
     echo "${CSUCCESS}Apache installed successfully! ${CEND}"
     popd 
@@ -62,9 +62,12 @@ Install_Apache-2-4() {
   fi
   sed -i "s@AddType\(.*\)Z@AddType\1Z\n    AddType application/x-httpd-php .php .phtml\n    AddType application/x-httpd-php-source .phps@" $apache_install_dir/conf/httpd.conf
   sed -i "s@#AddHandler cgi-script .cgi@AddHandler cgi-script .cgi .pl@" $apache_install_dir/conf/httpd.conf
-  sed -i 's@^#LoadModule rewrite_module@LoadModule rewrite_module@' $apache_install_dir/conf/httpd.conf
-  sed -i 's@^#LoadModule\(.*\)mod_deflate.so@LoadModule\1mod_deflate.so@' $apache_install_dir/conf/httpd.conf
-  sed -i 's@^#LoadModule\(.*\)mod_ssl.so@LoadModule\1mod_ssl.so@' $apache_install_dir/conf/httpd.conf
+  sed -ri 's@^#(.*mod_suexec.so)@\1@' $apache_install_dir/conf/httpd.conf
+  sed -ri 's@^#(.*mod_vhost_alias.so)@\1@' $apache_install_dir/conf/httpd.conf
+  sed -ri 's@^#(.*mod_rewrite.so)@\1@' $apache_install_dir/conf/httpd.conf
+  sed -ri 's@^#(.*mod_deflate.so)@\1@' $apache_install_dir/conf/httpd.conf
+  sed -ri 's@^#(.*mod_expires.so)@\1@' $apache_install_dir/conf/httpd.conf
+  sed -ri 's@^#(.*mod_ssl.so)@\1@' $apache_install_dir/conf/httpd.conf
   sed -i 's@DirectoryIndex index.html@DirectoryIndex index.html index.php@' $apache_install_dir/conf/httpd.conf
   sed -i "s@^DocumentRoot.*@DocumentRoot \"$wwwroot_dir/default\"@" $apache_install_dir/conf/httpd.conf
   sed -i "s@^<Directory \"$apache_install_dir/htdocs\">@<Directory \"$wwwroot_dir/default\">@" $apache_install_dir/conf/httpd.conf
@@ -73,54 +76,54 @@ Install_Apache-2-4() {
   #logrotate apache log
   cat > /etc/logrotate.d/apache << EOF
 $wwwlogs_dir/*apache.log {
-daily
-rotate 5
-missingok
-dateext
-compress
-notifempty
-sharedscripts
-postrotate
-[ -f $apache_install_dir/logs/httpd.pid ] && kill -USR1 \`cat $apache_install_dir/logs/httpd.pid\`
-endscript
+  daily
+  rotate 5
+  missingok
+  dateext
+  compress
+  notifempty
+  sharedscripts
+  postrotate
+    [ -f $apache_install_dir/logs/httpd.pid ] && kill -USR1 \`cat $apache_install_dir/logs/httpd.pid\`
+  endscript
 }
 EOF
 
   mkdir $apache_install_dir/conf/vhost
   cat >> $apache_install_dir/conf/vhost/0.conf << EOF
 <VirtualHost *:$TMP_PORT>
-    ServerAdmin admin@linuxeye.com
-    DocumentRoot "$wwwroot_dir/default"
-    ServerName $TMP_IP
-    ErrorLog "$wwwlogs_dir/error_apache.log"
-    CustomLog "$wwwlogs_dir/access_apache.log" common
+  ServerAdmin admin@linuxeye.com
+  DocumentRoot "$wwwroot_dir/default"
+  ServerName $TMP_IP
+  ErrorLog "$wwwlogs_dir/error_apache.log"
+  CustomLog "$wwwlogs_dir/access_apache.log" common
 <Directory "$wwwroot_dir/default">
-    SetOutputFilter DEFLATE
-    Options FollowSymLinks ExecCGI
-    Require all granted
-    AllowOverride All
-    Order allow,deny
-    Allow from all
-    DirectoryIndex index.html index.php
+  SetOutputFilter DEFLATE
+  Options FollowSymLinks ExecCGI
+  Require all granted
+  AllowOverride All
+  Order allow,deny
+  Allow from all
+  DirectoryIndex index.html index.php
 </Directory>
 <Location /server-status>
-    SetHandler server-status
-    Order Deny,Allow
-    Deny from all
-    Allow from 127.0.0.1
+  SetHandler server-status
+  Order Deny,Allow
+  Deny from all
+  Allow from 127.0.0.1
 </Location>
 </VirtualHost>
 EOF
 
   cat >> $apache_install_dir/conf/httpd.conf <<EOF
 <IfModule mod_headers.c>
-    AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript
-    <FilesMatch "\.(js|css|html|htm|png|jpg|swf|pdf|shtml|xml|flv|gif|ico|jpeg)\$">
-        RequestHeader edit "If-None-Match" "^(.*)-gzip(.*)\$" "\$1\$2"
-        Header edit "ETag" "^(.*)-gzip(.*)\$" "\$1\$2"
-    </FilesMatch>
-    DeflateCompressionLevel 6
-    SetOutputFilter DEFLATE
+  AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript
+  <FilesMatch "\.(js|css|html|htm|png|jpg|swf|pdf|shtml|xml|flv|gif|ico|jpeg)\$">
+    RequestHeader edit "If-None-Match" "^(.*)-gzip(.*)\$" "\$1\$2"
+    Header edit "ETag" "^(.*)-gzip(.*)\$" "\$1\$2"
+  </FilesMatch>
+  DeflateCompressionLevel 6
+  SetOutputFilter DEFLATE
 </IfModule>
 
 ServerTokens ProductOnly

+ 1 - 2
include/xcache.sh

@@ -16,14 +16,13 @@ Install_XCache() {
   ${php_install_dir}/bin/phpize
   ./configure --enable-xcache --enable-xcache-coverager --enable-xcache-optimizer --with-php-config=${php_install_dir}/bin/php-config
   make -j ${THREAD} && make install
-  popd
   if [ -f "${phpExtensionDir}/xcache.so" ]; then
     /bin/cp -R htdocs ${wwwroot_dir}/default/xcache
+    popd
     chown -R ${run_user}.${run_user} ${wwwroot_dir}/default/xcache
     touch /tmp/xcache;chown ${run_user}.${run_user} /tmp/xcache
     let xcacheCount="${CPU}+1"
     let xcacheSize="${Memory_limit}/2"
-
     cat > ${php_install_dir}/etc/php.d/ext-xcache.ini << EOF
 [xcache-common]
 extension=xcache.so

+ 1 - 1
init.d/Memcached-init-CentOS

@@ -30,7 +30,7 @@ start () {
   if [ "$(stat -c %U /var/run/memcached)" != "$USER" ]; then
     chown $USER /var/run/memcached
   fi
-  $DAEMON -d -p $PORT -u $USER  -m $CACHESIZE -c $MAXCONN -P /var/run/memcached/memcached.pid $OPTIONS
+  daemon $DAEMON -d -p $PORT -u $USER  -m $CACHESIZE -c $MAXCONN -P /var/run/memcached/memcached.pid $OPTIONS
   RETVAL=$?
   echo
   [ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached

+ 2 - 2
init.d/Redis-server-init

@@ -30,7 +30,7 @@ case "$1" in
     chown redis:redis $PIDFILE
     if start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid redis:redis --exec $DAEMON -- $DAEMON_ARGS
     then
-      echo "$NAME."
+      echo -e "\e[00;32m[OK]\e[00m"
     else
       echo "failed"
     fi
@@ -39,7 +39,7 @@ case "$1" in
     echo -n "Stopping $DESC: "
     if start-stop-daemon --stop --retry 10 --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
     then
-      echo "$NAME."
+      echo -e "\e[00;32m[OK]\e[00m"
     else
       echo "failed"
     fi

+ 1 - 1
install.sh

@@ -421,7 +421,7 @@ while :; do echo
 done
 
 # check jemalloc or tcmalloc
-if [[ $Nginx_version =~ ^[1-3]$ ]] || [ "$DB_yn" == 'y' -a "$DB_version" != '0' ]; then
+if [[ $Nginx_version =~ ^[1-3]$ ]] || [ "$DB_yn" == 'y' -a "$DB_version" != '10' ]; then
   while :; do echo
     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

+ 1 - 1
uninstall.sh

@@ -98,7 +98,7 @@ Print_DB() {
 }
 
 Uninstall_DB() {
-  [ -e "${db_install_dir}" ] && { service mysqld stop > /dev/null 2>&1; rm -rf ${db_install_dir} /etc/init.d/mysqld /etc/my.cnf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf; }
+  [ -e "${db_install_dir}" ] && { service mysqld stop > /dev/null 2>&1; rm -rf ${db_install_dir} /etc/init.d/mysqld /etc/my.cnf /etc/ld.so.conf.d/{mysql,mariadb,percona,alisql}*.conf; }
   id -u mysql >/dev/null 2>&1 ; [ $? -eq 0 ] && userdel mysql
   [ -e "${db_data_dir}" ] && /bin/mv ${db_data_dir}{,$(date +%Y%m%d%H)}
   sed -i 's@^dbrootpwd=.*@dbrootpwd=@' ./options.conf