PHP7 Web环境安装临时存放shell

cat>/etc/yum.repos.d/MariaDB.repo<<EOF
  [mariadb]
  name = MariaDB
  baseurl = http://yum.mariadb.org/10.1/centos6-amd64
  gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
  gpgcheck=1
  EOF
  yum -y install git wget gcc gcc-c++ gmake autoconf
  yum -y install lua-devel
  yum -y install libmcrypt-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel libcurl-devel openssl-devel libc-client-devel net-snmp-devel
yum -y install MariaDB-Galera-server MariaDB-server MariaDB-client galera
#-----------install pcre
  cd /tmp
  wget -c -q http://downloads.sourceforge.net/project/pcre/pcre/8.21/pcre-8.21.tar.gz -O - | tar zxf -
  cd pcre-8.21
  ./configure
  make && make install
  if [ `uname -i` == x86_64 ]; then ln -s /usr/lib64/{libpcre.*,libjpeg.so,libpng.so,libXpm.so,libc-client.so,libkrb5.so,libexpat.so,libevent.so} /usr/lib/;fi
#----------install bison
  cd /tmp
  wget http://ftp.gnu.org/gnu/bison/bison-2.6.4.tar.gz -O - | tar zxf -
  cd bison-2.6.4  
  ./configure  
  make && make install  
#--------------install ioncube loader
  wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz -O -| tar zxf - -C /opt/
#----------install php5.6
  cd /tmp
  wget http://sg2.php.net/get/php-5.6.28.tar.gz/from/this/mirror  -O - | tar zxf -
  cd php-5.6.28
  ./configure --prefix=/opt/php5 --with-config-file-path=/opt/php5/etc --with-mcrypt=/usr/include --with-snmp --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-imap --with-imap-ssl --with-kerberos --with-gd --with-iconv --with-zlib --enable-mysqlnd --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache
  gmake
  gmake install
  cp php.ini-production /opt/php5/etc/php.ini
  cp sapi/fpm/init.d.php-fpm /etc/init.d/php5-fpm
  cp /opt/php5/etc/php-fpm.conf.default /opt/php5/etc/php-fpm.conf  
  chmod +x /etc/init.d/php5-fpm  
  chkconfig php5-fpm on
  echo "zend_extension=/opt/ioncube/ioncube_loader_lin_5.6.so">>/opt/php5/etc/php.ini
  Wizard_php /opt/php5
#----------install php7
  cd /tmp
  wget http://sg2.php.net/get/php-7.0.13.tar.gz/from/this/mirror  -O - | tar zxf -
  cd php-7.0.13
  ./configure --prefix=/opt/php7 --with-config-file-path=/opt/php7/etc --with-mcrypt=/usr/include --with-snmp --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-imap --with-imap-ssl --with-kerberos --with-gd --with-iconv --with-zlib --enable-mysqlnd --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache
  gmake -j8
  gmake install
  ln -s /opt/php7/bin/* /usr/bin/
  cp php.ini-production /opt/php7/etc/php.ini
  cp sapi/fpm/init.d.php-fpm /etc/init.d/php7-fpm
  cp /opt/php7/etc/php-fpm.conf.default /opt/php7/etc/php-fpm.conf  
  echo "zend_extension=/opt/ioncube/ioncube_loader_lin_7.0.so">>/opt/php7/etc/php.ini
  chmod +x /etc/init.d/php7-fpm  
  chkconfig php7-fpm on
  Wizard_php /opt/php7
Wizard_php() {
  php_install_dir=$1
  Mem=`free -m | awk '/Mem:/{print $2}'`
  if [ $Mem -gt 1024 -a $Mem -le 1500 ];then
  Memory_limit=192
  elif [ $Mem -gt 1500 -a $Mem -le 3500 ];then
  Memory_limit=256
  elif [ $Mem -gt 3500 -a $Mem -le 4500 ];then
  Memory_limit=320
  elif [ $Mem -gt 4500 ];then
  Memory_limit=448
  else
  Memory_limit=128
  fi
  sed -i "s#^memory_limit.*#memory_limit = ${Memory_limit}M#" $php_install_dir/etc/php.ini
  sed -i 's#^output_buffering =#output_buffering = On\noutput_buffering =#' $php_install_dir/etc/php.ini
  sed -i 's#^;cgi.fix_pathinfo.*#cgi.fix_pathinfo=0#' $php_install_dir/etc/php.ini
  sed -i 's#^short_open_tag = Off#short_open_tag = On#' $php_install_dir/etc/php.ini
  sed -i 's#^expose_php = On#expose_php = Off#' $php_install_dir/etc/php.ini
  sed -i 's#^request_order.*#request_order = "CGP"#' $php_install_dir/etc/php.ini
  sed -i 's#^;date.timezone.*#date.timezone = Asia/Shanghai#' $php_install_dir/etc/php.ini
  sed -i 's#^post_max_size.*#post_max_size = 50M#' $php_install_dir/etc/php.ini
  sed -i 's#^upload_max_filesize.*#upload_max_filesize = 50M#' $php_install_dir/etc/php.ini
  sed -i 's#^;upload_tmp_dir.*#upload_tmp_dir = /tmp#' $php_install_dir/etc/php.ini
  sed -i 's#^max_execution_time.*#max_execution_time = 600#' $php_install_dir/etc/php.ini
  sed -i 's#^;realpath_cache_size.*#realpath_cache_size = 2M#' $php_install_dir/etc/php.ini
  sed -i 's#^disable_functions.*#disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen#' $php_install_dir/etc/php.ini
  sed -i 's#^session.cookie_httponly.*#session.cookie_httponly = 1#' $php_install_dir/etc/php.ini
  sed -i 's#^mysqlnd.collect_memory_statistics.*#mysqlnd.collect_memory_statistics = On#' $php_install_dir/etc/php.ini
  [ -e /usr/sbin/sendmail ] && sed -i 's#^;sendmail_path.*#sendmail_path = /usr/sbin/sendmail -t -i#' $php_install_dir/etc/php.ini
  sed -i 's#^\[opcache\]#[opcache]\nzend_extension=opcache.so#' $php_install_dir/etc/php.ini
  sed -i 's#^;opcache.enable=.*#opcache.enable=1#' $php_install_dir/etc/php.ini
  sed -i "s#^;opcache.memory_consumption.*#opcache.memory_consumption=$Memory_limit#" $php_install_dir/etc/php.ini
  sed -i 's#^;opcache.interned_strings_buffer.*#opcache.interned_strings_buffer=8#' $php_install_dir/etc/php.ini
  sed -i 's#^;opcache.max_accelerated_files.*#opcache.max_accelerated_files=4000#' $php_install_dir/etc/php.ini
  sed -i 's#^;opcache.revalidate_freq.*#opcache.revalidate_freq=60#' $php_install_dir/etc/php.ini
  sed -i 's#^;opcache.save_comments.*#opcache.save_comments=0#' $php_install_dir/etc/php.ini
  sed -i 's#^;opcache.fast_shutdown.*#opcache.fast_shutdown=1#' $php_install_dir/etc/php.ini
  sed -i 's#^;opcache.validate_timestamps.*#opcache.validate_timestamps=1#' $php_install_dir/etc/php.ini
  sed -i 's#^;opcache.enable_cli.*#opcache.enable_cli=1#' $php_install_dir/etc/php.ini
  sed -i 's#^;opcache.use_cwd.*#opcache.use_cwd=1#' $php_install_dir/etc/php.ini
  sed -i 's#^opcache.max_accelerated_files.*#opcache.max_accelerated_files=100000#' $php_install_dir/etc/php.ini
  sed -i 's#^;opcache.max_wasted_percentage.*#opcache.max_wasted_percentage=5#' $php_install_dir/etc/php.ini
  sed -i 's#^;opcache.consistency_checks.*#opcache.consistency_checks=0#' $php_install_dir/etc/php.ini
  sed -i 's#^;opcache.optimization_level.*#;opcache.optimization_level=0#' $php_install_dir/etc/php.ini
  }


#--------------install openresty
  cd /tmp
  wget https://openresty.org/download/openresty-1.11.2.2.tar.gz -O - | tar zxf -
  cd openresty-1.11.2.2
  ./configure -j2 --prefix=/etc/ --sbin-path=/usr/sbin/nginx --pid-path=/var/run/nginx.pid --with-http_stub_status_module
  gmake -j2
  gmake install
  wget http://down.kvm.la/conf/nginx.init.d -O /etc/init.d/nginx
  chmod 755 /etc/init.d/nginx
  chkconfig --add nginx


#--------------install sregex
  cd /tmp
  git clone  https://github.com/agentzh/sregex
  cd sregex
  make && make install
  ln -s ln -s /usr/local/lib/libsrege* /usr/lib/
  #--------------install nginx
  cd /tmp
  wget -c http://nginx.org/download/nginx-1.11.10.tar.gz -O - | tar zxf - ;  cd nginx-1.11.10
  wget http://dl.kvm.la/softsource/substitutions4nginx.tar.gz -O - | tar zxf -
  wget https://www.openssl.org/source/openssl-1.0.2j.tar.gz  -O - | tar zxf - ; mv openssl-1.0.2j openssl
  git clone https://github.com/openssl/openssl
  git clone https://github.com/simpl/ngx_devel_kit
  git clone https://github.com/openresty/lua-nginx-module
  git clone https://github.com/agentzh/srcache-nginx-module
  git clone https://github.com/agentzh/memc-nginx-module
  git clone https://github.com/agentzh/echo-nginx-module
  git clone https://github.com/agentzh/replace-filter-nginx-module
  git clone https://github.com/agentzh/set-misc-nginx-module
  ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --pid-path=/var/run/nginx.pid --conf-path=/etc/nginx/nginx.conf --lock-path=/var/lock/subsys/nginx  --with-http_v2_module --with-http_v2_module  --with-pcre --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_secure_link_module --with-http_dav_module --with-http_ssl_module --with-openssl=openssl --add-module=replace-filter-nginx-module --add-module=echo-nginx-module --add-module=lua-nginx-module --add-module=ngx_devel_kit --add-module=set-misc-nginx-module --add-module=substitutions4nginx --with-cc-opt=-m64 --with-ld-opt=-m64 --with-ld-opt=-lrt
  gmake -j2
  gmake install
  wget http://down.kvm.la/conf/nginx.init.d -O /etc/init.d/nginx
  chmod 755 /etc/init.d/nginx
  chkconfig --add nginx
#--------------Set iptables firwall
  iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
  iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
  service iptables save

添加新评论 »