├── .gitignore ├── LICENSE ├── README.md ├── backup ├── backup.sh ├── qrsync └── tool.sh ├── conf ├── 301.conf ├── config.inc.php ├── dabr.conf ├── dedecms.conf ├── discuz.conf ├── discuzx.conf ├── discuzx2.conf ├── drupal.conf ├── ecshop.conf ├── index.html ├── memcached-init ├── memcached.php ├── nginx.conf ├── nginx_h.conf ├── nginx_n.conf ├── none.conf ├── ocp.php ├── p.php ├── pathinfo.conf ├── php-fpm.conf ├── phpinfo.php ├── phpwind.conf ├── proxy.conf ├── rpaf.conf ├── sablog.conf ├── server.ini ├── shopex.conf ├── typecho.conf ├── wordpress.conf └── wp2.conf ├── init ├── HHVM-init-CentOS ├── Memcached-init-CentOS ├── Memcached-init-Ubuntu ├── Nginx-init-CentOS ├── Nginx-init-Ubuntu ├── Redis-server-init-CentOS ├── Redis-server-init-Ubuntu ├── hhvm ├── init.d.nginx ├── init.d.proftpd ├── init.d.redis ├── init_CentOS.sh ├── init_CentOS_hhvm.sh ├── init_Debian.sh ├── init_Debian_hhvm.sh ├── init_Ubuntu.sh └── init_Ubuntu_hhvm.sh ├── install_lnmp.sh ├── install_ltmh.sh ├── options.conf ├── shell ├── GraphicsMagick.sh ├── ImageMagick.sh ├── ZendGuardLoader.sh ├── apcu.sh ├── eaccelerator-0.9.sh ├── eaccelerator-1.0-dev.sh ├── eaccelerator.sh ├── hhvm-3.1_Debian.sh ├── hhvm-3.3_Debian.sh ├── hhvm_CentOS.sh ├── hhvm_Ubuntu.sh ├── ioncube.sh ├── jemalloc.sh ├── mariadb-10.0.sh ├── mariadb-5.5.sh ├── memcached.sh ├── mysql-5.5.sh ├── mysql-5.6.sh ├── nginx.sh ├── nginx_hhvm.sh ├── ngx_pagespeed.sh ├── php-5.3.sh ├── php-5.4.sh ├── php-5.5.sh ├── php-mysql-client.sh ├── phpmyadmin.sh ├── pureftpd.sh ├── redis.sh ├── tengine.sh ├── tengine_hhvm.sh ├── tengine_hhvm_centos.sh ├── xcache.sh └── zendopcache.sh ├── tools ├── check502.sh ├── check_os.sh ├── download.sh ├── get_ip_area.py ├── get_local_ip.py ├── get_public_ip.py ├── init.sh ├── init_hhvm.sh ├── remove_disable_function.sh ├── reset_mysql_root_password.sh └── waf │ ├── config.lua │ ├── init.lua │ ├── install.sh │ ├── waf.lua │ └── wafconf │ ├── args │ ├── cookie │ ├── post │ ├── url │ ├── user-agent │ └── whiteurl ├── uninstall.sh ├── up_php.sh ├── up_phpmyadmin.sh ├── up_redis.sh ├── up_web_ser.sh ├── vhost.sh └── vhost_hhvm.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # http://www.gnu.org/software/automake 2 | 3 | Makefile.in 4 | 5 | # http://www.gnu.org/software/autoconf 6 | 7 | /autom4te.cache 8 | /aclocal.m4 9 | /compile 10 | /configure 11 | /depcomp 12 | /install-sh 13 | /missing 14 | /stamp-h1 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 ielnehc 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ltmh 2 | ==== 3 | 4 | In CentOS / Red Hat Debian and Ubuntu is a complete automation LTMH / LNMH / LNMP / LTMP installation script 5 | This script is free collection of shell scripts for rapid deployment of `LTMH`/`LNMH`/`LTMP`/ `LNMP` stacks (`Linux`, `Tengine`/`Nginx`, `MySQL`/`MariaDB`/`PHP`/ `hhvm`) for CentOS/Redhat Debian and Ubuntu. 6 | 7 | Script features: 8 | - Constant updates 9 | - Source compiler installation, most source code is the latest stable version, and downloaded from the official website 10 | - Fixes some security issues 11 | - You can freely choose to install database version (MySQL-5.6, MySQL-5.5, MariaDB-10.0, MariaDB-5.5) 12 | - You can freely choose to install PHP version (php-5.5, php-5.4, php-5.3) 13 | - You can freely choose to install hhvm version (hhvm3.1.0,hhvm3.3.0) 14 | - You can freely choose to install Tengine or Nginx 15 | - According to their needs can to install ngx_pagespeed 16 | - According to their needs can to install ZendOPcache, xcache, APCU, eAccelerator, ionCube and ZendGuardLoader (php-5.4, php-5.3) 17 | - According to their needs can to install Pureftpd, phpMyAdmin 18 | - According to their needs can to install memcached, redis 19 | - According to their needs can to optimize Nginx and Tengine with jemalloc or tcmalloc 20 | 21 | Tengien default has been compiled ngx_lua_waf (Web Firewall), dynamically loaded modules as needed 22 | - You can open ngx_lua_waf the necessary functions to : 23 | Prevent sql injection, local contain, some overflow, fuzzing test, xss, SSRF and other web attacks 24 | Prevent svn / backup class file leak 25 | ApacheBench prevent attacks like stress testing tool 26 | Shielding common hacking tools to scan, the scanner 27 | Abnormal network requests shield 28 | Shielding Pictures directory php execute permissions Accessories 29 | Upload prevent webshell 30 | 31 | 32 | - A key to add a virtual host 33 | - Nginx/Tengine, PHP,HHVM, Redis, phpMyAdmin upgrade script provided 34 | - A key backup support,Automatic qiniu.com cloud storage space 35 | 36 | ## How to use : 37 | ##LTMH / LNMH only supports 64-bit operating system (Ubuntu 14.04, Debian7.X,Centos6.x) 38 | 39 | ```bash 40 | yum -y install wget screen # for CentOS/Redhat 41 | #apt-get -y install wget screen # for Debian/Ubuntu 42 | wget -c http://soft.hhvmc.com/dl/latest/ltmh.tar.gz 43 | tar xzf ltmh.tar.gz 44 | cd ltmh 45 | chmod 777 install_lnmp.sh install_ltmh.sh 46 | ##You can choose to install:Tengine+Mysql+HHVM,Nginx+Mysql+HHVM (Execute scripts ./install_ltmh.sh ) 47 | ###You can choose to install:Nginx+Mysql+php,Tengine+Mysql+Php (Execute scripts ./install_lnmp.sh ) 48 | ##Prevent interrupt the installation process. If the network is down, you can execute commands `screen -r ltmh` network reconnect the installation window. 49 | screen -S ltmh 50 | ./install_lnmp.sh or ./install_ltmh.sh 51 | ``` 52 | 53 | ## How to add a virtual host 54 | 55 | ```bash 56 | ./vhost.sh 57 | ./vhost_hhvm.sh 58 | ``` 59 | 60 | ## Hown to backup 61 | 62 | ```bash 63 | ./backup.sh ##Backup Initialization 64 | ``` 65 | 66 | ## How to manage service 67 | Nginx/Tengine: 68 | ```bash 69 | service nginx {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest} 70 | ##tengine:/usr/local/nginx/sbin/nginx -t ,-v ,-m , -V 71 | ##tengine:/usr/local/nginx/sbin/dso_tool --add-module=...... 72 | ``` 73 | MySQL/MariaDB/Percona: 74 | ```bash 75 | service mysqld {start|stop|restart|reload|force-reload|status} 76 | ``` 77 | PHP: 78 | ```bash 79 | service php-fpm {start|stop|force-quit|restart|reload|status} 80 | ``` 81 | HHVM: 82 | ```bash 83 | service hhvm {start|stop|restart|reload|status} 84 | ``` 85 | Pure-Ftpd: 86 | ```bash 87 | service pureftpd {start|stop|restart|condrestart|status} 88 | ``` 89 | Redis: 90 | ```bash 91 | service redis-server {start|stop|status|restart|condrestart|try-restart|reload|force-reload} 92 | ``` 93 | Memcached: 94 | ```bash 95 | service memcached {start|stop|status|restart|reload|force-reload} 96 | ``` 97 | 98 | ## How to upgrade 99 | ```bash 100 | ./up_php.sh # upgrade PHP 101 | ./up_web_ser.sh # upgrade Nginx/Tengine 102 | ./up_redis.sh # upgrade Redis 103 | ./up_phpmyadmin.sh # upgrade phpMyAdmin 104 | ``` 105 | 106 | ## How to uninstall 107 | 108 | ```bash 109 | ./uninstall.sh 110 | ``` 111 | 112 | For feedback, questions, and to follow the progress of the project:
113 | LTMH the latest source install script:http://www.hhvmc.com/thread-17-1-1.html
114 | Thank you very much http://blog.linuxeye.com of yeho, learn a lot, learned a lot of things, thanks again! 115 | -------------------------------------------------------------------------------- /backup/qrsync: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ielnehc/ltmh/3941431f3acffebdd62df5047c34b1e94be6dabd/backup/qrsync -------------------------------------------------------------------------------- /backup/tool.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | qiniu_space=http://$space.qiniudn.com 3 | backup_database_name=Database_$(date +"%Y%m%d").tar.gz 4 | Web_backup_name=Website_$(date +"%Y%m%d").tar.gz 5 | configuration_file=Nginx_conf_$(date +"%Y%m%d").tar.gz 6 | Compressed_file_name=Data_$(date +"%Y%m%d").zip 7 | 8 | daybc=day 9 | old_backup_data_file_name=Data_$(date -d -$expired_days$daybc +"%Y%m%d").zip 10 | 11 | if [ ! -f $local_bankup/$old_backup_data_file_name ]; then 12 | rm $local_bankup/$old_backup_data_file_name 13 | fi 14 | 15 | cd $local_bankup 16 | $mysqldump_dir -u$mysql_user -p$mysql_passwd $database_name>backup.sql 17 | 18 | cd $local_bankup 19 | tar zcf $local_bankup/$backup_database_name backup.sql 20 | rm $local_bankup/backup.sql 21 | 22 | cd $home_dir 23 | tar zcf $local_bankup/$Web_backup_name * 24 | 25 | cd $nginx_configuration_file 26 | tar zcf $local_bankup/$configuration_file * 27 | 28 | cd $local_bankup 29 | zip -q -r -P $backup_file_compression_password $Compressed_file_name $Web_backup_name $backup_database_name $configuration_file 30 | 31 | rm $Web_backup_name $backup_database_name $configuration_file 32 | 33 | SJS=$(cat /proc/sys/kernel/random/uuid) 34 | 35 | mkdir -p $local_bankup/bf_tmp/$SJS 36 | cp $Compressed_file_name $local_bankup/bf_tmp/$SJS/$Compressed_file_name 37 | 38 | $scriptdir/qrsync -skipsym $scriptdir/$con_file 39 | 40 | echo "The site data backup, the backup download address $qiniu_space/$SJS/$Compressed_file_name" >> backup_ok.txt 41 | 42 | rm backup_ok.txt 43 | cd $local_bankup 44 | rm -rf $local_bankup/bf_tmp -------------------------------------------------------------------------------- /conf/301.conf: -------------------------------------------------------------------------------- 1 | #This is a example 2 | #If you want domain.com 301 return to www.domain.com 3 | server { 4 | server_name domain.com; 5 | return 301 $scheme://www.domain.com$request_uri; 6 | } 7 | server { 8 | server_name www.domain.com; 9 | [...] 10 | } -------------------------------------------------------------------------------- /conf/config.inc.php: -------------------------------------------------------------------------------- 1 | . 9 | * 10 | * @package PhpMyAdmin 11 | */ 12 | 13 | /* 14 | * This is needed for cookie based authentication to encrypt password in 15 | * cookie 16 | */ 17 | $cfg['blowfish_secret'] = 'HHVMCOM'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */ 18 | 19 | /* 20 | * Servers configuration 21 | */ 22 | $i = 0; 23 | 24 | /* 25 | * First server 26 | */ 27 | $i++; 28 | /* Authentication type */ 29 | $cfg['Servers'][$i]['auth_type'] = 'cookie'; 30 | /* Server parameters */ 31 | $cfg['Servers'][$i]['host'] = 'localhost'; 32 | $cfg['Servers'][$i]['connect_type'] = 'tcp'; 33 | $cfg['Servers'][$i]['compress'] = false; 34 | /* Select mysql if your server does not have mysqli */ 35 | $cfg['Servers'][$i]['extension'] = 'mysqli'; 36 | $cfg['Servers'][$i]['AllowNoPassword'] = false; 37 | 38 | /* 39 | * phpMyAdmin configuration storage settings. 40 | */ 41 | 42 | /* User used to manipulate with storage */ 43 | // $cfg['Servers'][$i]['controlhost'] = ''; 44 | // $cfg['Servers'][$i]['controlport'] = ''; 45 | // $cfg['Servers'][$i]['controluser'] = 'pma'; 46 | // $cfg['Servers'][$i]['controlpass'] = 'pmapass'; 47 | 48 | /* Storage database and tables */ 49 | // $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin'; 50 | // $cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark'; 51 | // $cfg['Servers'][$i]['relation'] = 'pma__relation'; 52 | // $cfg['Servers'][$i]['table_info'] = 'pma__table_info'; 53 | // $cfg['Servers'][$i]['table_coords'] = 'pma__table_coords'; 54 | // $cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages'; 55 | // $cfg['Servers'][$i]['column_info'] = 'pma__column_info'; 56 | // $cfg['Servers'][$i]['history'] = 'pma__history'; 57 | // $cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs'; 58 | // $cfg['Servers'][$i]['tracking'] = 'pma__tracking'; 59 | // $cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords'; 60 | // $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig'; 61 | // $cfg['Servers'][$i]['recent'] = 'pma__recent'; 62 | // $cfg['Servers'][$i]['users'] = 'pma__users'; 63 | // $cfg['Servers'][$i]['usergroups'] = 'pma__usergroups'; 64 | // $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding'; 65 | /* Contrib / Swekey authentication */ 66 | // $cfg['Servers'][$i]['auth_swekey_config'] = '/etc/swekey-pma.conf'; 67 | 68 | /* 69 | * End of servers configuration 70 | */ 71 | 72 | /* 73 | * Directories for saving/loading files from server 74 | */ 75 | $cfg['UploadDir'] = 'upload'; 76 | $cfg['SaveDir'] = 'save'; 77 | 78 | /** 79 | * Defines whether a user should be displayed a "show all (records)" 80 | * button in browse mode or not. 81 | * default = false 82 | */ 83 | //$cfg['ShowAll'] = true; 84 | 85 | /** 86 | * Number of rows displayed when browsing a result set. If the result 87 | * set contains more rows, "Previous" and "Next". 88 | * default = 30 89 | */ 90 | //$cfg['MaxRows'] = 50; 91 | 92 | /** 93 | * disallow editing of binary fields 94 | * valid values are: 95 | * false allow editing 96 | * 'blob' allow editing except for BLOB fields 97 | * 'noblob' disallow editing except for BLOB fields 98 | * 'all' disallow editing 99 | * default = blob 100 | */ 101 | //$cfg['ProtectBinary'] = 'false'; 102 | 103 | /** 104 | * Default language to use, if not browser-defined or user-defined 105 | * (you find all languages in the locale folder) 106 | * uncomment the desired line: 107 | * default = 'en' 108 | */ 109 | //$cfg['DefaultLang'] = 'en'; 110 | //$cfg['DefaultLang'] = 'de'; 111 | 112 | /** 113 | * default display direction (horizontal|vertical|horizontalflipped) 114 | */ 115 | //$cfg['DefaultDisplay'] = 'vertical'; 116 | 117 | 118 | /** 119 | * How many columns should be used for table display of a database? 120 | * (a value larger than 1 results in some information being hidden) 121 | * default = 1 122 | */ 123 | //$cfg['PropertiesNumColumns'] = 2; 124 | 125 | /** 126 | * Set to true if you want DB-based query history.If false, this utilizes 127 | * JS-routines to display query history (lost by window close) 128 | * 129 | * This requires configuration storage enabled, see above. 130 | * default = false 131 | */ 132 | //$cfg['QueryHistoryDB'] = true; 133 | 134 | /** 135 | * When using DB-based query history, how many entries should be kept? 136 | * 137 | * default = 25 138 | */ 139 | //$cfg['QueryHistoryMax'] = 100; 140 | 141 | /** 142 | * Should error reporting be enabled for JavaScript errors 143 | * 144 | * default = 'ask' 145 | */ 146 | //$cfg['SendErrorReports'] = 'ask'; 147 | 148 | /* 149 | * You can find more configuration options in the documentation 150 | * in the doc/ folder or at . 151 | */ 152 | ?> -------------------------------------------------------------------------------- /conf/dabr.conf: -------------------------------------------------------------------------------- 1 | location / { 2 | if (!-e $request_filename) { 3 | rewrite ^/(.*)$ /index.php?q=$1 last; 4 | } 5 | } -------------------------------------------------------------------------------- /conf/dedecms.conf: -------------------------------------------------------------------------------- 1 | location / { 2 | rewrite "^/index.html$" /index.php last; 3 | rewrite "^/list-([0-9]+)\.html$" /plus/list.php?tid=$1 last; 4 | rewrite "^/list-([0-9]+)-([0-9]+)-([0-9]+)\.html$" /plus/list.php?tid=$1&totalresult=$2&PageNo=$3 last; 5 | rewrite "^/view-([0-9]+)-1\.html$" /plus/view.php?arcID=$1 last; 6 | rewrite "^/view-([0-9]+)-([0-9]+)\.html$" /plus/view.php?aid=$1&pageno=$2 last; 7 | rewrite "^/tags.html$" /tags.php last; 8 | rewrite "^/tag-([0-9]+)-([0-9]+)\.html$" /tags.php?/$1/$2/ last; 9 | break; 10 | } -------------------------------------------------------------------------------- /conf/discuz.conf: -------------------------------------------------------------------------------- 1 | location / { 2 | rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last; 3 | rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last; 4 | rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last; 5 | rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last; 6 | rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last; 7 | rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last; 8 | rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last; 9 | rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last; 10 | rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last; 11 | if (!-e $request_filename) { 12 | return 404; 13 | } 14 | 15 | 16 | 17 | 18 | } -------------------------------------------------------------------------------- /conf/discuzx.conf: -------------------------------------------------------------------------------- 1 | rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last; 2 | rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last; 3 | rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last; 4 | rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last; 5 | rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last; 6 | rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last; 7 | rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last; 8 | rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last; 9 | rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last; 10 | if (!-e $request_filename) { 11 | return 404; 12 | } -------------------------------------------------------------------------------- /conf/discuzx2.conf: -------------------------------------------------------------------------------- 1 | location /bbs/ { 2 | rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last; 3 | rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last; 4 | rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last; 5 | rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last; 6 | rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last; 7 | rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last; 8 | rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last; 9 | rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last; 10 | rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last; 11 | if (!-e $request_filename) { 12 | return 404; 13 | } 14 | } -------------------------------------------------------------------------------- /conf/drupal.conf: -------------------------------------------------------------------------------- 1 | if (!-e $request_filename) { 2 | rewrite ^/(.*)$ /index.php?q=$1 last; 3 | } -------------------------------------------------------------------------------- /conf/ecshop.conf: -------------------------------------------------------------------------------- 1 | if (!-e $request_filename) 2 | { 3 | rewrite "^/index\.html" /index.php last; 4 | rewrite "^/category$" /index.php last; 5 | rewrite "^/feed-c([0-9]+)\.xml$" /feed.php?cat=$1 last; 6 | rewrite "^/feed-b([0-9]+)\.xml$" /feed.php?brand=$1 last; 7 | rewrite "^/feed\.xml$" /feed.php last; 8 | rewrite "^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5&page=$6&sort=$7&order=$8 last; 9 | rewrite "^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*)\.html$" /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5 last; 10 | rewrite "^/category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /category.php?id=$1&brand=$2&page=$3&sort=$4&order=$5 last; 11 | rewrite "^/category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$" /category.php?id=$1&brand=$2&page=$3 last; 12 | rewrite "^/category-([0-9]+)-b([0-9]+)(.*)\.html$" /category.php?id=$1&brand=$2 last; 13 | rewrite "^/category-([0-9]+)(.*)\.html$" /category.php?id=$1 last; 14 | rewrite "^/goods-([0-9]+)(.*)\.html" /goods.php?id=$1 last; 15 | rewrite "^/article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /article_cat.php?id=$1&page=$2&sort=$3&order=$4 last; 16 | rewrite "^/article_cat-([0-9]+)-([0-9]+)(.*)\.html$" /article_cat.php?id=$1&page=$2 last; 17 | rewrite "^/article_cat-([0-9]+)(.*)\.html$" /article_cat.php?id=$1 last; 18 | rewrite "^/article-([0-9]+)(.*)\.html$" /article.php?id=$1 last; 19 | rewrite "^/brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\.html" /brand.php?id=$1&cat=$2&page=$3&sort=$4&order=$5 last; 20 | rewrite "^/brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html" /brand.php?id=$1&cat=$2&page=$3 last; 21 | rewrite "^/brand-([0-9]+)-c([0-9]+)(.*)\.html" /brand.php?id=$1&cat=$2 last; 22 | rewrite "^/brand-([0-9]+)(.*)\.html" /brand.php?id=$1 last; 23 | rewrite "^/tag-(.*)\.html" /search.php?keywords=$1 last; 24 | rewrite "^/snatch-([0-9]+)\.html$" /snatch.php?id=$1 last; 25 | rewrite "^/group_buy-([0-9]+)\.html$" /group_buy.php?act=view&id=$1 last; 26 | rewrite "^/auction-([0-9]+)\.html$" /auction.php?act=view&id=$1 last; 27 | rewrite "^/exchange-id([0-9]+)(.*)\.html$" /exchange.php?id=$1&act=view last; 28 | rewrite "^/exchange-([0-9]+)-min([0-9]+)-max([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /exchange.php?cat_id=$1&integral_min=$2&integral_max=$3&page=$4&sort=$5&order=$6 last; 29 | rewrite ^/exchange-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /exchange.php?cat_id=$1&page=$2&sort=$3&order=$4 last; 30 | rewrite "^/exchange-([0-9]+)-([0-9]+)(.*)\.html$" /exchange.php?cat_id=$1&page=$2 last; 31 | rewrite "^/exchange-([0-9]+)(.*)\.html$" /exchange.php?cat_id=$1 last; 32 | } -------------------------------------------------------------------------------- /conf/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LTMH by Andy 5 | 6 | 7 | 8 | 9 | 23 | 24 | 25 |
26 |
Congratulations, LTMH install package installed successfully!
27 |
LTMH
28 |
LTMH is a Linux Shell can be prepared with as Debian, ubuntu centos VPS) or independent host installation LTMH (Tengine, nginx, mysql, hhvm, phpMyAdmin) Shell scripting runtime environment.。
29 | 30 |

view the local environment:Probe phpinfo phpMyAdmin

31 | 32 |

More LTMH a key installation package information, please visit: http://www.hhvmc.com

33 |

LTMH a key installation package Feedback please visit: http://www.hhvmc.com/forum-36-1.html

34 |

VPS tutorials: http://www.hhvmc.com/forum-42-1.html

35 |

LTMH by Andy

36 |
37 | 38 | -------------------------------------------------------------------------------- /conf/memcached-init: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # 3 | # memcached: MemCached Daemon 4 | # 5 | # chkconfig: - 90 25 6 | # description: MemCached Daemon 7 | # 8 | ### BEGIN INIT INFO 9 | # Provides: memcached 10 | # Required-Start: $syslog 11 | # Required-Stop: $syslog 12 | # Should-Start: $local_fs 13 | # Should-Stop: $local_fs 14 | # Default-Start: 2 3 4 5 15 | # Default-Stop: 0 1 6 16 | # Short-Description: memcached - Memory caching daemon 17 | # Description: memcached - Memory caching daemon 18 | ### END INIT INFO 19 | 20 | PORT=11211 21 | USER=root 22 | MAXCONN=1024 23 | CACHESIZE=64 24 | OPTIONS="" 25 | 26 | RETVAL=0 27 | prog="memcached" 28 | 29 | start () { 30 | echo -n $"Starting $prog: " 31 | memcached -d -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN -P /var/run/memcached.pid $OPTIONS 32 | RETVAL=$? 33 | echo 34 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached 35 | } 36 | stop () { 37 | echo -n $"Stopping $prog: " 38 | kill `cat /var/run/memcached.pid` 39 | RETVAL=$? 40 | echo 41 | if [ $RETVAL -eq 0 ] ; then 42 | rm -f /var/lock/subsys/memcached 43 | rm -f /var/run/memcached.pid 44 | fi 45 | } 46 | 47 | restart () { 48 | stop 49 | start 50 | } 51 | 52 | 53 | # See how we were called. 54 | case "$1" in 55 | start) 56 | start 57 | ;; 58 | stop) 59 | stop 60 | ;; 61 | restart|reload) 62 | restart 63 | ;; 64 | *) 65 | echo $"Usage: $0 {start|stop|status|restart|reload}" 66 | exit 1 67 | esac 68 | 69 | exit $? 70 | -------------------------------------------------------------------------------- /conf/memcached.php: -------------------------------------------------------------------------------- 1 | connect("127.0.0.1", 11211) or die ("Could not connect"); 6 | 7 | //显示版本 8 | $version = $mem->getVersion(); 9 | echo "Memcached Server version: ".$version."
"; 10 | 11 | //保存数据 12 | $mem->set('key1', 'This is first value', 0, 60); 13 | $val = $mem->get('key1'); 14 | echo "Get key1 value: " . $val ."
"; 15 | 16 | //替换数据 17 | $mem->replace('key1', 'This is replace value', 0, 60); 18 | $val = $mem->get('key1'); 19 | echo "Get key1 value: " . $val . "
"; 20 | 21 | //保存数组 22 | $arr = array('aaa', 'bbb', 'ccc', 'ddd'); 23 | $mem->set('key2', $arr, 0, 60); 24 | $val2 = $mem->get('key2'); 25 | echo "Get key2 value: "; 26 | print_r($val2); 27 | echo "
"; 28 | 29 | //删除数据 30 | $mem->delete('key1'); 31 | $val = $mem->get('key1'); 32 | echo "Get key1 value: " . $val . "
"; 33 | 34 | //清除所有数据 35 | $mem->flush(); 36 | $val2 = $mem->get('key2'); 37 | echo "Get key2 value: "; 38 | print_r($val2); 39 | echo "
"; 40 | 41 | //关闭连接 42 | $mem->close(); 43 | ?> 44 | Memcached Test tools for LTMH一键安装包 Technical support -------------------------------------------------------------------------------- /conf/nginx.conf: -------------------------------------------------------------------------------- 1 | user www www; 2 | worker_processes 4; 3 | 4 | error_log /home/wwwlogs/error_nginx.log crit; 5 | pid /var/run/nginx.pid; 6 | worker_rlimit_nofile 51200; 7 | 8 | events { 9 | use epoll; 10 | worker_connections 51200; 11 | } 12 | 13 | http { 14 | include mime.types; 15 | default_type application/octet-stream; 16 | server_names_hash_bucket_size 128; 17 | client_header_buffer_size 32k; 18 | large_client_header_buffers 4 32k; 19 | client_max_body_size 50m; 20 | sendfile on; 21 | tcp_nopush on; 22 | keepalive_timeout 120; 23 | server_tokens off; 24 | tcp_nodelay on; 25 | 26 | fastcgi_connect_timeout 300; 27 | fastcgi_send_timeout 300; 28 | fastcgi_read_timeout 300; 29 | fastcgi_buffer_size 64k; 30 | fastcgi_buffers 4 64k; 31 | fastcgi_busy_buffers_size 128k; 32 | fastcgi_temp_file_write_size 128k; 33 | fastcgi_intercept_errors on; 34 | 35 | gzip on; 36 | gzip_disable "msie6"; 37 | gzip_vary on; 38 | gzip_comp_level 2; 39 | gzip_min_length 1k; 40 | gzip_buffers 4 16k; 41 | gzip_http_version 1.1; 42 | gzip_types text/plain application/x-javascript text/css application/xml; 43 | 44 | ###################pureftpd AND phpmyadmin############################ 45 | server { 46 | listen 80; 47 | server_name _; 48 | access_log /home/wwwlogs/access_nginx.log combined; 49 | root /home/wwwroot/default; 50 | index index.html index.php; 51 | if ( $query_string ~* ".*[\;'\<\>].*" ){ 52 | return 404; 53 | } 54 | 55 | location ~ .*\.(php|php5)?$ { 56 | #fastcgi_pass remote_php_ip:9000; 57 | fastcgi_pass unix:/dev/shm/php-cgi.sock; 58 | fastcgi_index index.php; 59 | include fastcgi.conf; 60 | } 61 | 62 | location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ { 63 | expires 30d; 64 | } 65 | 66 | location ~ .*\.(js|css)?$ { 67 | expires 7d; 68 | } 69 | } 70 | 71 | ##########################vhost##################################### 72 | include vhost/*.conf; 73 | } 74 | -------------------------------------------------------------------------------- /conf/nginx_h.conf: -------------------------------------------------------------------------------- 1 | user www www; 2 | 3 | worker_processes auto; 4 | 5 | error_log /home/wwwlogs/nginx_error.log crit; 6 | 7 | pid /usr/local/nginx/logs/nginx.pid; 8 | 9 | #Specifies the value for maximum file descriptors that can be opened by this process. 10 | worker_rlimit_nofile 51200; 11 | 12 | 13 | 14 | events 15 | { 16 | use epoll; 17 | worker_connections 51200; 18 | multi_accept on; 19 | } 20 | 21 | http 22 | { 23 | include mime.types; 24 | default_type application/octet-stream; 25 | server_names_hash_bucket_size 128; 26 | client_header_buffer_size 32k; 27 | large_client_header_buffers 4 32k; 28 | client_max_body_size 50m; 29 | 30 | sendfile on; 31 | tcp_nopush on; 32 | keepalive_timeout 60; 33 | tcp_nodelay on; 34 | 35 | fastcgi_connect_timeout 300; 36 | fastcgi_send_timeout 300; 37 | fastcgi_read_timeout 300; 38 | fastcgi_buffer_size 64k; 39 | fastcgi_buffers 4 64k; 40 | fastcgi_busy_buffers_size 128k; 41 | fastcgi_temp_file_write_size 256k; 42 | fastcgi_intercept_errors on; 43 | 44 | gzip on; 45 | gzip_min_length 1k; 46 | gzip_buffers 4 16k; 47 | gzip_http_version 1.0; 48 | gzip_comp_level 2; 49 | gzip_types text/plain application/x-javascript text/css application/xml; 50 | gzip_vary on; 51 | gzip_proxied expired no-cache no-store private auth; 52 | gzip_disable "MSIE [1-6]\."; 53 | 54 | #limit_conn_zone $binary_remote_addr zone=perip:10m; 55 | ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section. 56 | 57 | #lua_package_path "/usr/local/nginx/conf/waf/?.lua"; 58 | #lua_shared_dict limit 10m; 59 | #init_by_lua_file /usr/local/nginx/conf/waf/init.lua; 60 | #access_by_lua_file /usr/local/nginx/conf/waf/waf.lua; 61 | 62 | server_tokens off; 63 | #log format 64 | log_format access '$remote_addr - $remote_user [$time_local] "$request" ' 65 | '$status $body_bytes_sent "$http_referer" ' 66 | '"$http_user_agent" $http_x_forwarded_for'; 67 | 68 | server 69 | { 70 | listen 80 default; 71 | #listen [::]:80 default ipv6only=on; 72 | server_name www.hhvmc.com; 73 | index index.html index.htm index.php; 74 | root /home/wwwroot/default; 75 | 76 | #error_page 404 /404.html; 77 | location ~ [^/]\.php(/|$) 78 | { 79 | # comment try_files $uri =404; to enable pathinfo 80 | try_files $uri =404; 81 | #fastcgi_pass 127.0.0.1:9000; 82 | fastcgi_pass unix:/var/run/hhvm/server.sock; 83 | fastcgi_index index.php; 84 | include fastcgi.conf; 85 | #include pathinfo.conf; 86 | fastcgi_intercept_errors on; 87 | #error_page 500 501 502 503 = @fpm; 88 | } 89 | 90 | 91 | 92 | location /nginx_status { 93 | stub_status on; 94 | access_log off; 95 | } 96 | 97 | location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ 98 | { 99 | expires 30d; 100 | } 101 | 102 | location ~ .*\.(js|css)?$ 103 | { 104 | expires 24h; 105 | } 106 | 107 | access_log /home/wwwlogs/access.log access; 108 | } 109 | include vhost/*.conf; 110 | } 111 | 112 | -------------------------------------------------------------------------------- /conf/nginx_n.conf: -------------------------------------------------------------------------------- 1 | user www www; 2 | 3 | worker_processes auto; 4 | 5 | error_log /home/wwwlogs/nginx_error.log crit; 6 | 7 | pid /usr/local/nginx/logs/nginx.pid; 8 | 9 | #Specifies the value for maximum file descriptors that can be opened by this process. 10 | worker_rlimit_nofile 51200; 11 | 12 | 13 | 14 | events 15 | { 16 | use epoll; 17 | worker_connections 51200; 18 | multi_accept on; 19 | } 20 | 21 | http 22 | { 23 | include mime.types; 24 | default_type application/octet-stream; 25 | server_names_hash_bucket_size 128; 26 | client_header_buffer_size 32k; 27 | large_client_header_buffers 4 32k; 28 | client_max_body_size 50m; 29 | 30 | sendfile on; 31 | tcp_nopush on; 32 | keepalive_timeout 60; 33 | tcp_nodelay on; 34 | 35 | fastcgi_connect_timeout 300; 36 | fastcgi_send_timeout 300; 37 | fastcgi_read_timeout 300; 38 | fastcgi_buffer_size 64k; 39 | fastcgi_buffers 4 64k; 40 | fastcgi_busy_buffers_size 128k; 41 | fastcgi_temp_file_write_size 256k; 42 | fastcgi_intercept_errors on; 43 | 44 | gzip on; 45 | gzip_min_length 1k; 46 | gzip_buffers 4 16k; 47 | gzip_http_version 1.0; 48 | gzip_comp_level 2; 49 | gzip_types text/plain application/x-javascript text/css application/xml; 50 | gzip_vary on; 51 | gzip_proxied expired no-cache no-store private auth; 52 | gzip_disable "MSIE [1-6]\."; 53 | 54 | #limit_conn_zone $binary_remote_addr zone=perip:10m; 55 | ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section. 56 | 57 | server_tokens off; 58 | #log format 59 | log_format access '$remote_addr - $remote_user [$time_local] "$request" ' 60 | '$status $body_bytes_sent "$http_referer" ' 61 | '"$http_user_agent" $http_x_forwarded_for'; 62 | 63 | server 64 | { 65 | listen 80 default; 66 | #listen [::]:80 default ipv6only=on; 67 | server_name www.hhvmc.com; 68 | index index.html index.htm index.php; 69 | root /home/wwwroot/default; 70 | 71 | #error_page 404 /404.html; 72 | location ~ [^/]\.php(/|$) 73 | { 74 | # comment try_files $uri =404; to enable pathinfo 75 | try_files $uri =404; 76 | #fastcgi_pass 127.0.0.1:9000; 77 | fastcgi_pass unix:/var/run/hhvm/server.sock; 78 | #fastcgi_pass unix:/tmp/php-cgi.sock; 79 | fastcgi_index index.php; 80 | include fastcgi.conf; 81 | #include pathinfo.conf; 82 | fastcgi_intercept_errors on; 83 | #error_page 500 501 502 503 = @fpm; 84 | } 85 | 86 | 87 | 88 | location /nginx_status { 89 | stub_status on; 90 | access_log off; 91 | } 92 | 93 | location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ 94 | { 95 | expires 30d; 96 | } 97 | 98 | location ~ .*\.(js|css)?$ 99 | { 100 | expires 12h; 101 | } 102 | 103 | access_log /home/wwwlogs/access.log access; 104 | } 105 | include vhost/*.conf; 106 | } 107 | 108 | -------------------------------------------------------------------------------- /conf/none.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ielnehc/ltmh/3941431f3acffebdd62df5047c34b1e94be6dabd/conf/none.conf -------------------------------------------------------------------------------- /conf/pathinfo.conf: -------------------------------------------------------------------------------- 1 | fastcgi_split_path_info ^(.+?\.php)(/.*)$; 2 | set $path_info $fastcgi_path_info; 3 | fastcgi_param PATH_INFO $path_info; 4 | try_files $fastcgi_script_name =404; -------------------------------------------------------------------------------- /conf/php-fpm.conf: -------------------------------------------------------------------------------- 1 | 2 | All relative paths in this config are relative to php's install prefix 3 |
4 | Pid file 5 | /usr/local/php/logs/php-fpm.pid 6 | Error log file 7 | /usr/local/php/logs/php-fpm.log 8 | Log level 9 | notice 10 | When this amount of php processes exited with SIGSEGV or SIGBUS ... 11 | 10 12 | ... in a less than this interval of time, a graceful restart will be initiated. 13 | Useful to work around accidental curruptions in accelerator's shared memory. 14 | 1m 15 | Time limit on waiting child's reaction on signals from master 16 | 5s 17 | Set to 'no' to debug fpm 18 | yes 19 |
20 | 21 |
22 | Name of pool. Used in logs and stats. 23 | default 24 | Address to accept fastcgi requests on. 25 | Valid syntax is 'ip.ad.re.ss:port' or just 'port' or '/path/to/unix/socket' 26 | /tmp/php-cgi.sock 27 | 28 | Set listen(2) backlog 29 | -1 30 | Set permissions for unix socket, if one used. 31 | In Linux read/write permissions must be set in order to allow connections from web server. 32 | Many BSD-derrived systems allow connections regardless of permissions. 33 | 34 | 35 | 0666 36 | 37 | Additional php.ini defines, specific to this pool of workers. 38 | 39 | /usr/sbin/sendmail -t -i 40 | 1 41 | 42 | Unix user of processes 43 | www 44 | Unix group of processes 45 | www 46 | Process manager settings 47 | 48 | Sets style of controling worker process count. 49 | Valid values are 'static' and 'apache-like' 50 | static 51 | Sets the limit on the number of simultaneous requests that will be served. 52 | Equivalent to Apache MaxClients directive. 53 | Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi 54 | Used with any pm_style. 55 | 5 56 | Settings group for 'apache-like' pm style 57 | 58 | Sets the number of server processes created on startup. 59 | Used only when 'apache-like' pm_style is selected 60 | 20 61 | Sets the desired minimum number of idle server processes. 62 | Used only when 'apache-like' pm_style is selected 63 | 5 64 | Sets the desired maximum number of idle server processes. 65 | Used only when 'apache-like' pm_style is selected 66 | 35 67 | 68 | 69 | The timeout (in seconds) for serving a single request after which the worker process will be terminated 70 | Should be used when 'max_execution_time' ini option does not stop script execution for some reason 71 | '0s' means 'off' 72 | 0s 73 | The timeout (in seconds) for serving of single request after which a php backtrace will be dumped to slow.log file 74 | '0s' means 'off' 75 | 0s 76 | The log file for slow requests 77 | logs/slow.log 78 | Set open file desc rlimit 79 | 51200 80 | Set max core size rlimit 81 | 0 82 | Chroot to this directory at the start, absolute path 83 | 84 | Chdir to this directory at the start, absolute path 85 | 86 | Redirect workers' stdout and stderr into main error log. 87 | If not set, they will be redirected to /dev/null, according to FastCGI specs 88 | yes 89 | How much requests each process should execute before respawn. 90 | Useful to work around memory leaks in 3rd party libraries. 91 | For endless request processing please specify 0 92 | Equivalent to PHP_FCGI_MAX_REQUESTS 93 | 10240 94 | Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect. 95 | Equivalent to FCGI_WEB_SERVER_ADDRS environment in original php.fcgi (5.2.2+) 96 | Makes sense only with AF_INET listening socket. 97 | 127.0.0.1 98 | Pass environment variables like LD_LIBRARY_PATH 99 | All $VARIABLEs are taken from current environment 100 | 101 | $HOSTNAME 102 | /usr/local/bin:/usr/bin:/bin 103 | /tmp 104 | /tmp 105 | /tmp 106 | $OSTYPE 107 | $MACHTYPE 108 | 2 109 | 110 |
111 |
112 |
113 | -------------------------------------------------------------------------------- /conf/phpinfo.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /conf/phpwind.conf: -------------------------------------------------------------------------------- 1 | location / { 2 | rewrite ^(.*)-htm-(.*)$ $1.php?$2 last; 3 | rewrite ^(.*)/simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2 last; 4 | } -------------------------------------------------------------------------------- /conf/proxy.conf: -------------------------------------------------------------------------------- 1 | proxy_connect_timeout 300s; 2 | proxy_send_timeout 900; 3 | proxy_read_timeout 900; 4 | proxy_buffer_size 32k; 5 | proxy_buffers 4 32k; 6 | proxy_busy_buffers_size 64k; 7 | proxy_redirect off; 8 | proxy_hide_header Vary; 9 | proxy_set_header Accept-Encoding ''; 10 | proxy_set_header Host $host; 11 | proxy_set_header Referer $http_referer; 12 | proxy_set_header Cookie $http_cookie; 13 | proxy_set_header X-Real-IP $remote_addr; 14 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 15 | -------------------------------------------------------------------------------- /conf/rpaf.conf: -------------------------------------------------------------------------------- 1 | LoadModule rpaf_module modules/mod_rpaf-2.0.so 2 | #Mod_rpaf settings 3 | RPAFenable On 4 | RPAFproxy_ips 127.0.0.1 5 | RPAFsethostname On 6 | RPAFheader X-Forwarded-For 7 | -------------------------------------------------------------------------------- /conf/sablog.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ielnehc/ltmh/3941431f3acffebdd62df5047c34b1e94be6dabd/conf/sablog.conf -------------------------------------------------------------------------------- /conf/server.ini: -------------------------------------------------------------------------------- 1 | 2 | ; php options 3 | 4 | pid = /var/run/hhvm/pid 5 | 6 | ; hhvm specific 7 | 8 | ;hhvm.server.port = 9000 9 | hhvm.server.file_socket = /var/run/hhvm/server.sock 10 | hhvm.server.type = fastcgi 11 | hhvm.server.default_document = index.php 12 | hhvm.log.use_log_file = true 13 | hhvm.log.file = /var/log/hhvm/error.log 14 | hhvm.repo.central.path = /var/run/hhvm/hhvm.hhbc -------------------------------------------------------------------------------- /conf/shopex.conf: -------------------------------------------------------------------------------- 1 | location / { 2 | if (!-e $request_filename) { 3 | rewrite ^/(.+\.(html|xml|json|htm|php|jsp|asp|shtml))$ /index.php?$1 last; 4 | } 5 | } -------------------------------------------------------------------------------- /conf/typecho.conf: -------------------------------------------------------------------------------- 1 | location / { 2 | index index.html index.php; 3 | if (-f $request_filename/index.html){ 4 | rewrite (.*) $1/index.html break; 5 | } 6 | if (-f $request_filename/index.php){ 7 | rewrite (.*) $1/index.php; 8 | } 9 | if (!-f $request_filename){ 10 | rewrite (.*) /index.php; 11 | } 12 | } -------------------------------------------------------------------------------- /conf/wordpress.conf: -------------------------------------------------------------------------------- 1 | location / { 2 | try_files $uri $uri/ /index.php?$args; 3 | } 4 | 5 | # Add trailing slash to */wp-admin requests. 6 | rewrite /wp-admin$ $scheme://$host$uri/ permanent; -------------------------------------------------------------------------------- /conf/wp2.conf: -------------------------------------------------------------------------------- 1 | location /wp/ { 2 | try_files $uri $uri/ /wp/index.php?$args; 3 | } 4 | 5 | # Add trailing slash to */wp-admin requests. 6 | rewrite /wp-admin$ $scheme://$host$uri/ permanent; -------------------------------------------------------------------------------- /init/HHVM-init-CentOS: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # hhvm Starts The HHVM FastCGI Daemon 4 | # 5 | # chkconfig: - 85 15 6 | # description: Starts The HHVM FastCGI Daemon 7 | # processname: hhvm 8 | # config: /etc/hhvm/server.ini 9 | # config: /etc/sysconfig/hhvm 10 | # pidfile: /var/run/hhvm/hhvm.pid 11 | # 12 | ### BEGIN INIT INFO 13 | # Provides: hhvm 14 | # Short-Description: start and stop the HHVM FastCGI Daemon 15 | # Description: Starts The HHVM FastCGI Daemon 16 | ### END INIT INFO 17 | 18 | # Standard LSB functions 19 | #. /lib/lsb/init-functions 20 | 21 | # Source function library. 22 | . /etc/init.d/functions 23 | 24 | # Check that networking is up. 25 | . /etc/sysconfig/network 26 | 27 | if [ "$NETWORKING" = "no" ] 28 | then 29 | exit 0 30 | fi 31 | 32 | RETVAL=0 33 | HHVM=/usr/bin/hhvm 34 | prog="Hhvm" 35 | pidfile=${PIDFILE-/var/run/hhvm/pid} 36 | lockfile=${LOCKFILE-/var/run/hhvm/lock} 37 | 38 | CONFIG_FILE="/etc/hhvm/server.ini" 39 | SYSTEM_CONFIG_FILE="/etc/hhvm/php.ini" 40 | MODE=daemon 41 | USER=www 42 | ARGS="--config ${CONFIG_FILE} --config ${SYSTEM_CONFIG_FILE}" 43 | 44 | if [ -f /etc/sysconfig/hhvm ]; then 45 | . /etc/sysconfig/hhvm 46 | fi 47 | 48 | 49 | start() { 50 | echo -n $"Starting $prog: " 51 | dir=$(dirname ${pidfile}) 52 | [ -d $dir ] || mkdir $dir 53 | daemon ${HHVM} --mode ${MODE} --user ${USER} ${ARGS} 54 | RETVAL=$? 55 | echo 56 | [ $RETVAL -eq 0 ] && touch ${lockfile} 57 | } 58 | 59 | 60 | stop() { 61 | echo -n $"Stopping $prog: " 62 | killproc -p ${pidfile} ${HHVM} 63 | RETVAL=$? 64 | echo 65 | if [ $RETVAL -eq 0 ] ; then 66 | rm -f ${lockfile} ${pidfile} 67 | fi 68 | } 69 | 70 | restart () { 71 | stop 72 | start 73 | } 74 | 75 | # See how we were called. 76 | case "$1" in 77 | start) 78 | start 79 | ;; 80 | stop) 81 | stop 82 | ;; 83 | status) 84 | status -p ${pidfile} ${HHVM} 85 | RETVAL=$? 86 | ;; 87 | restart) 88 | restart 89 | ;; 90 | *) 91 | echo $"Usage: $prog {start|stop|status|restart}" 92 | RETVAL=2 93 | esac 94 | 95 | exit $RETVAL 96 | -------------------------------------------------------------------------------- /init/Memcached-init-CentOS: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # chkconfig: - 55 45 4 | # description: The memcached daemon is a network memory cache service. 5 | # processname: memcached 6 | # config: /etc/sysconfig/memcached 7 | # pidfile: /var/run/memcached/memcached.*.pid 8 | 9 | # Source function library. 10 | . /etc/init.d/functions 11 | 12 | PORT=11211 13 | USER=memcached 14 | MAXCONN=1024 15 | OPTIONS="" 16 | 17 | if [ -f /etc/sysconfig/memcached ];then 18 | . /etc/sysconfig/memcached 19 | fi 20 | 21 | # Check that networking is up. 22 | . /etc/sysconfig/network 23 | 24 | if [ "$NETWORKING" = "no" ] 25 | then 26 | exit 0 27 | fi 28 | 29 | RETVAL=0 30 | prog="/usr/local/memcached/bin/memcached" 31 | 32 | start_instance() { 33 | echo -n $"Starting $prog ($1): " 34 | daemon --pidfile /var/run/memcached/memcached.$1.pid memcached -d -p $PORT -u $USER -m $2 -c $MAXCONN -P /var/run/memcached/memcached.$1.pid $OPTIONS 35 | RETVAL=$? 36 | echo 37 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached.$1 38 | PORT=`expr $PORT + 1` 39 | } 40 | 41 | stop_instance() { 42 | echo -n $"Stopping $prog ($1): " 43 | killproc -p /var/run/memcached/memcached.$1.pid /usr/bin/memcached 44 | RETVAL=$? 45 | echo 46 | if [ $RETVAL -eq 0 ] ; then 47 | rm -f /var/lock/subsys/memcached.$1 48 | rm -f /var/run/memcached.$1.pid 49 | fi 50 | } 51 | 52 | start () { 53 | # insure that /var/run/memcached has proper permissions 54 | mkdir -p /var/run/memcached 55 | if [ "`stat -c %U /var/run/memcached`" != "$USER" ]; then 56 | chown $USER /var/run/memcached 57 | fi 58 | 59 | start_instance default 64; 60 | #start_instance block 16; 61 | #start_instance content 128; 62 | #start_instance filter 128; 63 | #start_instance form 32; 64 | #start_instance menu 16; 65 | #start_instance page 8; 66 | #start_instance update 8; 67 | #start_instance views 8; 68 | } 69 | stop () { 70 | stop_instance default; 71 | #stop_instance block; 72 | #stop_instance content; 73 | #stop_instance filter; 74 | #stop_instance form; 75 | #stop_instance menu; 76 | #stop_instance page; 77 | #stop_instance update; 78 | #stop_instance views; 79 | } 80 | 81 | restart () { 82 | stop 83 | start 84 | } 85 | 86 | 87 | # See how we were called. 88 | case "$1" in 89 | start) 90 | start 91 | ;; 92 | stop) 93 | stop 94 | ;; 95 | status) 96 | status memcached 97 | ;; 98 | restart|reload|force-reload) 99 | restart 100 | ;; 101 | *) 102 | echo $"Usage: $0 {start|stop|status|restart|reload|force-reload}" 103 | exit 1 104 | esac 105 | 106 | exit $? 107 | -------------------------------------------------------------------------------- /init/Memcached-init-Ubuntu: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | 4 | PORT=11211 5 | USER=memcached 6 | MAXCONN=1024 7 | OPTIONS="" 8 | DAEMON=/usr/local/memcached/bin/memcached 9 | 10 | RETVAL=0 11 | prog="/usr/local/memcached/bin/memcached" 12 | 13 | start_instance() { 14 | echo -n $"Starting $prog ($1): " 15 | start-stop-daemon --start --quiet --pidfile /var/run/memcached/memcached.$1.pid --exec $DAEMON -- -d -p $PORT -u $USER -m $2 -c $MAXCONN -P /var/run/memcached/memcached.$1.pid $OPTIONS 16 | RETVAL=$? 17 | echo 18 | [ $RETVAL -eq 0 ] && touch /var/lock/memcached.$1 19 | PORT=`expr $PORT + 1` 20 | } 21 | 22 | stop_instance() { 23 | echo -n $"Stopping $prog ($1): " 24 | start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/memcached/memcached.$1.pid --exec $DAEMON 25 | RETVAL=$? 26 | echo 27 | if [ $RETVAL -eq 0 ] ; then 28 | rm -f /var/lock/memcached.$1 29 | rm -f /var/run/memcached/memcached.$1.pid 30 | fi 31 | } 32 | start () { 33 | # insure that /var/run/memcached has proper permissions 34 | mkdir -p /var/run/memcached 35 | if [ "`stat -c %U /var/run/memcached`" != "$USER" ]; then 36 | chown $USER /var/run/memcached 37 | fi 38 | 39 | start_instance default 64; 40 | #start_instance block 16; 41 | #start_instance content 128; 42 | #start_instance filter 128; 43 | #start_instance form 32; 44 | #start_instance menu 16; 45 | #start_instance page 8; 46 | #start_instance update 8; 47 | #start_instance views 8; 48 | } 49 | stop () { 50 | stop_instance default; 51 | #stop_instance block; 52 | #stop_instance content; 53 | #stop_instance filter; 54 | #stop_instance form; 55 | #stop_instance menu; 56 | #stop_instance page; 57 | #stop_instance update; 58 | #stop_instance views; 59 | } 60 | 61 | restart () { 62 | stop 63 | start 64 | } 65 | 66 | # See how we were called. 67 | case "$1" in 68 | start) 69 | start 70 | ;; 71 | stop) 72 | stop 73 | ;; 74 | status) 75 | status memcached 76 | ;; 77 | restart|reload|force-reload) 78 | restart 79 | ;; 80 | *) 81 | echo $"Usage: $0 {start|stop|status|restart|reload|force-reload}" 82 | exit 1 83 | esac 84 | 85 | exit $? 86 | -------------------------------------------------------------------------------- /init/Nginx-init-CentOS: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # nginx - this script starts and stops the nginx daemon 4 | # 5 | # chkconfig: - 85 15 6 | # description: Nginx is an HTTP(S) server, HTTP(S) reverse \ 7 | # proxy and IMAP/POP3 proxy server 8 | # processname: nginx 9 | # config: /usr/local/nginx/conf/nginx.conf 10 | # pidfile: /var/run/nginx.pid 11 | 12 | # Source function library. 13 | . /etc/rc.d/init.d/functions 14 | 15 | # Source networking configuration. 16 | . /etc/sysconfig/network 17 | 18 | # Check that networking is up. 19 | [ "$NETWORKING" = "no" ] && exit 0 20 | 21 | nginx="/usr/local/nginx/sbin/nginx" 22 | prog=$(basename $nginx) 23 | 24 | NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" 25 | 26 | [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx 27 | 28 | lockfile=/var/lock/subsys/nginx 29 | 30 | make_dirs() { 31 | # make required directories 32 | user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -` 33 | if [ -z "`grep $user /etc/passwd`" ]; then 34 | useradd -M -s /bin/nologin $user 35 | fi 36 | options=`$nginx -V 2>&1 | grep 'configure arguments:'` 37 | for opt in $options; do 38 | if [ `echo $opt | grep '.*-temp-path'` ]; then 39 | value=`echo $opt | cut -d "=" -f 2` 40 | if [ ! -d "$value" ]; then 41 | # echo "creating" $value 42 | mkdir -p $value && chown -R $user $value 43 | fi 44 | fi 45 | done 46 | } 47 | 48 | start() { 49 | [ -x $nginx ] || exit 5 50 | [ -f $NGINX_CONF_FILE ] || exit 6 51 | make_dirs 52 | echo -n $"Starting $prog: " 53 | daemon $nginx -c $NGINX_CONF_FILE 54 | retval=$? 55 | echo 56 | [ $retval -eq 0 ] && touch $lockfile 57 | return $retval 58 | } 59 | 60 | stop() { 61 | echo -n $"Stopping $prog: " 62 | killproc $prog -QUIT 63 | retval=$? 64 | echo 65 | [ $retval -eq 0 ] && rm -f $lockfile 66 | return $retval 67 | } 68 | 69 | restart() { 70 | configtest || return $? 71 | stop 72 | sleep 3 73 | start 74 | } 75 | 76 | reload() { 77 | configtest || return $? 78 | echo -n $"Reloading $prog: " 79 | killproc $nginx -HUP 80 | RETVAL=$? 81 | echo 82 | } 83 | 84 | force_reload() { 85 | restart 86 | } 87 | 88 | configtest() { 89 | $nginx -t -c $NGINX_CONF_FILE 90 | } 91 | 92 | rh_status() { 93 | status $prog 94 | } 95 | 96 | rh_status_q() { 97 | rh_status >/dev/null 2>&1 98 | } 99 | 100 | case "$1" in 101 | start) 102 | rh_status_q && exit 0 103 | $1 104 | ;; 105 | stop) 106 | rh_status_q || exit 0 107 | $1 108 | ;; 109 | restart|configtest) 110 | $1 111 | ;; 112 | reload) 113 | rh_status_q || exit 7 114 | $1 115 | ;; 116 | force-reload) 117 | force_reload 118 | ;; 119 | status) 120 | rh_status 121 | ;; 122 | condrestart|try-restart) 123 | rh_status_q || exit 0 124 | ;; 125 | *) 126 | echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" 127 | exit 2 128 | esac 129 | -------------------------------------------------------------------------------- /init/Redis-server-init-CentOS: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # redis - this script starts and stops the redis-server daemon 4 | # 5 | # chkconfig: - 85 15 6 | # description: Redis is a persistent key-value database 7 | # processname: redis-server 8 | # config: /usr/local/redis/etc/redis.conf 9 | # config: /etc/sysconfig/redis 10 | # pidfile: /var/run/redis.pid 11 | 12 | # Source function library. 13 | . /etc/rc.d/init.d/functions 14 | 15 | # Source networking configuration. 16 | . /etc/sysconfig/network 17 | 18 | # Check that networking is up. 19 | [ "$NETWORKING" = "no" ] && exit 0 20 | 21 | redis="/usr/local/redis/bin/redis-server" 22 | prog=$(basename $redis) 23 | 24 | REDIS_CONF_FILE="/usr/local/redis/etc/redis.conf" 25 | 26 | [ -f /etc/sysconfig/redis ] && . /etc/sysconfig/redis 27 | 28 | lockfile=/var/lock/subsys/redis 29 | 30 | start() { 31 | [ -x $redis ] || exit 5 32 | [ -f $REDIS_CONF_FILE ] || exit 6 33 | echo -n $"Starting $prog: " 34 | daemon $redis $REDIS_CONF_FILE 35 | retval=$? 36 | echo 37 | [ $retval -eq 0 ] && touch $lockfile 38 | return $retval 39 | } 40 | 41 | stop() { 42 | echo -n $"Stopping $prog: " 43 | killproc $prog -QUIT 44 | retval=$? 45 | echo 46 | [ $retval -eq 0 ] && rm -f $lockfile 47 | return $retval 48 | } 49 | 50 | restart() { 51 | stop 52 | start 53 | } 54 | 55 | reload() { 56 | echo -n $"Reloading $prog: " 57 | killproc $redis -HUP 58 | RETVAL=$? 59 | echo 60 | } 61 | 62 | force_reload() { 63 | restart 64 | } 65 | 66 | rh_status() { 67 | status $prog 68 | } 69 | 70 | rh_status_q() { 71 | rh_status >/dev/null 2>&1 72 | } 73 | 74 | case "$1" in 75 | start) 76 | rh_status_q && exit 0 77 | $1 78 | ;; 79 | stop) 80 | rh_status_q || exit 0 81 | $1 82 | ;; 83 | restart|configtest) 84 | $1 85 | ;; 86 | reload) 87 | rh_status_q || exit 7 88 | $1 89 | ;; 90 | force-reload) 91 | force_reload 92 | ;; 93 | status) 94 | rh_status 95 | ;; 96 | condrestart|try-restart) 97 | rh_status_q || exit 0 98 | ;; 99 | *) 100 | echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" 101 | exit 2 102 | esac 103 | -------------------------------------------------------------------------------- /init/Redis-server-init-Ubuntu: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | ### BEGIN INIT INFO 3 | # Provides: redis-server 4 | # Required-Start: $syslog 5 | # Required-Stop: $syslog 6 | # Should-Start: $local_fs 7 | # Should-Stop: $local_fs 8 | # Default-Start: 2 3 4 5 9 | # Default-Stop: 0 1 6 10 | # Short-Description: redis-server - Persistent key-value db 11 | # Description: redis-server - Persistent key-value db 12 | ### END INIT INFO 13 | 14 | 15 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 16 | DAEMON=/usr/local/redis/bin/redis-server 17 | DAEMON_ARGS=/usr/local/redis/etc/redis.conf 18 | NAME=redis-server 19 | DESC=redis-server 20 | PIDFILE=/var/run/redis.pid 21 | 22 | test -x $DAEMON || exit 0 23 | test -x $DAEMONBOOTSTRAP || exit 0 24 | 25 | set -e 26 | 27 | case "$1" in 28 | start) 29 | echo -n "Starting $DESC: " 30 | touch $PIDFILE 31 | chown redis:redis $PIDFILE 32 | if start-stop-daemon --start --quiet --umask 007 --pidfile $PIDFILE --chuid redis:redis --exec $DAEMON -- $DAEMON_ARGS 33 | then 34 | echo "$NAME." 35 | else 36 | echo "failed" 37 | fi 38 | ;; 39 | stop) 40 | echo -n "Stopping $DESC: " 41 | if start-stop-daemon --stop --retry 10 --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON 42 | then 43 | echo "$NAME." 44 | else 45 | echo "failed" 46 | fi 47 | rm -f $PIDFILE 48 | ;; 49 | 50 | restart|force-reload) 51 | ${0} stop 52 | ${0} start 53 | ;; 54 | *) 55 | echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2 56 | exit 1 57 | ;; 58 | esac 59 | 60 | exit 0 61 | -------------------------------------------------------------------------------- /init/hhvm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # hhvm Starts The HHVM FastCGI Daemon 4 | ## Author: hhvmc.com 5 | # chkconfig: - 85 15 6 | # description: Starts The HHVM FastCGI Daemon 7 | # processname: hhvm 8 | # config: /etc/hhvm/server.ini 9 | # config: /etc/sysconfig/hhvm 10 | # pidfile: /var/run/hhvm/hhvm.pid 11 | # 12 | ### BEGIN INIT INFO 13 | # Provides: hhvm 14 | # Short-Description: start and stop the HHVM FastCGI Daemon 15 | # Description: Starts The HHVM FastCGI Daemon 16 | ### END INIT INFO 17 | 18 | # Standard LSB functions 19 | #. /lib/lsb/init-functions 20 | 21 | # Source function library. 22 | . /etc/init.d/functions 23 | 24 | # Check that networking is up. 25 | . /etc/sysconfig/network 26 | 27 | if [ "$NETWORKING" = "no" ] 28 | then 29 | exit 0 30 | fi 31 | 32 | RETVAL=0 33 | HHVM=/usr/bin/hhvm 34 | prog="HHVM" 35 | pidfile=${PIDFILE-/var/run/hhvm/pid} 36 | lockfile=${LOCKFILE-/var/run/hhvm/lock} 37 | 38 | CONFIG_FILE="/etc/hhvm/server.ini" 39 | SYSTEM_CONFIG_FILE="/etc/hhvm/php.ini" 40 | MODE=daemon 41 | USER=www-data 42 | ARGS="--config ${CONFIG_FILE} --config ${SYSTEM_CONFIG_FILE}" 43 | 44 | if [ -f /etc/sysconfig/hhvm ]; then 45 | . /etc/sysconfig/hhvm 46 | fi 47 | 48 | 49 | start() { 50 | echo -n $"Starting $prog: " 51 | dir=$(dirname ${pidfile}) 52 | [ -d $dir ] || mkdir $dir 53 | daemon ${HHVM} --mode ${MODE} --user ${USER} ${ARGS} 54 | RETVAL=$? 55 | echo 56 | [ $RETVAL -eq 0 ] && touch ${lockfile} 57 | } 58 | 59 | 60 | stop() { 61 | echo -n $"Stopping $prog: " 62 | killproc -p ${pidfile} ${HHVM} 63 | RETVAL=$? 64 | echo 65 | if [ $RETVAL -eq 0 ] ; then 66 | rm -f ${lockfile} ${pidfile} 67 | fi 68 | } 69 | 70 | restart () { 71 | stop 72 | start 73 | } 74 | 75 | # See how we were called. 76 | case "$1" in 77 | start) 78 | start 79 | ;; 80 | stop) 81 | stop 82 | ;; 83 | status) 84 | status -p ${pidfile} ${HHVM} 85 | RETVAL=$? 86 | ;; 87 | restart) 88 | restart 89 | ;; 90 | *) 91 | echo $"Usage: $prog {start|stop|status|restart}" 92 | RETVAL=2 93 | esac 94 | 95 | exit $RETVAL 96 | -------------------------------------------------------------------------------- /init/init.d.nginx: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # chkconfig: 2345 55 25 3 | # Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and 4 | # run 'update-rc.d -f nginx defaults', or use the appropriate command on your 5 | # distro. For CentOS/Redhat run: 'chkconfig --add nginx' 6 | 7 | ### BEGIN INIT INFO 8 | # Provides: nginx 9 | # Required-Start: $all 10 | # Required-Stop: $all 11 | # Default-Start: 2 3 4 5 12 | # Default-Stop: 0 1 6 13 | # Short-Description: starts the nginx web server 14 | # Description: starts nginx using start-stop-daemon 15 | ### END INIT INFO 16 | # Author: andy 17 | # Web Address: http://www.hhvm.biz 18 | # 19 | # Version: 0.1 25-Jul-2014 andy 20 | # Notes: LNMP/LAMP/LANMP for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ 21 | # 22 | # This script's project home is: 23 | # http://www.hhvm.biz/forum-36-1.html 24 | # https://github.com/ielnehc/ltmh 25 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 26 | NAME=nginx 27 | NGINX_BIN=/usr/local/nginx/sbin/$NAME 28 | CONFIGFILE=/usr/local/nginx/conf/$NAME.conf 29 | PIDFILE=/usr/local/nginx/logs/$NAME.pid 30 | SCRIPTNAME=/etc/init.d/$NAME 31 | 32 | case "$1" in 33 | start) 34 | echo -n "Starting $NAME... " 35 | 36 | if netstat -tnpl | grep -q nginx;then 37 | echo "$NAME (pid `pidof $NAME`) already running." 38 | exit 1 39 | fi 40 | 41 | $NGINX_BIN -c $CONFIGFILE 42 | 43 | if [ "$?" != 0 ] ; then 44 | echo " failed" 45 | exit 1 46 | else 47 | echo " done" 48 | fi 49 | ;; 50 | 51 | stop) 52 | echo -n "Stoping $NAME... " 53 | 54 | if ! netstat -tnpl | grep -q nginx; then 55 | echo "$NAME is not running." 56 | exit 1 57 | fi 58 | 59 | $NGINX_BIN -s stop 60 | 61 | if [ "$?" != 0 ] ; then 62 | echo " failed. Use force-quit" 63 | exit 1 64 | else 65 | echo " done" 66 | fi 67 | ;; 68 | 69 | status) 70 | if netstat -tnpl | grep -q nginx; then 71 | PID=`pidof nginx` 72 | echo "$NAME (pid $PID) is running..." 73 | else 74 | echo "$NAME is stopped" 75 | exit 0 76 | fi 77 | ;; 78 | 79 | force-quit) 80 | echo -n "Terminating $NAME... " 81 | 82 | if ! netstat -tnpl | grep -q nginx; then 83 | echo "$NAME is not running." 84 | exit 1 85 | fi 86 | 87 | kill `pidof $NAME` 88 | 89 | if [ "$?" != 0 ] ; then 90 | echo " failed" 91 | exit 1 92 | else 93 | echo " done" 94 | fi 95 | ;; 96 | 97 | restart) 98 | $SCRIPTNAME stop 99 | sleep 1 100 | $SCRIPTNAME start 101 | ;; 102 | 103 | reload) 104 | 105 | echo -n "Reload service $NAME... " 106 | 107 | if netstat -tnpl | grep -q nginx; then 108 | $NGINX_BIN -s reload 109 | echo " done" 110 | else 111 | echo "$NAME is not running, can't reload." 112 | exit 1 113 | fi 114 | ;; 115 | 116 | configtest) 117 | 118 | echo -n "Test $NAME configure files... " 119 | 120 | $NGINX_BIN -t 121 | ;; 122 | 123 | *) 124 | echo "Usage: $SCRIPTNAME {start|stop|force-quit|restart|reload|status|configtest}" 125 | exit 1 126 | ;; 127 | 128 | esac -------------------------------------------------------------------------------- /init/init.d.proftpd: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # chkconfig: 2345 55 25 3 | # Description: Startup script for proftpd on Debian. Place in /etc/init.d and 4 | # run 'update-rc.d -f proftpd defaults', or use the appropriate command on your 5 | # distro. For CentOS/Redhat run: 'chkconfig --add proftpd' 6 | 7 | ### BEGIN INIT INFO 8 | # Provides: proftpd 9 | # Required-Start: $all 10 | # Required-Stop: $all 11 | # Default-Start: 2 3 4 5 12 | # Default-Stop: 0 1 6 13 | # Short-Description: starts the proftpd server 14 | # Description: starts proftpd using start-stop-daemon 15 | ### END INIT INFO 16 | 17 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 18 | DESC="proftpd daemon" 19 | NAME=proftpd 20 | DAEMON=/usr/local/proftpd/sbin/$NAME 21 | CONFIGFILE=/usr/local/proftpd/etc/$NAME.conf 22 | PIDFILE=/usr/local/proftpd/var/$NAME.pid 23 | SCRIPTNAME=/etc/init.d/$NAME 24 | 25 | set -e 26 | [ -x "$DAEMON" ] || exit 0 27 | 28 | do_start() { 29 | $DAEMON || echo -n "$NAME already running" 30 | } 31 | 32 | do_stop() { 33 | kill -INT `cat $PIDFILE` || echo -n "$NAME not running" 34 | } 35 | 36 | do_reload() { 37 | kill -HUP `cat $PIDFILE` || echo -n "$NAME can't reload" 38 | } 39 | 40 | case "$1" in 41 | start) 42 | echo -n "Starting $DESC: $NAME" 43 | do_start 44 | echo "." 45 | ;; 46 | stop) 47 | echo -n "Stopping $DESC: $NAME" 48 | do_stop 49 | echo "." 50 | ;; 51 | restart) 52 | echo -n "Restarting $DESC: $NAME" 53 | do_stop 54 | do_start 55 | echo "." 56 | ;; 57 | reload) 58 | echo -n "Stopping $DESC: $NAME" 59 | do_reload 60 | echo "." 61 | ;; 62 | *) 63 | echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2 64 | exit 3 65 | ;; 66 | esac 67 | 68 | exit 0 69 | -------------------------------------------------------------------------------- /init/init.d.redis: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # redis - this script starts and stops the redis-server daemon 4 | # 5 | # chkconfig: 2345 80 90 6 | # description: Redis is a persistent key-value database 7 | # 8 | ### BEGIN INIT INFO 9 | # Provides: redis 10 | # Required-Start: $syslog 11 | # Required-Stop: $syslog 12 | # Should-Start: $local_fs 13 | # Should-Stop: $local_fs 14 | # Default-Start: 2 3 4 5 15 | # Default-Stop: 0 1 6 16 | # Short-Description: redis-server daemon 17 | # Description: redis-server daemon 18 | ### END INIT INFO 19 | 20 | REDISPORT=6379 21 | EXEC=/usr/local/redis/bin/redis-server 22 | REDIS_CLI=/usr/local/redis/bin/redis-cli 23 | 24 | PIDFILE=/var/run/redis.pid 25 | CONF="/usr/local/redis/etc/redis.conf" 26 | 27 | case "$1" in 28 | start) 29 | if [ -f $PIDFILE ] 30 | then 31 | echo "$PIDFILE exists, process is already running or crashed" 32 | else 33 | echo "Starting Redis server..." 34 | $EXEC $CONF 35 | fi 36 | if [ "$?"="0" ] 37 | then 38 | echo "Redis is running..." 39 | fi 40 | ;; 41 | stop) 42 | if [ ! -f $PIDFILE ] 43 | then 44 | echo "$PIDFILE does not exist, process is not running" 45 | else 46 | PID=$(cat $PIDFILE) 47 | echo "Stopping ..." 48 | $REDIS_CLI -p $REDISPORT shutdown 49 | while [ -x ${PIDFILE} ] 50 | do 51 | echo "Waiting for Redis to shutdown ..." 52 | sleep 1 53 | done 54 | echo "Redis stopped" 55 | fi 56 | ;; 57 | restart) 58 | ${0} stop 59 | ${0} start 60 | ;; 61 | *) 62 | echo "Usage: /etc/init.d/redis {start|stop|restart}" >&2 63 | exit 1 64 | esac -------------------------------------------------------------------------------- /init/init_Debian.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for Package in apache2 apache2-doc apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-doc apache2-mpm-worker mysql-client mysql-server mysql-common php5 php5-common php5-cgi php5-mysql php5-curl php5-gd libmysql* mysql-* 4 | do 5 | apt-get -y remove $Package 6 | done 7 | dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P 8 | 9 | apt-get -y update 10 | 11 | # check upgrade OS 12 | [ "$upgrade_yn" == 'y' ] && apt-get -y upgrade 13 | 14 | # Install needed packages 15 | for Package in gcc g++ make autoconf ntpdate libjpeg8 libjpeg8-dev libpng12-0 libpng12-dev libpng3 libfreetype6 libfreetype6-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev curl libcurl3 libcurl4-openssl-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl libssl-dev libtool libevent-dev bison libsasl2-dev libxslt1-dev locales libcloog-ppl0 patch vim zip unzip tmux htop wget dc bc expect rsync 16 | do 17 | apt-get -y install $Package 18 | done 19 | 20 | 21 | # Modify swap 22 | Mem=`free -m | awk '/Mem:/{print $2}'` 23 | Swap=`free -m | grep 'Swap:' | awk '{print $2}'` 24 | if [ $Swap == 0 ] ;then 25 | if [ $Swap == 0 ] && [ $Mem -le 512 ];then 26 | dd if=/dev/zero of=/swapfile count=1024 bs=1M 27 | mkswap /swapfile 28 | swapon /swapfile 29 | chown root:root /swapfile 30 | chmod 0600 /swapfile 31 | elif [ $Swap == 0 ] && [ $Mem -gt 512 -a $Mem -le 1024 ];then 32 | dd if=/dev/zero of=/swapfile count=2048 bs=1M 33 | mkswap /swapfile 34 | swapon /swapfile 35 | chown root:root /swapfile 36 | chmod 0600 /swapfile 37 | elif [ $Swap == 0 ] && [ $Mem -gt 1500 ];then 38 | dd if=/dev/zero of=/swapfile count=$Mem bs=1M 39 | mkswap /swapfile 40 | swapon /swapfile 41 | chown root:root /swapfile 42 | chmod 0600 /swapfile 43 | fi 44 | 45 | cat >> /etc/fstab << EOF 46 | /swapfile swap swap defaults 0 0 47 | 48 | EOF 49 | fi 50 | 51 | 52 | # PS1 53 | [ -z "`cat ~/.bashrc | grep ^PS1`" ] && echo "PS1='\${debian_chroot:+(\$debian_chroot)}\\[\\e[1;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ '" >> ~/.bashrc 54 | 55 | # history size 56 | [ -z "`cat ~/.bashrc | grep ^HISTSIZE`" ] && echo 'HISTSIZE=100' >> ~/.bashrc 57 | [ -z "`cat ~/.bashrc | grep history-timestamp`" ] && echo "export PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });user=\$(whoami); echo \$(date \"+%Y-%m-%d %H:%M:%S\"):\$user:\`pwd\`/:\$msg ---- \$(who am i); } >> /tmp/\`hostname\`.\`whoami\`.history-timestamp'" >> ~/.bashrc 58 | 59 | # /etc/security/limits.conf 60 | [ -z "`cat /etc/security/limits.conf | grep 'nproc 65535'`" ] && cat >> /etc/security/limits.conf <> /etc/rc.local 67 | 68 | # /etc/hosts 69 | [ "$(hostname -i | awk '{print $1}')" != "127.0.0.1" ] && sed -i "s@^127.0.0.1\(.*\)@127.0.0.1 `hostname` \1@" /etc/hosts 70 | 71 | 72 | # Set DNS 73 | #cat > /etc/resolv.conf << EOF 74 | #nameserver 114.114.114.114 75 | #nameserver 8.8.8.8 76 | #EOF 77 | 78 | # alias vi 79 | [ -z "`cat ~/.bashrc | grep 'alias vi='`" ] && sed -i "s@^alias l=\(.*\)@alias l=\1\nalias vi='vim'@" ~/.bashrc 80 | [ -z "`cat /etc/vim/vimrc | grep 'syntax on'`" ] && echo 'syntax on' >> /etc/vim/vimrc 81 | sed -i 's@^# export LS_OPTIONS@export LS_OPTIONS@' ~/.bashrc 82 | sed -i 's@^# alias@alias@g' ~/.bashrc 83 | 84 | # /etc/sysctl.conf 85 | [ -z "`cat /etc/sysctl.conf | grep 'fs.file-max'`" ] && cat >> /etc/sysctl.conf << EOF 86 | fs.file-max=65535 87 | net.ipv4.tcp_syncookies = 1 88 | net.ipv4.tcp_fin_timeout = 30 89 | net.ipv4.tcp_tw_reuse = 1 90 | net.ipv4.tcp_tw_recycle = 1 91 | net.ipv4.ip_local_port_range = 1024 65000 92 | net.ipv4.tcp_max_syn_backlog = 262144 93 | net.ipv4.tcp_max_tw_buckets = 6000 94 | net.ipv4.route.gc_timeout = 100 95 | net.ipv4.tcp_syn_retries = 1 96 | net.ipv4.tcp_synack_retries = 1 97 | net.core.somaxconn = 65535 98 | net.core.netdev_max_backlog = 262144 99 | net.ipv4.tcp_timestamps = 0 100 | net.ipv4.tcp_max_orphans = 262144 101 | EOF 102 | sysctl -p 103 | 104 | sed -i 's@^ACTIVE_CONSOLES.*@ACTIVE_CONSOLES="/dev/tty[1-2]"@' /etc/default/console-setup 105 | sed -i 's@^3:23:respawn@#3:23:respawn@' /etc/inittab 106 | sed -i 's@^4:23:respawn@#4:23:respawn@' /etc/inittab 107 | sed -i 's@^5:23:respawn@#5:23:respawn@' /etc/inittab 108 | sed -i 's@^6:23:respawn@#6:23:respawn@' /etc/inittab 109 | sed -i "s@^ctrlaltdel@#ctrlaltdel@" /etc/inittab 110 | sed -i 's@^# en_US.UTF-8@en_US.UTF-8@' /etc/locale.gen 111 | init q 112 | 113 | # Update time 114 | ntpdate pool.ntp.org 115 | echo "*/20 * * * * `which ntpdate` pool.ntp.org > /dev/null 2>&1" >> /var/spool/cron/crontabs/root;chmod 600 /var/spool/cron/crontabs/root 116 | service cron restart 117 | 118 | # iptables 119 | cat > /etc/iptables.up.rules << EOF 120 | # Firewall configuration written by system-config-securitylevel 121 | # Manual customization of this file is not recommended. 122 | *filter 123 | :INPUT DROP [0:0] 124 | :FORWARD ACCEPT [0:0] 125 | :OUTPUT ACCEPT [0:0] 126 | :syn-flood - [0:0] 127 | -A INPUT -i lo -j ACCEPT 128 | -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT 129 | -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT 130 | -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT 131 | -A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT 132 | -A INPUT -p icmp -m limit --limit 100/sec --limit-burst 100 -j ACCEPT 133 | -A INPUT -p icmp -m limit --limit 1/s --limit-burst 10 -j ACCEPT 134 | -A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j syn-flood 135 | -A INPUT -j REJECT --reject-with icmp-host-prohibited 136 | -A syn-flood -p tcp -m limit --limit 3/sec --limit-burst 6 -j RETURN 137 | -A syn-flood -j REJECT --reject-with icmp-port-unreachable 138 | COMMIT 139 | EOF 140 | iptables-restore < /etc/iptables.up.rules 141 | echo 'pre-up iptables-restore < /etc/iptables.up.rules' >> /etc/network/interfaces 142 | 143 | . ~/.bashrc 144 | -------------------------------------------------------------------------------- /init/init_Debian_hhvm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cat /etc/issue 4 | uname -a 5 | apt-get -y update 6 | 7 | for Package in apache2 apache2-doc apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-doc apache2-mpm-worker mysql-client mysql-server mysql-common php5 php5-common php5-cgi php5-mysql php5-curl php5-gd libmysql* mysql-* 8 | do 9 | apt-get -y remove $Package 10 | done 11 | dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P 12 | 13 | apt-get -y update 14 | 15 | # check upgrade OS 16 | [ "$upgrade_yn" == 'y' ] && apt-get -y upgrade 17 | 18 | # Install needed packages 19 | for Package in gcc g++ make autoconf ntpdate libjpeg8 libjpeg8-dev libpng12-0 libpng12-dev libpng3 libfreetype6 libfreetype6-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev curl libcurl3 libcurl4-openssl-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl libtool libevent-dev bison libsasl2-dev libxslt1-dev locales libcloog-ppl0 patch vim zip unzip tmux htop wget bc dc expect rsync libpcre3 libpcre3-dev libssl-dev 20 | do 21 | apt-get -y install $Package 22 | done 23 | 24 | 25 | # Modify swap 26 | Mem=`free -m | awk '/Mem:/{print $2}'` 27 | Swap=`free -m | grep 'Swap:' | awk '{print $2}'` 28 | if [ $Swap == 0 ] ;then 29 | if [ $Swap == 0 ] && [ $Mem -le 512 ];then 30 | dd if=/dev/zero of=/swapfile count=1024 bs=1M 31 | mkswap /swapfile 32 | swapon /swapfile 33 | chown root:root /swapfile 34 | chmod 0600 /swapfile 35 | elif [ $Swap == 0 ] && [ $Mem -gt 512 -a $Mem -le 1024 ];then 36 | dd if=/dev/zero of=/swapfile count=2048 bs=1M 37 | mkswap /swapfile 38 | swapon /swapfile 39 | chown root:root /swapfile 40 | chmod 0600 /swapfile 41 | elif [ $Swap == 0 ] && [ $Mem -gt 1500 ];then 42 | dd if=/dev/zero of=/swapfile count=$Mem bs=1M 43 | mkswap /swapfile 44 | swapon /swapfile 45 | chown root:root /swapfile 46 | chmod 0600 /swapfile 47 | fi 48 | 49 | cat >> /etc/fstab << EOF 50 | /swapfile swap swap defaults 0 0 51 | 52 | EOF 53 | fi 54 | 55 | 56 | # PS1 57 | [ -z "`cat ~/.bashrc | grep ^PS1`" ] && echo "PS1='\${debian_chroot:+(\$debian_chroot)}\\[\\e[1;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ '" >> ~/.bashrc 58 | 59 | # history size 60 | [ -z "`cat ~/.bashrc | grep ^HISTSIZE`" ] && echo 'HISTSIZE=100' >> ~/.bashrc 61 | [ -z "`cat ~/.bashrc | grep history-timestamp`" ] && echo "export PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });user=\$(whoami); echo \$(date \"+%Y-%m-%d %H:%M:%S\"):\$user:\`pwd\`/:\$msg ---- \$(who am i); } >> /tmp/\`hostname\`.\`whoami\`.history-timestamp'" >> ~/.bashrc 62 | 63 | # /etc/security/limits.conf 64 | [ -z "`cat /etc/security/limits.conf | grep 'nproc 65535'`" ] && cat >> /etc/security/limits.conf <> /etc/rc.local 71 | 72 | # /etc/hosts 73 | [ "$(hostname -i | awk '{print $1}')" != "127.0.0.1" ] && sed -i "s@^127.0.0.1\(.*\)@127.0.0.1 `hostname` \1@" /etc/hosts 74 | 75 | # Set timezone 76 | rm -rf /etc/localtime 77 | ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 78 | 79 | # Set DNS 80 | #cat > /etc/resolv.conf << EOF 81 | #nameserver 114.114.114.114 82 | #nameserver 8.8.8.8 83 | #EOF 84 | 85 | # alias vi 86 | [ -z "`cat ~/.bashrc | grep 'alias vi='`" ] && sed -i "s@^alias l=\(.*\)@alias l=\1\nalias vi='vim'@" ~/.bashrc 87 | [ -z "`cat /etc/vim/vimrc | grep 'syntax on'`" ] && echo 'syntax on' >> /etc/vim/vimrc 88 | sed -i 's@^# export LS_OPTIONS@export LS_OPTIONS@' ~/.bashrc 89 | sed -i 's@^# alias@alias@g' ~/.bashrc 90 | 91 | # /etc/sysctl.conf 92 | [ -z "`cat /etc/sysctl.conf | grep 'fs.file-max'`" ] && cat >> /etc/sysctl.conf << EOF 93 | fs.file-max=65535 94 | net.ipv4.tcp_syncookies = 1 95 | net.ipv4.tcp_fin_timeout = 30 96 | net.ipv4.tcp_tw_reuse = 1 97 | net.ipv4.tcp_tw_recycle = 1 98 | net.ipv4.ip_local_port_range = 1024 65000 99 | net.ipv4.tcp_max_syn_backlog = 262144 100 | net.ipv4.tcp_max_tw_buckets = 6000 101 | net.ipv4.route.gc_timeout = 100 102 | net.ipv4.tcp_syn_retries = 1 103 | net.ipv4.tcp_synack_retries = 1 104 | net.core.somaxconn = 65535 105 | net.core.netdev_max_backlog = 262144 106 | net.ipv4.tcp_timestamps = 0 107 | net.ipv4.tcp_max_orphans = 262144 108 | EOF 109 | sysctl -p 110 | 111 | sed -i 's@^ACTIVE_CONSOLES.*@ACTIVE_CONSOLES="/dev/tty[1-2]"@' /etc/default/console-setup 112 | sed -i 's@^3:23:respawn@#3:23:respawn@' /etc/inittab 113 | sed -i 's@^4:23:respawn@#4:23:respawn@' /etc/inittab 114 | sed -i 's@^5:23:respawn@#5:23:respawn@' /etc/inittab 115 | sed -i 's@^6:23:respawn@#6:23:respawn@' /etc/inittab 116 | sed -i "s@^ctrlaltdel@#ctrlaltdel@" /etc/inittab 117 | sed -i 's@^# en_US.UTF-8@en_US.UTF-8@' /etc/locale.gen 118 | init q 119 | 120 | # Update time 121 | ntpdate pool.ntp.org 122 | echo "*/20 * * * * `which ntpdate` pool.ntp.org > /dev/null 2>&1" >> /var/spool/cron/crontabs/root;chmod 600 /var/spool/cron/crontabs/root 123 | service cron restart 124 | 125 | # iptables 126 | cat > /etc/iptables.up.rules << EOF 127 | # Firewall configuration written by system-config-securitylevel 128 | # Manual customization of this file is not recommended. 129 | *filter 130 | :INPUT DROP [0:0] 131 | :FORWARD ACCEPT [0:0] 132 | :OUTPUT ACCEPT [0:0] 133 | :syn-flood - [0:0] 134 | -A INPUT -i lo -j ACCEPT 135 | -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT 136 | -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT 137 | -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT 138 | -A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT 139 | -A INPUT -p icmp -m limit --limit 100/sec --limit-burst 100 -j ACCEPT 140 | -A INPUT -p icmp -m limit --limit 1/s --limit-burst 10 -j ACCEPT 141 | -A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j syn-flood 142 | -A INPUT -j REJECT --reject-with icmp-host-prohibited 143 | -A syn-flood -p tcp -m limit --limit 3/sec --limit-burst 6 -j RETURN 144 | -A syn-flood -j REJECT --reject-with icmp-port-unreachable 145 | COMMIT 146 | EOF 147 | iptables-restore < /etc/iptables.up.rules 148 | echo 'pre-up iptables-restore < /etc/iptables.up.rules' >> /etc/network/interfaces 149 | 150 | . ~/.bashrc 151 | -------------------------------------------------------------------------------- /init/init_Ubuntu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for Package in apache2 apache2-doc apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-doc apache2-mpm-worker mysql-client mysql-server mysql-common php5 php5-common php5-cgi php5-mysql php5-curl php5-gd libmysql* mysql-* 4 | do 5 | apt-get -y remove $Package 6 | done 7 | dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P 8 | 9 | apt-get -y update 10 | 11 | # check upgrade OS 12 | [ "$upgrade_yn" == 'y' ] && apt-get -y upgrade 13 | 14 | # Install needed packages 15 | for Package in gcc g++ make autoconf ntpdate libjpeg8 libjpeg8-dev libpng12-0 libpng12-dev libpng3 libfreetype6 libfreetype6-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev curl libcurl3 libcurl4-openssl-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl libtool libevent-dev bison libsasl2-dev libxslt1-dev patch vim zip unzip tmux htop wget bc dc zip expect rsync libssl-dev 16 | do 17 | apt-get -y install $Package 18 | done 19 | 20 | if [ ! -z "`cat /etc/issue | grep 13`" ];then 21 | apt-get -y install libcloog-ppl1 22 | elif [ ! -z "`cat /etc/issue | grep 12`" ];then 23 | apt-get -y install libcloog-ppl0 24 | fi 25 | 26 | # Modify swap 27 | Mem=`free -m | awk '/Mem:/{print $2}'` 28 | Swap=`free -m | grep 'Swap:' | awk '{print $2}'` 29 | if [ $Swap == 0 ] ;then 30 | if [ $Swap == 0 ] && [ $Mem -le 512 ];then 31 | dd if=/dev/zero of=/swapfile count=1024 bs=1M 32 | mkswap /swapfile 33 | swapon /swapfile 34 | chown root:root /swapfile 35 | chmod 0600 /swapfile 36 | elif [ $Swap == 0 ] && [ $Mem -gt 512 -a $Mem -le 1024 ];then 37 | dd if=/dev/zero of=/swapfile count=2048 bs=1M 38 | mkswap /swapfile 39 | swapon /swapfile 40 | chown root:root /swapfile 41 | chmod 0600 /swapfile 42 | elif [ $Swap == 0 ] && [ $Mem -gt 1500 ];then 43 | dd if=/dev/zero of=/swapfile count=$Mem bs=1M 44 | mkswap /swapfile 45 | swapon /swapfile 46 | chown root:root /swapfile 47 | chmod 0600 /swapfile 48 | fi 49 | 50 | cat >> /etc/fstab << EOF 51 | /swapfile swap swap defaults 0 0 52 | 53 | EOF 54 | fi 55 | 56 | # PS1 57 | [ -z "`cat ~/.bashrc | grep ^PS1`" ] && echo "PS1='\${debian_chroot:+(\$debian_chroot)}\\[\\e[1;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ '" >> ~/.bashrc 58 | 59 | # history size 60 | sed -i 's/HISTSIZE=.*$/HISTSIZE=100/g' ~/.bashrc 61 | [ -z "`cat ~/.bashrc | grep history-timestamp`" ] && echo "export PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });user=\$(whoami); echo \$(date \"+%Y-%m-%d %H:%M:%S\"):\$user:\`pwd\`/:\$msg ---- \$(who am i); } >> /tmp/\`hostname\`.\`whoami\`.history-timestamp'" >> ~/.bashrc 62 | 63 | # /etc/security/limits.conf 64 | [ -z "`cat /etc/security/limits.conf | grep 'nproc 65535'`" ] && cat >> /etc/security/limits.conf <> /etc/rc.local 71 | 72 | # /etc/hosts 73 | [ "$(hostname -i | awk '{print $1}')" != "127.0.0.1" ] && sed -i "s@^127.0.0.1\(.*\)@127.0.0.1 `hostname` \1@" /etc/hosts 74 | 75 | # Set timezone 76 | rm -rf /etc/localtime 77 | ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 78 | 79 | # Set DNS 80 | #cat > /etc/resolv.conf << EOF 81 | #nameserver 114.114.114.114 82 | #nameserver 8.8.8.8 83 | #EOF 84 | 85 | # alias vi 86 | [ -z "`cat ~/.bashrc | grep 'alias vi='`" ] && sed -i "s@^alias l=\(.*\)@alias l=\1\nalias vi='vim'@" ~/.bashrc 87 | 88 | # /etc/sysctl.conf 89 | [ -z "`cat /etc/sysctl.conf | grep 'fs.file-max'`" ] && cat >> /etc/sysctl.conf << EOF 90 | fs.file-max=65535 91 | net.ipv4.tcp_syncookies = 1 92 | net.ipv4.tcp_fin_timeout = 30 93 | net.ipv4.tcp_tw_reuse = 1 94 | net.ipv4.tcp_tw_recycle = 1 95 | net.ipv4.ip_local_port_range = 1024 65000 96 | net.ipv4.tcp_max_syn_backlog = 262144 97 | net.ipv4.tcp_max_tw_buckets = 6000 98 | net.ipv4.route.gc_timeout = 100 99 | net.ipv4.tcp_syn_retries = 1 100 | net.ipv4.tcp_synack_retries = 1 101 | net.core.somaxconn = 65535 102 | net.core.netdev_max_backlog = 262144 103 | net.ipv4.tcp_timestamps = 0 104 | net.ipv4.tcp_max_orphans = 262144 105 | EOF 106 | sysctl -p 107 | 108 | sed -i 's@^ACTIVE_CONSOLES.*@ACTIVE_CONSOLES="/dev/tty[1-2]"@' /etc/default/console-setup 109 | sed -i 's@^@#@g' /etc/init/tty[3-6].conf 110 | echo 'en_US.UTF-8 UTF-8' > /var/lib/locales/supported.d/local 111 | sed -i 's@^@#@g' /etc/init/control-alt-delete.conf 112 | 113 | # Update time 114 | ntpdate pool.ntp.org 115 | echo "*/20 * * * * `which ntpdate` pool.ntp.org > /dev/null 2>&1" >> /var/spool/cron/crontabs/root;chmod 600 /var/spool/cron/crontabs/root 116 | service cron restart 117 | 118 | # iptables 119 | cat > /etc/iptables.up.rules << EOF 120 | # Firewall configuration written by system-config-securitylevel 121 | # Manual customization of this file is not recommended. 122 | *filter 123 | :INPUT DROP [0:0] 124 | :FORWARD ACCEPT [0:0] 125 | :OUTPUT ACCEPT [0:0] 126 | :syn-flood - [0:0] 127 | -A INPUT -i lo -j ACCEPT 128 | -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT 129 | -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT 130 | -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT 131 | -A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT 132 | -A INPUT -p icmp -m limit --limit 100/sec --limit-burst 100 -j ACCEPT 133 | -A INPUT -p icmp -m limit --limit 1/s --limit-burst 10 -j ACCEPT 134 | -A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j syn-flood 135 | -A INPUT -j REJECT --reject-with icmp-host-prohibited 136 | -A syn-flood -p tcp -m limit --limit 3/sec --limit-burst 6 -j RETURN 137 | -A syn-flood -j REJECT --reject-with icmp-port-unreachable 138 | COMMIT 139 | EOF 140 | iptables-restore < /etc/iptables.up.rules 141 | echo 'pre-up iptables-restore < /etc/iptables.up.rules' >> /etc/network/interfaces 142 | 143 | . ~/.bashrc 144 | -------------------------------------------------------------------------------- /init/init_Ubuntu_hhvm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cat /etc/issue 3 | uname -a 4 | apt-get -y update 5 | 6 | for Package in apache2 apache2-doc apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-doc apache2-mpm-worker mysql-client mysql-server mysql-common php5 php5-common php5-cgi php5-mysql php5-curl php5-gd libmysql* mysql-* 7 | do 8 | apt-get -y remove $Package 9 | done 10 | dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P 11 | 12 | apt-get -y update 13 | 14 | # check upgrade OS 15 | [ "$upgrade_yn" == 'y' ] && apt-get -y upgrade 16 | 17 | # Install needed packages 18 | for Package in gcc g++ make autoconf ntpdate libjpeg8 libjpeg8-dev libpng12-0 libpng12-dev libpng3 libfreetype6 libfreetype6-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev curl libcurl3 libcurl4-openssl-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl libtool libevent-dev bison libsasl2-dev libxslt1-dev patch vim zip unzip tmux htop wget bc dc expect rsync libpcre3 libpcre3-dev libssl-dev 19 | do 20 | apt-get -y install $Package 21 | done 22 | 23 | if [ ! -z "`cat /etc/issue | grep 13`" ];then 24 | apt-get -y install libcloog-ppl1 25 | elif [ ! -z "`cat /etc/issue | grep 12`" ];then 26 | apt-get -y install libcloog-ppl0 27 | fi 28 | 29 | # Modify swap 30 | Mem=`free -m | awk '/Mem:/{print $2}'` 31 | Swap=`free -m | grep 'Swap:' | awk '{print $2}'` 32 | if [ $Swap == 0 ] ;then 33 | if [ $Swap == 0 ] && [ $Mem -le 512 ];then 34 | dd if=/dev/zero of=/swapfile count=1024 bs=1M 35 | mkswap /swapfile 36 | swapon /swapfile 37 | chown root:root /swapfile 38 | chmod 0600 /swapfile 39 | elif [ $Swap == 0 ] && [ $Mem -gt 512 -a $Mem -le 1024 ];then 40 | dd if=/dev/zero of=/swapfile count=2048 bs=1M 41 | mkswap /swapfile 42 | swapon /swapfile 43 | chown root:root /swapfile 44 | chmod 0600 /swapfile 45 | elif [ $Swap == 0 ] && [ $Mem -gt 1500 ];then 46 | dd if=/dev/zero of=/swapfile count=$Mem bs=1M 47 | mkswap /swapfile 48 | swapon /swapfile 49 | chown root:root /swapfile 50 | chmod 0600 /swapfile 51 | fi 52 | 53 | cat >> /etc/fstab << EOF 54 | /swapfile swap swap defaults 0 0 55 | 56 | EOF 57 | fi 58 | 59 | # PS1 60 | [ -z "`cat ~/.bashrc | grep ^PS1`" ] && echo "PS1='\${debian_chroot:+(\$debian_chroot)}\\[\\e[1;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ '" >> ~/.bashrc 61 | 62 | # history size 63 | sed -i 's/HISTSIZE=.*$/HISTSIZE=100/g' ~/.bashrc 64 | [ -z "`cat ~/.bashrc | grep history-timestamp`" ] && echo "export PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });user=\$(whoami); echo \$(date \"+%Y-%m-%d %H:%M:%S\"):\$user:\`pwd\`/:\$msg ---- \$(who am i); } >> /tmp/\`hostname\`.\`whoami\`.history-timestamp'" >> ~/.bashrc 65 | 66 | # /etc/security/limits.conf 67 | [ -z "`cat /etc/security/limits.conf | grep 'nproc 65535'`" ] && cat >> /etc/security/limits.conf <> /etc/rc.local 74 | 75 | # /etc/hosts 76 | [ "$(hostname -i | awk '{print $1}')" != "127.0.0.1" ] && sed -i "s@^127.0.0.1\(.*\)@127.0.0.1 `hostname` \1@" /etc/hosts 77 | 78 | # Set timezone 79 | rm -rf /etc/localtime 80 | ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 81 | 82 | # Set DNS 83 | #cat > /etc/resolv.conf << EOF 84 | #nameserver 114.114.114.114 85 | #nameserver 8.8.8.8 86 | #EOF 87 | 88 | # alias vi 89 | [ -z "`cat ~/.bashrc | grep 'alias vi='`" ] && sed -i "s@^alias l=\(.*\)@alias l=\1\nalias vi='vim'@" ~/.bashrc 90 | 91 | # /etc/sysctl.conf 92 | [ -z "`cat /etc/sysctl.conf | grep 'fs.file-max'`" ] && cat >> /etc/sysctl.conf << EOF 93 | fs.file-max=65535 94 | net.ipv4.tcp_syncookies = 1 95 | net.ipv4.tcp_fin_timeout = 30 96 | net.ipv4.tcp_tw_reuse = 1 97 | net.ipv4.tcp_tw_recycle = 1 98 | net.ipv4.ip_local_port_range = 1024 65000 99 | net.ipv4.tcp_max_syn_backlog = 262144 100 | net.ipv4.tcp_max_tw_buckets = 6000 101 | net.ipv4.route.gc_timeout = 100 102 | net.ipv4.tcp_syn_retries = 1 103 | net.ipv4.tcp_synack_retries = 1 104 | net.core.somaxconn = 65535 105 | net.core.netdev_max_backlog = 262144 106 | net.ipv4.tcp_timestamps = 0 107 | net.ipv4.tcp_max_orphans = 262144 108 | EOF 109 | sysctl -p 110 | 111 | sed -i 's@^ACTIVE_CONSOLES.*@ACTIVE_CONSOLES="/dev/tty[1-2]"@' /etc/default/console-setup 112 | sed -i 's@^@#@g' /etc/init/tty[3-6].conf 113 | echo 'en_US.UTF-8 UTF-8' > /var/lib/locales/supported.d/local 114 | sed -i 's@^@#@g' /etc/init/control-alt-delete.conf 115 | 116 | # Update time 117 | ntpdate pool.ntp.org 118 | echo "*/20 * * * * `which ntpdate` pool.ntp.org > /dev/null 2>&1" >> /var/spool/cron/crontabs/root;chmod 600 /var/spool/cron/crontabs/root 119 | service cron restart 120 | 121 | # iptables 122 | cat > /etc/iptables.up.rules << EOF 123 | # Firewall configuration written by system-config-securitylevel 124 | # Manual customization of this file is not recommended. 125 | *filter 126 | :INPUT DROP [0:0] 127 | :FORWARD ACCEPT [0:0] 128 | :OUTPUT ACCEPT [0:0] 129 | :syn-flood - [0:0] 130 | -A INPUT -i lo -j ACCEPT 131 | -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT 132 | -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT 133 | -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT 134 | -A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT 135 | -A INPUT -p icmp -m limit --limit 100/sec --limit-burst 100 -j ACCEPT 136 | -A INPUT -p icmp -m limit --limit 1/s --limit-burst 10 -j ACCEPT 137 | -A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j syn-flood 138 | -A INPUT -j REJECT --reject-with icmp-host-prohibited 139 | -A syn-flood -p tcp -m limit --limit 3/sec --limit-burst 6 -j RETURN 140 | -A syn-flood -j REJECT --reject-with icmp-port-unreachable 141 | COMMIT 142 | EOF 143 | iptables-restore < /etc/iptables.up.rules 144 | echo 'pre-up iptables-restore < /etc/iptables.up.rules' >> /etc/network/interfaces 145 | 146 | . ~/.bashrc 147 | -------------------------------------------------------------------------------- /options.conf: -------------------------------------------------------------------------------- 1 | # operating environment for the current working directory 2 | ltmh_dir= 3 | 4 | # set the default install path, you can freely specify 5 | nginx_install_dir=/usr/local/nginx 6 | tengine_install_dir=/usr/local/nginx 7 | mysql_install_dir=/usr/local/mysql 8 | mariadb_install_dir=/usr/local/mysql 9 | hhvm_install_dir=/usr/share/hhvm 10 | php_install_dir=/usr/local/php 11 | 12 | pureftpd_install_dir=/usr/local/pureftpd 13 | 14 | memcached_install_dir=/usr/local/memcached 15 | 16 | redis_install_dir=/usr/local/redis 17 | 18 | ######################################################################### 19 | # database data storage directory, you can freely specify 20 | mysql_data_dir=/data/mysql 21 | mariadb_data_dir=/data/mysql 22 | 23 | # web directory, you can customize, which default directory to store ftp. 24 | # (User_manager_for-PureFTPd Proposal to modify the name for security) 25 | home_dir=/home/wwwroot 26 | 27 | # nginx Generate a log storage directory, you can freely specify. 28 | wwwlogs_dir=/home/wwwlogs 29 | 30 | ######################################################################### 31 | # automatically generated, You can't change 32 | web_install_dir=/usr/local/nginx 33 | 34 | db_install_dir= 35 | 36 | db_data_dir= 37 | 38 | dbrootpwd= 39 | 40 | ftpmanagerpwd= 41 | 42 | conn_ftpusers_dbpwd= 43 | 44 | ######################################################################### 45 | # Backup Dest directory, change this if you have someother location 46 | 47 | space=x 48 | # backup needed script file directory, access to the current directory. 49 | scriptdir=/home/ltmh/backup 50 | # seven bovine AccessKey, to the http://portal.qiniu.com/ acquisition, log on seven may seven cattle in the "account settings" - "key" can be found in the. 51 | qiniuAccessKey=123456 52 | # seven bovine SecretKey, to the http://portal.qiniu.com/ acquisition, log on seven may seven cattle in the "account settings" - "key" can be found in the. 53 | QINIUSecretKey=123456 54 | # backup password, please enter the password to 20 characters of high strength more than zip, the brute force attack speed very quickly. 55 | backup_file_compression_password=123456 56 | # to backup the database name, such as the need to back up multiple sites or multiple databases make a script execution between different, this can reduce #server because of backup performance by. 57 | database_name=123456 58 | #Mysql user name (export authority, must have the corresponding database can use root, can also be used to bind the user name of the database) 59 | mysql_user=root 60 | #mysqlpassword 61 | mysql_passwd=123456 62 | # database is sent to the mailbox, if you need to install mail and remove the bank and the related notes 63 | info_sent_mail_to=admin@hhvmc.com 64 | # to backup site code directory. 65 | #home_dir=/home/wwwroot 66 | #mysqldump address 67 | mysqldump_dir=/usr/local/mysql/bin/mysqldump 68 | # backup configuration file location 69 | nginx_configuration_file=/usr/local/nginx/conf 70 | # local backup directory. 71 | local_bankup=/home/backup 72 | # local backup retention time 73 | expired_days=2 74 | #domain name 75 | domain_name=hhvmc.com 76 | # tasks: script timed execution time 77 | backup_time="10 3 * * * date" 78 | 79 | -------------------------------------------------------------------------------- /shell/GraphicsMagick.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | Install_GraphicsMagick() 3 | { 4 | cd $ltmh_dir/src 5 | . ../tools/download.sh 6 | . ../options.conf 7 | 8 | src_url=http://downloads.sourceforge.net/project/graphicsmagick/graphicsmagick/1.3.21/GraphicsMagick-1.3.21.tar.gz && Download_src 9 | 10 | tar xzf GraphicsMagick-1.3.21.tar.gz 11 | cd GraphicsMagick-1.3.21 12 | ./configure --enable-shared 13 | make && make install 14 | cd ../ 15 | /bin/rm -rf GraphicsMagick-1.3.21 16 | 17 | if [ -e "$php_install_dir/bin/phpize" ];then 18 | src_url=http://pecl.php.net/get/gmagick-1.1.7RC2.tgz && Download_src 19 | tar xzf gmagick-1.1.7RC2.tgz 20 | cd gmagick-1.1.7RC2 21 | make clean 22 | export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig 23 | $php_install_dir/bin/phpize 24 | ./configure --with-php-config=$php_install_dir/bin/php-config 25 | make && make install 26 | cd ../ 27 | /bin/rm -rf gmagick-1.1.7RC2 28 | 29 | if [ -f "$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/gmagick.so" ];then 30 | [ -z "`cat $php_install_dir/etc/php.ini | grep '^extension_dir'`" ] && sed -i "s@extension_dir = \"ext\"@extension_dir = \"ext\"\nextension_dir = \"$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`\"@" $php_install_dir/etc/php.ini 31 | sed -i 's@^extension_dir\(.*\)@extension_dir\1\nextension = "gmagick.so"@' $php_install_dir/etc/php.ini 32 | service php-fpm restart 33 | else 34 | echo -e "\033[31mPHP Gmagick module install failed, Please contact the author! \033[0m" 35 | fi 36 | fi 37 | cd ../ 38 | } 39 | -------------------------------------------------------------------------------- /shell/ImageMagick.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Install_ImageMagick() 4 | { 5 | cd $ltmh_dir/src 6 | . ../tools/download.sh 7 | . ../options.conf 8 | 9 | src_url=http://www.imagemagick.org/download/ImageMagick-6.9.0-10.tar.xz && Download_src 10 | 11 | tar Jxf ImageMagick-6.9.0-10.tar.xz 12 | cd ImageMagick-6.9.0-10 13 | ./configure 14 | make && make install 15 | cd ../ 16 | /bin/rm -rf ImageMagick-6.9.0-10 17 | ln -s /usr/local/include/ImageMagick-6 /usr/local/include/ImageMagick 18 | 19 | if [ -e "$php_install_dir/bin/phpize" ];then 20 | src_url=http://pecl.php.net/get/imagick-3.1.2.tgz && Download_src 21 | tar xzf imagick-3.1.2.tgz 22 | cd imagick-3.1.2 23 | make clean 24 | export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig 25 | $php_install_dir/bin/phpize 26 | ./configure --with-php-config=$php_install_dir/bin/php-config 27 | make && make install 28 | cd ../ 29 | /bin/rm -rf imagick-3.1.2 30 | 31 | if [ -f "$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/imagick.so" ];then 32 | [ -z "`cat $php_install_dir/etc/php.ini | grep '^extension_dir'`" ] && sed -i "s@extension_dir = \"ext\"@extension_dir = \"ext\"\nextension_dir = \"$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`\"@" $php_install_dir/etc/php.ini 33 | sed -i 's@^extension_dir\(.*\)@extension_dir\1\nextension = "imagick.so"@' $php_install_dir/etc/php.ini 34 | service php-fpm restart 35 | echo -e "\033[31mPHP imagick module install failed, Please contact the author! \033[0m" 36 | fi 37 | fi 38 | cd ../ 39 | } 40 | -------------------------------------------------------------------------------- /shell/ZendGuardLoader.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Install_ZendGuardLoader() 4 | { 5 | cd $ltmh_dir/src 6 | . ../tools/download.sh 7 | . ../options.conf 8 | 9 | php_version=`$php_install_dir/bin/php -r 'echo PHP_VERSION;'` 10 | PHP_version=${php_version%.*} 11 | 12 | [ ! -e "$php_install_dir/lib/php/extensions/" ] && mkdir $php_install_dir/lib/php/extensions/ 13 | if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 64 ] ;then 14 | if [ "$PHP_version" == '5.4' ];then 15 | src_url=http://soft.hhvm.biz/php/lib/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz && Download_src 16 | tar xzf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz 17 | /bin/cp ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64/php-5.4.x/ZendGuardLoader.so $php_install_dir/lib/php/extensions/ 18 | /bin/rm -rf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64 19 | fi 20 | 21 | if [ "$PHP_version" == '5.3' ];then 22 | src_url=http://soft.hhvm.biz/php/lib/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz && Download_src 23 | tar xzf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz 24 | /bin/cp ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so $php_install_dir/lib/php/extensions/ 25 | /bin/rm -rf ZendGuardLoader-php-5.3-linux-glibc23-x86_64 26 | fi 27 | else 28 | if [ "$PHP_version" == '5.4' ];then 29 | src_url=http://soft.hhvm.biz/php/lib/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386.tar.gz && Download_src 30 | tar xzf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386.tar.gz 31 | /bin/cp ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386/php-5.4.x/ZendGuardLoader.so $php_install_dir/lib/php/extensions/ 32 | /bin/rm -rf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386 33 | fi 34 | 35 | if [ "$PHP_version" == '5.3' ];then 36 | src_url=http://soft.hhvm.biz/php/lib/ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz && Download_src 37 | tar xzf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz 38 | /bin/cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/ZendGuardLoader.so $php_install_dir/lib/php/extensions/ 39 | /bin/rm -rf ZendGuardLoader-php-5.3-linux-glibc23-i386 40 | fi 41 | fi 42 | 43 | if [ -f "$php_install_dir/lib/php/extensions/ZendGuardLoader.so" ];then 44 | cat >> $php_install_dir/etc/php.ini << EOF 45 | [Zend Guard Loader] 46 | zend_extension="/usr/local/php/lib/php/extensions/ZendGuardLoader.so" 47 | zend_loader.enable=1 48 | zend_loader.disable_licensing=0 49 | zend_loader.obfuscation_level_support=3 50 | EOF 51 | service php-fpm restart 52 | echo -e "\033[31meZendGuardLoader module install failed, Please contact the author! \033[0m" 53 | fi 54 | cd ../ 55 | } 56 | -------------------------------------------------------------------------------- /shell/apcu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Install_APCU() 4 | { 5 | cd $ltmh_dir/src 6 | . ../tools/download.sh 7 | . ../options.conf 8 | 9 | src_url=http://pecl.php.net/get/apcu-4.0.6.tgz && Download_src 10 | tar xzf apcu-4.0.6.tgz 11 | cd apcu-4.0.6 12 | make clean 13 | $php_install_dir/bin/phpize 14 | ./configure --with-php-config=$php_install_dir/bin/php-config 15 | make && make install 16 | if [ -f "$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/apcu.so" ];then 17 | cat >> $php_install_dir/etc/php.ini << EOF 18 | extension = apcu.so 19 | apc.enabled=1 20 | apc.shm_size=32M 21 | apc.ttl=7200 22 | apc.enable_cli=1 23 | EOF 24 | service php-fpm restart 25 | /bin/cp apc.php $home_dir/default 26 | else 27 | echo -e "\033[31meAPCU module install failed, Please contact the author! \033[0m" 28 | fi 29 | cd ../../ 30 | } 31 | -------------------------------------------------------------------------------- /shell/eaccelerator-0.9.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Install_eAccelerator-0-9() 4 | { 5 | cd $ltmh_dir/src 6 | . ../functions/download.sh 7 | . ../options.conf 8 | 9 | src_url=https://github.com/downloads/eaccelerator/eaccelerator/eaccelerator-0.9.6.1.tar.bz2 && Download_src 10 | tar jxf eaccelerator-0.9.6.1.tar.bz2 11 | cd eaccelerator-0.9.6.1 12 | make clean 13 | $php_install_dir/bin/phpize 14 | ./configure --enable-eaccelerator=shared --with-php-config=$php_install_dir/bin/php-config 15 | make && make install 16 | 17 | if [ -f "$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/eaccelerator.so" ];then 18 | mkdir /var/eaccelerator_cache;chown -R www.www /var/eaccelerator_cache 19 | cat >> $php_install_dir/etc/php.ini << EOF 20 | [eaccelerator] 21 | zend_extension="$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/eaccelerator.so" 22 | eaccelerator.shm_size="64" 23 | eaccelerator.cache_dir="/var/eaccelerator_cache" 24 | eaccelerator.enable="1" 25 | eaccelerator.optimizer="1" 26 | eaccelerator.check_mtime="1" 27 | eaccelerator.debug="0" 28 | eaccelerator.filter="" 29 | eaccelerator.shm_max="0" 30 | eaccelerator.shm_ttl="0" 31 | eaccelerator.shm_prune_period="0" 32 | eaccelerator.shm_only="0" 33 | eaccelerator.compress="0" 34 | eaccelerator.compress_level="9" 35 | eaccelerator.keys = "disk_only" 36 | eaccelerator.sessions = "disk_only" 37 | eaccelerator.content = "disk_only" 38 | EOF 39 | echo 'kernel.shmmax = 67108864' >> /etc/sysctl.conf 40 | sysctl -p 41 | service php-fpm restart 42 | echo -e "\033[31meAccelerator module install failed, Please contact the author! \033[0m" 43 | fi 44 | cd .. 45 | /bin/rm -rf eaccelerator-0.9.6.1 46 | cd .. 47 | } 48 | -------------------------------------------------------------------------------- /shell/eaccelerator-1.0-dev.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Install_eAccelerator-1-0-dev() 4 | { 5 | cd $ltmh_dir/src 6 | . ../functions/download.sh 7 | . ../options.conf 8 | 9 | src_url=https://github.com/eaccelerator/eaccelerator/tarball/master && Download_src 10 | /bin/mv master eaccelerator-eaccelerator-42067ac.tar.gz 11 | tar xzf eaccelerator-eaccelerator-42067ac.tar.gz 12 | cd eaccelerator-eaccelerator-42067ac 13 | make clean 14 | $php_install_dir/bin/phpize 15 | ./configure --enable-eaccelerator=shared --with-php-config=$php_install_dir/bin/php-config 16 | make && make install 17 | if [ -f "$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/eaccelerator.so" ];then 18 | mkdir /var/eaccelerator_cache;chown -R www.www /var/eaccelerator_cache 19 | cat >> $php_install_dir/etc/php.ini << EOF 20 | [eaccelerator] 21 | zend_extension="$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/eaccelerator.so" 22 | eaccelerator.shm_size="64" 23 | eaccelerator.cache_dir="/var/eaccelerator_cache" 24 | eaccelerator.enable="1" 25 | eaccelerator.optimizer="1" 26 | eaccelerator.check_mtime="1" 27 | eaccelerator.debug="0" 28 | eaccelerator.filter="" 29 | eaccelerator.shm_max="0" 30 | eaccelerator.shm_ttl="0" 31 | eaccelerator.shm_prune_period="0" 32 | eaccelerator.shm_only="0" 33 | eaccelerator.compress="0" 34 | eaccelerator.compress_level="9" 35 | eaccelerator.keys = "disk_only" 36 | eaccelerator.sessions = "disk_only" 37 | eaccelerator.content = "disk_only" 38 | EOF 39 | echo 'kernel.shmmax = 67108864' >> /etc/sysctl.conf 40 | sysctl -p 41 | service php-fpm restart 42 | echo -e "\033[31meAccelerator module install failed, Please contact the author! \033[0m" 43 | fi 44 | cd .. 45 | /bin/rm -rf eaccelerator-eaccelerator-42067ac 46 | cd .. 47 | } 48 | -------------------------------------------------------------------------------- /shell/hhvm-3.1_Debian.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | Install_hhvm() 3 | { 4 | cd $ltmh_dir/src 5 | . ../tools/download.sh 6 | . ../tools/check_os.sh 7 | . ../options.conf 8 | 9 | #src_url=http://dl.hiphop-php.com/debian/pool/main/h/hhvm/hhvm_3.1.0~wheezy_amd64.deb && Download_src 10 | src_url=http://dl.hhvm.com/debian/pool/main/h/hhvm/hhvm_3.1.0~wheezy_amd64.deb && Download_src 11 | #wget -O - http://sg.hhvm.mirrors.simon.geek.nz/conf/hhvm.gpg.key | apt-key add - 12 | deb http://sg.hhvm.mirrors.simon.geek.nz/debian wheezy main 13 | wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | apt-key add - 14 | echo deb http://dl.hhvm.com/debian wheezy main | tee /etc/apt/sources.list.d/hhvm.list 15 | #echo deb http://sg.hhvm.mirrors.simon.geek.nz/debian wheezy main | tee /etc/apt/sources.list.d/hhvm.list 16 | #wget http://dl.hiphop-php.com/conf/hhvm.gpg.key | apt-key add - 17 | #echo deb http://dl.hiphop-php.com/debian wheezy main | tee /etc/apt/sources.list.d/hhvm.list 18 | apt-get update 19 | #aptitude upgrade 20 | apt-get -y install hhvm 21 | apt-get -y remove hhvm 22 | dpkg -i hhvm_3.1.0~wheezy_amd64.deb 23 | /usr/share/hhvm/install_fastcgi.sh 24 | update-rc.d hhvm defaults 25 | service hhvm restart 26 | } 27 | -------------------------------------------------------------------------------- /shell/hhvm-3.3_Debian.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | Install_hhvm() 3 | { 4 | cd $ltmh_dir/src 5 | . ../tools/download.sh 6 | . ../tools/check_os.sh 7 | . ../options.conf 8 | 9 | #src_url=http://dl.hhvm.com/debian/pool/main/h/hhvm/hhvm_3.1.0~wheezy_amd64.deb && Download_src 10 | src_url=http://sg.hhvm.mirrors.simon.geek.nz/debian/pool/main/h/hhvm/hhvm_3.3.0~wheezy_amd64.deb && Download_src 11 | wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | apt-key add - 12 | echo deb http://dl.hhvm.com/debian wheezy main | tee /etc/apt/sources.list.d/hhvm.list 13 | apt-get update 14 | apt-get -y install libgmp-dev libmemcachedutil2 15 | apt-get -y install hhvm 16 | apt-get -y install libgmp-dev libmemcachedutil2 17 | /usr/share/hhvm/install_fastcgi.sh 18 | update-rc.d hhvm defaults 19 | apt-get -y remove hhvm 20 | dpkg -i hhvm_3.3.0~wheezy_amd64.deb 21 | /usr/share/hhvm/install_fastcgi.sh 22 | update-rc.d hhvm defaults 23 | service hhvm stop 24 | /bin/rm -f /etc/hhvm/server.ini 25 | cd .. 26 | /bin/cp conf/server.ini /etc/hhvm/server.ini 27 | #service hhvm restart 28 | cat >> /etc/hhvm/php.ini << EOF 29 | hhvm.mysql.socket = /tmp/mysql.sock 30 | memory_limit = 256M 31 | post_max_size = 50M 32 | EOF 33 | 34 | mv /etc/mysql/my.cnf{,_bk} 35 | 36 | } 37 | -------------------------------------------------------------------------------- /shell/hhvm_CentOS.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Install_hhvm() 4 | { 5 | cd $ltmh_dir/src 6 | . ../tools/download.sh 7 | . ../tools/check_os.sh 8 | . ../options.conf 9 | 10 | 11 | # 12 | yum -y remove hhvm 13 | yum --nogpgcheck -y install libbson 14 | wget -c http://soft.hhvmc.com/dl/centos6/hhvm-stable-3.3.0-1.el6.x86_64.rpm 15 | rpm -ivh hhvm-stable-3.3.0-1.el6.x86_64.rpm 16 | useradd -M -s /sbin/nologin www 17 | chown -R www:www /var/run/hhvm/ 18 | /bin/rm -f /etc/init.d/hhvm 19 | /bin/rm -f /etc/hhvm/server.ini 20 | cd .. 21 | /bin/cp init/HHVM-init-CentOS /etc/init.d/hhvm 22 | /bin/cp conf/server.ini /etc/hhvm/server.ini 23 | chmod +x /etc/init.d/hhvm 24 | rm -rf hhvm-stable-3.3.0-1.el6.x86_64.rpm 25 | cat >> /etc/hhvm/php.ini << EOF 26 | hhvm.mysql.socket = /tmp/mysql.sock 27 | memory_limit = 256M 28 | post_max_size = 50M 29 | EOF 30 | #service hhvm restart 31 | chkconfig hhvm on 32 | } 33 | 34 | -------------------------------------------------------------------------------- /shell/hhvm_Ubuntu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Install_hhvm() 4 | { 5 | cd $ltmh_dir/src 6 | . ../tools/download.sh 7 | . ../tools/check_os.sh 8 | . ../options.conf 9 | 10 | #src_url=http://dl.hhvm.com/ubuntu/pool/main/h/hhvm/hhvm_3.1.0~trusty_amd64.deb && Download_src 11 | src_url=http://sg.hhvm.mirrors.simon.geek.nz/ubuntu/pool/main/h/hhvm/hhvm_3.3.0~trusty_amd64.deb && Download_src 12 | wget -O - http://mirror.mephi.ru/hhvm/conf/hhvm.gpg.key | apt-key add - 13 | echo deb http://mirror.mephi.ru/hhvm/ubuntu trusty main | tee /etc/apt/sources.list.d/hhvm.list 14 | apt-get update 15 | apt-get -y install libgnutls26 16 | wget -c http://security.ubuntu.com/ubuntu/pool/main/libm/libmemcached/libmemcached10_1.0.8-1ubuntu2_amd64.deb 17 | wget -c http://mirrors.kernel.org/ubuntu/pool/main/r/rtmpdump/librtmp0_2.4+20121230.gitdf6c518-1_amd64.deb 18 | dpkg -i libmemcached10_1.0.8-1ubuntu2_amd64.deb 19 | dpkg -i librtmp0_2.4+20121230.gitdf6c518-1_amd64.deb 20 | apt-get -y install libgmp-dev libmemcachedutil2 21 | apt-get -y install hhvm 22 | /usr/share/hhvm/install_fastcgi.sh 23 | update-rc.d hhvm defaults 24 | apt-get -y remove hhvm 25 | dpkg -i hhvm_3.3.0~trusty_amd64.deb 26 | /usr/share/hhvm/install_fastcgi.sh 27 | update-rc.d hhvm defaults 28 | service hhvm stop 29 | /bin/rm -f /etc/hhvm/server.ini 30 | cd .. 31 | /bin/cp conf/server.ini /etc/hhvm/server.ini 32 | #service hhvm restart 33 | cat >> /etc/hhvm/php.ini << EOF 34 | hhvm.mysql.socket = /tmp/mysql.sock 35 | memory_limit = 256M 36 | post_max_size = 50M 37 | EOF 38 | 39 | rm -rf libmemcached10_1.0.8-1ubuntu2_amd64.deb 40 | rm -rf librtmp0_2.4+20121230.gitdf6c518-1_amd64.deb 41 | rm -rf hhvm_3.3.0~trusty_amd64.deb 42 | mv /etc/mysql/my.cnf{,_bk} 43 | 44 | } 45 | -------------------------------------------------------------------------------- /shell/ioncube.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Install_ionCube() 4 | { 5 | cd $ltmh_dir/src 6 | . ../tools/download.sh 7 | . ../options.conf 8 | 9 | php_version=`$php_install_dir/bin/php -r 'echo PHP_VERSION;'` 10 | PHP_version=${php_version%.*} 11 | 12 | if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 64 ] ;then 13 | src_url=http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz && Download_src 14 | tar xzf ioncube_loaders_lin_x86-64.tar.gz 15 | else 16 | src_url=http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz && Download_src 17 | tar xzf ioncube_loaders_lin_x86.tar.gz 18 | fi 19 | 20 | [ ! -e "$php_install_dir/lib/php/extensions/" ] && mkdir $php_install_dir/lib/php/extensions/ 21 | if [ "$PHP_version" == '5.5' ];then 22 | /bin/cp ioncube/ioncube_loader_lin_5.5.so $php_install_dir/lib/php/extensions/ 23 | zend_extension="$php_install_dir/lib/php/extensions/ioncube_loader_lin_5.5.so" 24 | elif [ "$PHP_version" == '5.4' ];then 25 | /bin/cp ioncube/ioncube_loader_lin_5.4.so $php_install_dir/lib/php/extensions/ 26 | zend_extension="$php_install_dir/lib/php/extensions/ioncube_loader_lin_5.4.so" 27 | elif [ "$PHP_version" == '5.3' ];then 28 | /bin/cp ioncube/ioncube_loader_lin_5.3.so $php_install_dir/lib/php/extensions/ 29 | zend_extension="$php_install_dir/lib/php/extensions/ioncube_loader_lin_5.3.so" 30 | fi 31 | 32 | /bin/rm -rf ioncube 33 | if [ -n "`grep '^\[opcache\]' $php_install_dir/etc/php.ini`" -a -z "`grep '^\[ionCube Loader\]' $php_install_dir/etc/php.ini`" ];then 34 | sed -i "s@^\[opcache\]@[ionCube Loader]\nzend_extension=\"$zend_extension\"\n[opcache]@" $php_install_dir/etc/php.ini 35 | elif [ -z "`grep '^\[ionCube Loader\]' $php_install_dir/etc/php.ini`" ];then 36 | cat >> $php_install_dir/etc/php.ini << EOF 37 | [ionCube Loader] 38 | zend_extension="$zend_extension" 39 | EOF 40 | fi 41 | service php-fpm restart 42 | cd ../ 43 | } 44 | -------------------------------------------------------------------------------- /shell/jemalloc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Install_jemalloc() 4 | { 5 | cd $ltmh_dir/src 6 | . ../tools/download.sh 7 | 8 | src_url=http://www.canonware.com/download/jemalloc/jemalloc-3.6.0.tar.bz2 && Download_src 9 | 10 | tar xjf jemalloc-3.6.0.tar.bz2 11 | cd jemalloc-3.6.0 12 | ./configure 13 | make && make install 14 | if [ -f "/usr/local/lib/libjemalloc.so" ];then 15 | echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf 16 | ldconfig 17 | else 18 | echo -e "\033[31mjemalloc install failed, Please contact the author! \033[0m" 19 | kill -9 $$ 20 | fi 21 | cd .. 22 | /bin/rm -rf jemalloc-3.6.0 23 | cd .. 24 | } 25 | -------------------------------------------------------------------------------- /shell/memcached.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Install_memcached() 4 | { 5 | cd $ltmh_dir/src 6 | . ../tools/download.sh 7 | . ../tools/check_os.sh 8 | . ../options.conf 9 | 10 | src_url=http://www.memcached.org/files/memcached-1.4.20.tar.gz && Download_src 11 | 12 | # memcached server 13 | useradd -M -s /sbin/nologin memcached 14 | tar xzf memcached-1.4.20.tar.gz 15 | cd memcached-1.4.20 16 | ./configure --prefix=$memcached_install_dir 17 | make && make install 18 | cd ../ 19 | /bin/rm -rf memcached-1.4.20 20 | if [ -d "$memcached_install_dir" ];then 21 | echo -e "\033[32mmemcached install successfully! \033[0m" 22 | ln -s $memcached_install_dir/bin/memcached /usr/bin/memcached 23 | OS_CentOS='/bin/cp ../init/Memcached-init-CentOS /etc/init.d/memcached \n 24 | chkconfig --add memcached \n 25 | chkconfig memcached on' 26 | OS_Debian_Ubuntu='/bin/cp ../init/Memcached-init-Ubuntu /etc/init.d/memcached \n 27 | update-rc.d memcached defaults' 28 | OS_command 29 | sed -i "s@/usr/local/memcached@$memcached_install_dir@g" /etc/init.d/memcached 30 | service memcached start 31 | else 32 | echo -e "\033[31mmemcached install failed, Please contact the author! \033[0m" 33 | fi 34 | 35 | if [ -e "$php_install_dir/bin/phpize" ];then 36 | src_url=https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz && Download_src 37 | src_url=http://pecl.php.net/get/memcached-2.2.0.tgz && Download_src 38 | src_url=http://pecl.php.net/get/memcache-2.2.7.tgz && Download_src 39 | # php memcache extension 40 | tar xzf memcache-2.2.7.tgz 41 | cd memcache-2.2.7 42 | make clean 43 | $php_install_dir/bin/phpize 44 | ./configure --with-php-config=$php_install_dir/bin/php-config 45 | make && make install 46 | cd .. 47 | /bin/rm -rf memcache-2.2.7 48 | if [ -f "$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/memcache.so" ];then 49 | [ -z "`cat $php_install_dir/etc/php.ini | grep '^extension_dir'`" ] && sed -i "s@extension_dir = \"ext\"@extension_dir = \"ext\"\nextension_dir = \"$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`\"@" $php_install_dir/etc/php.ini 50 | sed -i 's@^extension_dir\(.*\)@extension_dir\1\nextension = "memcache.so"@' $php_install_dir/etc/php.ini 51 | service php-fpm restart 52 | echo -e "\033[31mPHP memcache module install failed, Please contact the author! \033[0m" 53 | fi 54 | 55 | # php memcached extension 56 | tar xzf libmemcached-1.0.18.tar.gz 57 | cd libmemcached-1.0.18 58 | OS_CentOS='yum -y install cyrus-sasl-devel' 59 | OS_Debian_Ubuntu='sed -i "s@lthread -pthread -pthreads@lthread -lpthread -pthreads@" ./configure' 60 | OS_command 61 | ./configure --with-memcached=$memcached_install_dir 62 | make && make install 63 | cd .. 64 | /bin/rm -rf libmemcached-1.0.18 65 | 66 | tar xzf memcached-2.2.0.tgz 67 | cd memcached-2.2.0 68 | make clean 69 | $php_install_dir/bin/phpize 70 | ./configure --with-php-config=$php_install_dir/bin/php-config 71 | make && make install 72 | cd ../ 73 | /bin/rm -rf memcached-2.2.0 74 | if [ -f "$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/memcached.so" ];then 75 | [ -z "`cat $php_install_dir/etc/php.ini | grep '^extension_dir'`" ] && sed -i "s@extension_dir = \"ext\"@extension_dir = \"ext\"\nextension_dir = \"$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions/ | grep zts`\"@" $php_install_dir/etc/php.ini 76 | sed -i 's@^extension_dir\(.*\)@extension_dir\1\nextension = "memcached.so"@' $php_install_dir/etc/php.ini 77 | service php-fpm restart 78 | echo -e "\033[31mPHP memcached module install failed, Please contact the author! \033[0m" 79 | fi 80 | fi 81 | cd ../ 82 | } 83 | -------------------------------------------------------------------------------- /shell/mysql-5.5.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Install_MySQL-5-5() 4 | { 5 | cd $ltmh_dir/src 6 | . ../tools/download.sh 7 | . ../tools/check_os.sh 8 | . ../options.conf 9 | 10 | src_url=http://www.cmake.org/files/v3.0/cmake-3.0.2.tar.gz && Download_src 11 | src_url=http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.42.tar.gz && Download_src 12 | 13 | useradd -M -s /sbin/nologin mysql 14 | mkdir -p $mysql_data_dir;chown mysql.mysql -R $mysql_data_dir 15 | if [ ! -e "`which cmake`" ];then 16 | tar xzf cmake-3.0.2.tar.gz 17 | cd cmake-3.0.2 18 | CFLAGS= CXXFLAGS= ./configure 19 | make && make install 20 | cd .. 21 | /bin/rm -rf cmake-3.0.2 22 | fi 23 | tar zxf mysql-5.5.42.tar.gz 24 | cd mysql-5.5.42 25 | 26 | make clean 27 | cmake . -DCMAKE_INSTALL_PREFIX=$mysql_install_dir \ 28 | -DMYSQL_DATADIR=$mysql_data_dir \ 29 | -DSYSCONFDIR=/etc \ 30 | -DWITH_INNOBASE_STORAGE_ENGINE=1 \ 31 | -DWITH_PARTITION_STORAGE_ENGINE=1 \ 32 | -DWITH_FEDERATED_STORAGE_ENGINE=1 \ 33 | -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ 34 | -DWITH_MYISAM_STORAGE_ENGINE=1 \ 35 | -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ 36 | -DWITH_READLINE=1 \ 37 | -DENABLED_LOCAL_INFILE=1 \ 38 | -DDEFAULT_CHARSET=utf8 \ 39 | -DDEFAULT_COLLATION=utf8_general_ci \ 40 | -DWITH_EMBEDDED_SERVER=1 \ 41 | -DCMAKE_EXE_LINKER_FLAGS='-ljemalloc' 42 | make && make install 43 | 44 | if [ -d "$mysql_install_dir" ];then 45 | echo -e "\033[32mMySQL install successfully! \033[0m" 46 | else 47 | echo -e "\033[31mMySQL install failed, Please contact the author! \033[0m" 48 | kill -9 $$ 49 | fi 50 | 51 | /bin/cp support-files/mysql.server /etc/init.d/mysqld 52 | chmod +x /etc/init.d/mysqld 53 | OS_CentOS='chkconfig --add mysqld \n 54 | chkconfig mysqld on' 55 | OS_Debian_Ubuntu='update-rc.d mysqld defaults' 56 | OS_command 57 | cd .. 58 | /bin/rm -rf mysql-5.5.42 59 | cd .. 60 | 61 | # my.cf 62 | cat > /etc/my.cnf << EOF 63 | [client] 64 | port = 3306 65 | socket = /tmp/mysql.sock 66 | 67 | [mysqld] 68 | port = 3306 69 | socket = /tmp/mysql.sock 70 | 71 | basedir = $mysql_install_dir 72 | datadir = $mysql_data_dir 73 | pid-file = $mysql_data_dir/mysql.pid 74 | user = mysql 75 | bind-address = 0.0.0.0 76 | server-id = 1 77 | 78 | skip-name-resolve 79 | #skip-networking 80 | back_log = 300 81 | 82 | max_connections = 1000 83 | max_connect_errors = 6000 84 | open_files_limit = 65535 85 | table_open_cache = 128 86 | max_allowed_packet = 4M 87 | binlog_cache_size = 1M 88 | max_heap_table_size = 8M 89 | tmp_table_size = 16M 90 | 91 | read_buffer_size = 2M 92 | read_rnd_buffer_size = 8M 93 | sort_buffer_size = 8M 94 | join_buffer_size = 8M 95 | key_buffer_size = 4M 96 | 97 | thread_cache_size = 8 98 | 99 | query_cache_type = 1 100 | query_cache_size = 8M 101 | query_cache_limit = 2M 102 | 103 | ft_min_word_len = 4 104 | 105 | log_bin = mysql-bin 106 | binlog_format = mixed 107 | expire_logs_days = 30 108 | 109 | log_error = $mysql_data_dir/mysql-error.log 110 | slow_query_log = 1 111 | long_query_time = 1 112 | slow_query_log_file = $mysql_data_dir/mysql-slow.log 113 | 114 | performance_schema = 0 115 | 116 | #lower_case_table_names = 1 117 | 118 | skip-external-locking 119 | 120 | default_storage_engine = InnoDB 121 | #default-storage-engine = MyISAM 122 | innodb_file_per_table = 1 123 | innodb_open_files = 500 124 | innodb_buffer_pool_size = 64M 125 | innodb_write_io_threads = 4 126 | innodb_read_io_threads = 4 127 | innodb_thread_concurrency = 0 128 | innodb_purge_threads = 1 129 | innodb_flush_log_at_trx_commit = 2 130 | innodb_log_buffer_size = 2M 131 | innodb_log_file_size = 32M 132 | innodb_log_files_in_group = 3 133 | innodb_max_dirty_pages_pct = 90 134 | innodb_lock_wait_timeout = 120 135 | 136 | bulk_insert_buffer_size = 8M 137 | myisam_sort_buffer_size = 8M 138 | myisam_max_sort_file_size = 10G 139 | myisam_repair_threads = 1 140 | 141 | interactive_timeout = 28800 142 | wait_timeout = 28800 143 | 144 | [mysqldump] 145 | quick 146 | max_allowed_packet = 16M 147 | 148 | [myisamchk] 149 | key_buffer_size = 8M 150 | sort_buffer_size = 8M 151 | read_buffer = 4M 152 | write_buffer = 4M 153 | EOF 154 | 155 | Memtatol=`free -m | grep 'Mem:' | awk '{print $2}'` 156 | if [ $Memtatol -gt 1500 -a $Memtatol -le 2500 ];then 157 | sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf 158 | sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf 159 | sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf 160 | sed -i 's@^key_buffer_size.*@key_buffer_size = 16M@' /etc/my.cnf 161 | sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf 162 | sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf 163 | sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf 164 | elif [ $Memtatol -gt 2500 -a $Memtatol -le 3500 ];then 165 | sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf 166 | sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf 167 | sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf 168 | sed -i 's@^key_buffer_size.*@key_buffer_size = 64M@' /etc/my.cnf 169 | sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf 170 | sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf 171 | sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf 172 | elif [ $Memtatol -gt 3500 ];then 173 | sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf 174 | sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf 175 | sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf 176 | sed -i 's@^key_buffer_size.*@key_buffer_size = 256M@' /etc/my.cnf 177 | sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 1024M@' /etc/my.cnf 178 | sed -i 's@^tmp_table_size.*@tmp_table_size = 128M@' /etc/my.cnf 179 | sed -i 's@^table_open_cache.*@table_open_cache = 1024@' /etc/my.cnf 180 | fi 181 | 182 | $mysql_install_dir/scripts/mysql_install_db --user=mysql --basedir=$mysql_install_dir --datadir=$mysql_data_dir 183 | 184 | chown mysql.mysql -R $mysql_data_dir 185 | service mysqld start 186 | sleep 10s 187 | export PATH=$mysql_install_dir/bin:$PATH 188 | [ -z "`cat /etc/profile | grep $mysql_install_dir`" ] && echo "export PATH=$mysql_install_dir/bin:\$PATH" >> /etc/profile 189 | . /etc/profile 190 | 191 | $mysql_install_dir/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"$dbrootpwd\" with grant option;" 192 | $mysql_install_dir/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"$dbrootpwd\" with grant option;" 193 | $mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.user where Password='';" 194 | $mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.db where User='';" 195 | $mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.proxies_priv where Host!='localhost';" 196 | $mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "drop database test;" 197 | $mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "reset master;" 198 | sed -i "s@^db_install_dir.*@db_install_dir=$mysql_install_dir@" options.conf 199 | sed -i "s@^db_data_dir.*@db_data_dir=$mysql_data_dir@" options.conf 200 | service mysqld stop 201 | } 202 | -------------------------------------------------------------------------------- /shell/mysql-5.6.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | Install_MySQL-5-6() 3 | { 4 | cd $ltmh_dir/src 5 | . ../tools/download.sh 6 | . ../tools/check_os.sh 7 | . ../options.conf 8 | 9 | src_url=http://www.cmake.org/files/v3.0/cmake-3.0.2.tar.gz && Download_src 10 | src_url=http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.23.tar.gz && Download_src 11 | 12 | useradd -M -s /sbin/nologin mysql 13 | mkdir -p $mysql_data_dir;chown mysql.mysql -R $mysql_data_dir 14 | if [ ! -e "`which cmake`" ];then 15 | tar xzf cmake-3.0.2.tar.gz 16 | cd cmake-3.0.2 17 | CFLAGS= CXXFLAGS= ./configure 18 | make && make install 19 | cd .. 20 | /bin/rm -rf cmake-3.0.2 21 | fi 22 | tar zxf mysql-5.6.23.tar.gz 23 | cd mysql-5.6.23 24 | 25 | make clean 26 | cmake . -DCMAKE_INSTALL_PREFIX=$mysql_install_dir \ 27 | -DMYSQL_DATADIR=$mysql_data_dir \ 28 | -DSYSCONFDIR=/etc \ 29 | -DWITH_INNOBASE_STORAGE_ENGINE=1 \ 30 | -DWITH_PARTITION_STORAGE_ENGINE=1 \ 31 | -DWITH_FEDERATED_STORAGE_ENGINE=1 \ 32 | -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ 33 | -DWITH_MYISAM_STORAGE_ENGINE=1 \ 34 | -DENABLED_LOCAL_INFILE=1 \ 35 | -DDEFAULT_CHARSET=utf8 \ 36 | -DDEFAULT_COLLATION=utf8_general_ci \ 37 | -DWITH_EMBEDDED_SERVER=1 \ 38 | -DCMAKE_EXE_LINKER_FLAGS='-ljemalloc' 39 | make && make install 40 | 41 | if [ -d "$mysql_install_dir" ];then 42 | echo -e "\033[32mMySQL install successfully! \033[0m" 43 | else 44 | echo -e "\033[31mMySQL install failed, Please contact the author! \033[0m" 45 | kill -9 $$ 46 | fi 47 | 48 | /bin/cp support-files/mysql.server /etc/init.d/mysqld 49 | chmod +x /etc/init.d/mysqld 50 | OS_CentOS='chkconfig --add mysqld \n 51 | chkconfig mysqld on' 52 | OS_Debian_Ubuntu='update-rc.d mysqld defaults' 53 | OS_command 54 | cd .. 55 | /bin/rm -rf mysql-5.6.23 56 | cd .. 57 | 58 | # my.cf 59 | cat > /etc/my.cnf << EOF 60 | [client] 61 | port = 3306 62 | socket = /tmp/mysql.sock 63 | 64 | [mysqld] 65 | port = 3306 66 | socket = /tmp/mysql.sock 67 | 68 | basedir = $mysql_install_dir 69 | datadir = $mysql_data_dir 70 | pid-file = $mysql_data_dir/mysql.pid 71 | user = mysql 72 | bind-address = 0.0.0.0 73 | server-id = 1 74 | 75 | skip-name-resolve 76 | #skip-networking 77 | back_log = 300 78 | 79 | max_connections = 1000 80 | max_connect_errors = 6000 81 | open_files_limit = 65535 82 | table_open_cache = 128 83 | max_allowed_packet = 4M 84 | binlog_cache_size = 1M 85 | max_heap_table_size = 8M 86 | tmp_table_size = 16M 87 | 88 | read_buffer_size = 2M 89 | read_rnd_buffer_size = 8M 90 | sort_buffer_size = 8M 91 | join_buffer_size = 8M 92 | key_buffer_size = 4M 93 | 94 | thread_cache_size = 8 95 | 96 | query_cache_type = 1 97 | query_cache_size = 8M 98 | query_cache_limit = 2M 99 | 100 | ft_min_word_len = 4 101 | 102 | log_bin = mysql-bin 103 | binlog_format = mixed 104 | expire_logs_days = 30 105 | 106 | log_error = $mysql_data_dir/mysql-error.log 107 | slow_query_log = 1 108 | long_query_time = 1 109 | slow_query_log_file = $mysql_data_dir/mysql-slow.log 110 | 111 | performance_schema = 0 112 | explicit_defaults_for_timestamp 113 | 114 | #lower_case_table_names = 1 115 | 116 | skip-external-locking 117 | 118 | default_storage_engine = InnoDB 119 | #default-storage-engine = MyISAM 120 | innodb_file_per_table = 1 121 | innodb_open_files = 500 122 | innodb_buffer_pool_size = 64M 123 | innodb_write_io_threads = 4 124 | innodb_read_io_threads = 4 125 | innodb_thread_concurrency = 0 126 | innodb_purge_threads = 1 127 | innodb_flush_log_at_trx_commit = 2 128 | innodb_log_buffer_size = 2M 129 | innodb_log_file_size = 32M 130 | innodb_log_files_in_group = 3 131 | innodb_max_dirty_pages_pct = 90 132 | innodb_lock_wait_timeout = 120 133 | 134 | bulk_insert_buffer_size = 8M 135 | myisam_sort_buffer_size = 8M 136 | myisam_max_sort_file_size = 10G 137 | myisam_repair_threads = 1 138 | 139 | interactive_timeout = 28800 140 | wait_timeout = 28800 141 | 142 | [mysqldump] 143 | quick 144 | max_allowed_packet = 16M 145 | 146 | [myisamchk] 147 | key_buffer_size = 8M 148 | sort_buffer_size = 8M 149 | read_buffer = 4M 150 | write_buffer = 4M 151 | EOF 152 | 153 | Memtatol=`free -m | grep 'Mem:' | awk '{print $2}'` 154 | if [ $Memtatol -gt 1500 -a $Memtatol -le 2500 ];then 155 | sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf 156 | sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf 157 | sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf 158 | sed -i 's@^key_buffer_size.*@key_buffer_size = 16M@' /etc/my.cnf 159 | sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf 160 | sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf 161 | sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf 162 | elif [ $Memtatol -gt 2500 -a $Memtatol -le 3500 ];then 163 | sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf 164 | sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf 165 | sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf 166 | sed -i 's@^key_buffer_size.*@key_buffer_size = 64M@' /etc/my.cnf 167 | sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf 168 | sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf 169 | sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf 170 | elif [ $Memtatol -gt 3500 ];then 171 | sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf 172 | sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf 173 | sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf 174 | sed -i 's@^key_buffer_size.*@key_buffer_size = 256M@' /etc/my.cnf 175 | sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 1024M@' /etc/my.cnf 176 | sed -i 's@^tmp_table_size.*@tmp_table_size = 128M@' /etc/my.cnf 177 | sed -i 's@^table_open_cache.*@table_open_cache = 1024@' /etc/my.cnf 178 | fi 179 | 180 | $mysql_install_dir/scripts/mysql_install_db --user=mysql --basedir=$mysql_install_dir --datadir=$mysql_data_dir 181 | 182 | chown mysql.mysql -R $mysql_data_dir 183 | service mysqld start 184 | sleep 10s 185 | export PATH=$mysql_install_dir/bin:$PATH 186 | [ -z "`cat /etc/profile | grep $mysql_install_dir`" ] && echo "export PATH=$mysql_install_dir/bin:\$PATH" >> /etc/profile 187 | . /etc/profile 188 | 189 | $mysql_install_dir/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"$dbrootpwd\" with grant option;" 190 | $mysql_install_dir/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"$dbrootpwd\" with grant option;" 191 | $mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.user where Password='';" 192 | $mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.db where User='';" 193 | $mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.proxies_priv where Host!='localhost';" 194 | $mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "drop database test;" 195 | $mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "reset master;" 196 | sed -i "s@^db_install_dir.*@db_install_dir=$mysql_install_dir@" options.conf 197 | sed -i "s@^db_data_dir.*@db_data_dir=$mysql_data_dir@" options.conf 198 | service mysqld stop 199 | } 200 | -------------------------------------------------------------------------------- /shell/nginx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Install_Nginx() 4 | { 5 | cd $ltmh_dir/src 6 | . ../tools/download.sh 7 | . ../tools/check_os.sh 8 | . ../options.conf 9 | 10 | src_url=http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz && Download_src 11 | src_url=http://nginx.org/download/nginx-1.6.2.tar.gz && Download_src 12 | 13 | tar xzf pcre-8.35.tar.gz 14 | cd pcre-8.35 15 | ./configure 16 | make && make install 17 | cd ../ 18 | 19 | tar xzf nginx-1.6.2.tar.gz 20 | useradd -M -s /sbin/nologin www 21 | cd nginx-1.6.2 22 | 23 | # Modify Nginx version 24 | #sed -i 's@#define NGINX_VERSION.*$@#define NGINX_VERSION "1.2"@' src/core/nginx.h 25 | #sed -i 's@#define NGINX_VER.*NGINX_VERSION$@#define NGINX_VER "BSW/" NGINX_VERSION@' src/core/nginx.h 26 | #sed -i 's@Server: nginx@Server: BSW@' src/http/ngx_http_header_filter_module.c 27 | 28 | # close debug 29 | sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc 30 | 31 | ./configure --prefix=$nginx_install_dir --user=www --group=www --with-http_stub_status_module --with-http_sub_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --with-ld-opt='-ljemalloc' 32 | make && make install 33 | if [ -d "$nginx_install_dir" ];then 34 | echo -e "\033[32mNginx install successfully! \033[0m" 35 | else 36 | echo -e "\033[31mNginx install failed, Please Contact the author! \033[0m" 37 | kill -9 $$ 38 | fi 39 | 40 | [ -n "`cat /etc/profile | grep 'export PATH='`" -a -z "`cat /etc/profile | grep $nginx_install_dir`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$nginx_install_dir/sbin:\1@" /etc/profile 41 | . /etc/profile 42 | 43 | cd ../../ 44 | OS_CentOS='/bin/cp init/Nginx-init-CentOS /etc/init.d/nginx \n 45 | chkconfig --add nginx \n 46 | chkconfig nginx on' 47 | OS_Debian_Ubuntu='/bin/cp init/Nginx-init-Ubuntu /etc/init.d/nginx \n 48 | update-rc.d nginx defaults' 49 | OS_command 50 | sed -i "s@/usr/local/nginx@$nginx_install_dir@g" /etc/init.d/nginx 51 | 52 | mv $nginx_install_dir/conf/nginx.conf{,_bk} 53 | if [ "$Apache_version" == '1' -o "$Apache_version" == '2' ];then 54 | /bin/cp conf/nginx_apache.conf $nginx_install_dir/conf/nginx.conf 55 | else 56 | /bin/cp conf/nginx.conf $nginx_install_dir/conf/nginx.conf 57 | fi 58 | sed -i "s@/home/wwwroot/default@$home_dir/default@" $nginx_install_dir/conf/nginx.conf 59 | sed -i "s@/home/wwwlogs@$wwwlogs_dir@g" $nginx_install_dir/conf/nginx.conf 60 | [ "$je_tc_malloc" == '2' ] && sed -i 's@^pid\(.*\)@pid\1\ngoogle_perftools_profiles /tmp/tcmalloc;@' $nginx_install_dir/conf/nginx.conf 61 | 62 | # worker_cpu_affinity 63 | CPU_num=`cat /proc/cpuinfo | grep processor | wc -l` 64 | if [ $CPU_num == 1 ];then 65 | sed -i 's@^worker_processes.*@worker_processes 1;@' $nginx_install_dir/conf/nginx.conf 66 | elif [ $CPU_num == 2 ];then 67 | sed -i 's@^worker_processes.*@worker_processes 2;\nworker_cpu_affinity 10 01;@' $nginx_install_dir/conf/nginx.conf 68 | elif [ $CPU_num == 3 ];then 69 | sed -i 's@^worker_processes.*@worker_processes 3;\nworker_cpu_affinity 100 010 001;@' $nginx_install_dir/conf/nginx.conf 70 | elif [ $CPU_num == 4 ];then 71 | sed -i 's@^worker_processes.*@worker_processes 4;\nworker_cpu_affinity 1000 0100 0010 0001;@' $nginx_install_dir/conf/nginx.conf 72 | elif [ $CPU_num == 6 ];then 73 | sed -i 's@^worker_processes.*@worker_processes 6;\nworker_cpu_affinity 100000 010000 001000 000100 000010 000001;@' $nginx_install_dir/conf/nginx.conf 74 | elif [ $CPU_num == 8 ];then 75 | sed -i 's@^worker_processes.*@worker_processes 8;\nworker_cpu_affinity 10000000 01000000 00100000 00010000 00001000 00000100 00000010 00000001;@' $nginx_install_dir/conf/nginx.conf 76 | else 77 | echo Google worker_cpu_affinity 78 | fi 79 | 80 | # logrotate nginx log 81 | cat > /etc/logrotate.d/nginx << EOF 82 | $wwwlogs_dir/*nginx.log { 83 | daily 84 | rotate 5 85 | missingok 86 | dateext 87 | compress 88 | notifempty 89 | sharedscripts 90 | postrotate 91 | [ -e /var/run/nginx.pid ] && kill -USR1 \`cat /var/run/nginx.pid\` 92 | endscript 93 | } 94 | EOF 95 | 96 | sed -i "s@^web_install_dir.*@web_install_dir=$nginx_install_dir@" options.conf 97 | sed -i "s@/home/wwwroot@$home_dir@g" vhost.sh 98 | sed -i "s@/home/wwwlogs@$wwwlogs_dir@g" vhost.sh 99 | ldconfig 100 | #service nginx start 101 | } 102 | -------------------------------------------------------------------------------- /shell/nginx_hhvm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Install_Nginx() 4 | { 5 | cd $ltmh_dir/src 6 | . ../tools/download.sh 7 | . ../tools/check_os.sh 8 | . ../options.conf 9 | 10 | src_url=http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz && Download_src 11 | src_url=http://nginx.org/download/nginx-1.6.2.tar.gz && Download_src 12 | 13 | tar xzf pcre-8.35.tar.gz 14 | cd pcre-8.35 15 | ./configure 16 | make && make install 17 | cd ../ 18 | 19 | tar xzf nginx-1.6.2.tar.gz 20 | useradd -M -s /sbin/nologin www 21 | cd nginx-1.6.2 22 | 23 | # close debug 24 | sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc 25 | 26 | ./configure --prefix=$nginx_install_dir --user=www --group=www --with-http_stub_status_module --with-http_sub_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --with-ld-opt='-ljemalloc' 27 | make && make install 28 | if [ -d "$nginx_install_dir" ];then 29 | echo -e "\033[32mNginx install successfully! \033[0m" 30 | else 31 | echo -e "\033[31mNginx install failed, Please Contact the author! \033[0m" 32 | kill -9 $$ 33 | fi 34 | 35 | [ -n "`cat /etc/profile | grep 'export PATH='`" -a -z "`cat /etc/profile | grep $nginx_install_dir`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$nginx_install_dir/sbin:\1@" /etc/profile 36 | . /etc/profile 37 | 38 | cd ../../ 39 | OS_CentOS='/bin/cp init/Nginx-init-CentOS /etc/init.d/nginx \n 40 | chkconfig --add nginx \n 41 | chkconfig nginx on' 42 | OS_Debian_Ubuntu='/bin/cp init/Nginx-init-Ubuntu /etc/init.d/nginx \n 43 | update-rc.d nginx defaults' 44 | OS_command 45 | sed -i "s@/usr/local/nginx@$nginx_install_dir@g" /etc/init.d/nginx 46 | 47 | mv $nginx_install_dir/conf/nginx.conf{,_bk} 48 | /bin/cp conf/nginx_n.conf $nginx_install_dir/conf/nginx.conf 49 | 50 | sed -i "s@/home/wwwroot/default@$home_dir/default@" $nginx_install_dir/conf/nginx.conf 51 | sed -i "s@/home/wwwlogs@$wwwlogs_dir@g" $nginx_install_dir/conf/nginx.conf 52 | [ "$je_tc_malloc" == '2' ] && sed -i 's@^pid\(.*\)@pid\1\ngoogle_perftools_profiles /tmp/tcmalloc;@' $nginx_install_dir/conf/nginx.conf 53 | 54 | # worker_cpu_affinity 55 | CPU_num=`cat /proc/cpuinfo | grep processor | wc -l` 56 | if [ $CPU_num == 1 ];then 57 | sed -i 's@^worker_processes.*@worker_processes 1;@' $nginx_install_dir/conf/nginx.conf 58 | elif [ $CPU_num == 2 ];then 59 | sed -i 's@^worker_processes.*@worker_processes 2;\nworker_cpu_affinity 10 01;@' $nginx_install_dir/conf/nginx.conf 60 | elif [ $CPU_num == 3 ];then 61 | sed -i 's@^worker_processes.*@worker_processes 3;\nworker_cpu_affinity 100 010 001;@' $nginx_install_dir/conf/nginx.conf 62 | elif [ $CPU_num == 4 ];then 63 | sed -i 's@^worker_processes.*@worker_processes 4;\nworker_cpu_affinity 1000 0100 0010 0001;@' $nginx_install_dir/conf/nginx.conf 64 | elif [ $CPU_num == 6 ];then 65 | sed -i 's@^worker_processes.*@worker_processes 6;\nworker_cpu_affinity 100000 010000 001000 000100 000010 000001;@' $nginx_install_dir/conf/nginx.conf 66 | elif [ $CPU_num == 8 ];then 67 | sed -i 's@^worker_processes.*@worker_processes 8;\nworker_cpu_affinity 10000000 01000000 00100000 00010000 00001000 00000100 00000010 00000001;@' $nginx_install_dir/conf/nginx.conf 68 | else 69 | echo Google worker_cpu_affinity 70 | fi 71 | 72 | # logrotate nginx log 73 | cat > /etc/logrotate.d/nginx << EOF 74 | $wwwlogs_dir/*nginx.log { 75 | daily 76 | rotate 5 77 | missingok 78 | dateext 79 | compress 80 | notifempty 81 | sharedscripts 82 | postrotate 83 | [ -e /var/run/nginx.pid ] && kill -USR1 \`cat /var/run/nginx.pid\` 84 | endscript 85 | } 86 | EOF 87 | 88 | sed -i "s@^web_install_dir.*@web_install_dir=$nginx_install_dir@" options.conf 89 | sed -i "s@/home/wwwroot@$home_dir@g" vhost.sh 90 | sed -i "s@/home/wwwlogs@$wwwlogs_dir@g" vhost.sh 91 | ldconfig 92 | #service nginx start 93 | } 94 | -------------------------------------------------------------------------------- /shell/ngx_pagespeed.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | Install_ngx_pagespeed() 3 | { 4 | cd $ltmh_dir/src 5 | . ../tools/download.sh 6 | . ../options.conf 7 | 8 | rm -rf ngx_pagespeed* 9 | src_url=https://dl.google.com/dl/page-speed/psol/1.9.32.3.tar.gz && Download_src 10 | [ -s "ngx_pagespeed-1.9.32.3-beta.zip" ] && echo "ngx_pagespeed-1.9.32.3-beta.zip found" || wget -c --no-check-certificate -O ngx_pagespeed-1.9.32.3-beta.zip https://github.com/pagespeed/ngx_pagespeed/archive/master.zip 11 | 12 | unzip -q ngx_pagespeed-1.9.32.3-beta.zip 13 | /bin/mv ngx_pagespeed-master ngx_pagespeed-1.9.32.3-beta 14 | tar xzf 1.9.32.3.tar.gz -C ngx_pagespeed-1.9.32.3-beta 15 | 16 | if [ "$Nginx_version" == '1' ];then 17 | cd nginx-1.6.2 18 | make clean 19 | $web_install_dir/sbin/nginx -V &> $$ 20 | nginx_configure_arguments=`cat $$ | grep 'configure arguments:' | awk -F: '{print $2}'` 21 | rm -rf $$ 22 | 23 | if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 64 ] ;then 24 | ./configure $nginx_configure_arguments --add-module=../ngx_pagespeed-1.9.32.3-beta --with-cc-opt='-DLINUX=2 -D_REENTRANT -D_LARGEFILE64_SOURCE -pthread' 25 | else 26 | ./configure $nginx_configure_arguments --add-module=../ngx_pagespeed-1.9.32.3-beta --with-cc-opt='-DLINUX=2 -D_REENTRANT -D_LARGEFILE64_SOURCE -march=i686 -pthread' 27 | fi 28 | 29 | make 30 | if [ -f "objs/nginx" ];then 31 | /bin/mv $web_install_dir/sbin/nginx $web_install_dir/sbin/nginx$(date +%m%d) 32 | /bin/cp objs/nginx $web_install_dir/sbin/nginx 33 | mkdir /var/ngx_pagespeed_cache 34 | chown -R www.www /var/ngx_pagespeed_cache 35 | kill -USR2 `cat /var/run/nginx.pid` 36 | kill -QUIT `cat /var/run/nginx.pid.oldbin` 37 | echo -e "\033[32minstall ngx_pagespeed module successfully! \033[0m" 38 | else 39 | echo -e "\033[31minstall ngx_pagespeed failed\033[0m" 40 | fi 41 | cd ../ 42 | elif [ "$Nginx_version" == '2' ];then 43 | $web_install_dir/sbin/dso_tool --add-module=$ltmh_dir/src/ngx_pagespeed-1.9.32.3-beta 44 | if [ -f "$web_install_dir/modules/ngx_pagespeed.so" ];then 45 | sed -i "s@^dso\(.*\)@dso\1\n\tload ngx_pagespeed.so;@" $web_install_dir/conf/nginx.conf 46 | mkdir /var/ngx_pagespeed_cache 47 | chown -R www.www /var/ngx_pagespeed_cache 48 | kill -HUP `cat /var/run/nginx.pid` 49 | fi 50 | fi 51 | cd .. 52 | } 53 | -------------------------------------------------------------------------------- /shell/php-mysql-client.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Install_PHP-MySQL-Client() 4 | { 5 | cd $ltmh_dir/src 6 | . ../tools/download.sh 7 | . ../options.conf 8 | 9 | src_url=http://www.cmake.org/files/v3.0/cmake-3.0.2.tar.gz && Download_src 10 | src_url=http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.40.tar.gz && Download_src 11 | 12 | if [ ! -e "`which cmake`" ];then 13 | tar xzf cmake-3.0.2.tar.gz 14 | cd cmake-3.0.2 15 | CFLAGS= CXXFLAGS= ./configure 16 | make && make install 17 | cd .. 18 | /bin/rm -rf cmake-3.0.2 19 | fi 20 | 21 | tar zxf mysql-5.5.40.tar.gz 22 | cd mysql-5.5.40 23 | cmake . -DCMAKE_INSTALL_PREFIX=$mysql_install_dir 24 | make mysqlclient libmysql 25 | mkdir -p $mysql_install_dir/{lib,bin} 26 | /bin/cp libmysql/libmysqlclient* $mysql_install_dir/lib 27 | /bin/cp scripts/mysql_config $mysql_install_dir/bin 28 | /bin/cp -R include $mysql_install_dir 29 | cd .. 30 | /bin/rm -rf mysql-5.5.40 31 | cd .. 32 | } 33 | -------------------------------------------------------------------------------- /shell/phpmyadmin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | Install_phpMyAdmin() 3 | { 4 | cd $ltmh_dir/src 5 | . ../tools/download.sh 6 | . ../options.conf 7 | 8 | src_url=https://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/4.2.9.1/phpMyAdmin-4.2.9.1-all-languages.tar.gz && Download_src 9 | tar xzf phpMyAdmin-4.2.9.1-all-languages.tar.gz 10 | /bin/mv phpMyAdmin-4.2.9.1-all-languages $home_dir/default/phpmyadmin 11 | /bin/cp $home_dir/default/phpmyadmin/{config.sample.inc.php,config.inc.php} 12 | mkdir $home_dir/default/phpmyadmin/{upload,save} 13 | sed -i "s@UploadDir.*@UploadDir'\] = 'upload';@" $home_dir/default/phpmyadmin/config.inc.php 14 | sed -i "s@SaveDir.*@SaveDir'\] = 'save';@" $home_dir/default/phpmyadmin/config.inc.php 15 | chown -R www.www $home_dir/default/phpmyadmin 16 | cd .. 17 | } 18 | -------------------------------------------------------------------------------- /shell/pureftpd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Install_PureFTPd() 4 | { 5 | cd $ltmh_dir/src 6 | . ../tools/download.sh 7 | . ../tools/check_os.sh 8 | . ../options.conf 9 | 10 | src_url=http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.36.tar.gz && Download_src 11 | src_url=http://machiel.generaal.net/files/pureftpd/ftp_v2.1.tar.gz && Download_src 12 | 13 | tar xzf pure-ftpd-1.0.36.tar.gz 14 | cd pure-ftpd-1.0.36 15 | [ $OS == 'Ubuntu' ] && ln -s $db_install_dir/lib/libmysqlclient.so /usr/lib 16 | ./configure --prefix=$pureftpd_install_dir CFLAGS=-O2 --with-mysql=$db_install_dir --with-quotas --with-cookie --with-virtualhosts --with-virtualchroot --with-diraliases --with-sysquotas --with-ratios --with-altlog --with-paranoidmsg --with-shadow --with-welcomemsg --with-throttling --with-uploadscript --with-language=english --with-rfc2640 17 | make && make install 18 | if [ -d "$pureftpd_install_dir" ];then 19 | echo -e "\033[32mPure-Ftp install successfully! \033[0m" 20 | cp configuration-file/pure-config.pl $pureftpd_install_dir/sbin 21 | sed -i "s@/usr/local/pureftpd@$pureftpd_install_dir@" $pureftpd_install_dir/sbin/pure-config.pl 22 | chmod +x $pureftpd_install_dir/sbin/pure-config.pl 23 | cp contrib/redhat.init /etc/init.d/pureftpd 24 | cd ../../ 25 | sed -i "s@fullpath=.*@fullpath=$pureftpd_install_dir/sbin/\$prog@" /etc/init.d/pureftpd 26 | sed -i "s@pureftpwho=.*@pureftpwho=$pureftpd_install_dir/sbin/pure-ftpwho@" /etc/init.d/pureftpd 27 | sed -i "s@/etc/pure-ftpd.conf@$pureftpd_install_dir/pure-ftpd.conf@" /etc/init.d/pureftpd 28 | chmod +x /etc/init.d/pureftpd 29 | OS_CentOS='chkconfig --add pureftpd \n 30 | chkconfig pureftpd on' 31 | OS_Debian_Ubuntu="sed -i 's@^. /etc/rc.d/init.d/functions@. /lib/lsb/init-functions@' /etc/init.d/pureftpd \n 32 | update-rc.d pureftpd defaults" 33 | OS_command 34 | 35 | /bin/cp conf/pure-ftpd.conf $pureftpd_install_dir/ 36 | sed -i "s@^MySQLConfigFile.*@MySQLConfigFile $pureftpd_install_dir/pureftpd-mysql.conf@" $pureftpd_install_dir/pure-ftpd.conf 37 | sed -i "s@^LimitRecursion.*@LimitRecursion 65535 8@" $pureftpd_install_dir/pure-ftpd.conf 38 | /bin/cp conf/pureftpd-mysql.conf $pureftpd_install_dir/ 39 | conn_ftpusers_dbpwd=`cat /dev/urandom | head -1 | md5sum | head -c 8` 40 | sed -i "s@^conn_ftpusers_dbpwd.*@conn_ftpusers_dbpwd=$conn_ftpusers_dbpwd@" options.conf 41 | sed -i 's/tmppasswd/'$conn_ftpusers_dbpwd'/g' $pureftpd_install_dir/pureftpd-mysql.conf 42 | sed -i 's/conn_ftpusers_dbpwd/'$conn_ftpusers_dbpwd'/g' conf/script.mysql 43 | sed -i 's/ftpmanagerpwd/'$ftpmanagerpwd'/g' conf/script.mysql 44 | ulimit -s unlimited 45 | service mysqld restart 46 | $db_install_dir/bin/mysql -uroot -p$dbrootpwd < conf/script.mysql 47 | service pureftpd start 48 | 49 | cd src 50 | tar xzf ftp_v2.1.tar.gz 51 | sed -i 's/tmppasswd/'$conn_ftpusers_dbpwd'/' ftp/config.php 52 | sed -i "s/myipaddress.com/`echo $local_IP`/" ftp/config.php 53 | sed -i 's@\$DEFUserID.*;@\$DEFUserID = "501";@' ftp/config.php 54 | sed -i 's@\$DEFGroupID.*;@\$DEFGroupID = "501";@' ftp/config.php 55 | sed -i 's@iso-8859-1@UTF-8@' ftp/language/english.php 56 | /bin/cp ../conf/chinese.php ftp/language/ 57 | sed -i 's@\$LANG.*;@\$LANG = "chinese";@' ftp/config.php 58 | rm -rf ftp/install.php 59 | mv ftp $home_dir/default 60 | cd .. 61 | 62 | # iptables Ftp 63 | iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT 64 | iptables -I INPUT 6 -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT 65 | OS_CentOS='service iptables save' 66 | OS_Debian_Ubuntu='iptables-save > /etc/iptables.up.rules' 67 | OS_command 68 | else 69 | cd ../../ 70 | echo -e "\033[31mPure-Ftp install failed, Please contact the author! \033[0m" 71 | kill -9 $$ 72 | fi 73 | } 74 | -------------------------------------------------------------------------------- /shell/redis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Install_redis() 4 | { 5 | cd $ltmh_dir/src 6 | . ../tools/download.sh 7 | . ../tools/check_os.sh 8 | . ../options.conf 9 | 10 | if [ -e "$php_install_dir/bin/phpize" ];then 11 | src_url=http://pecl.php.net/get/redis-2.2.7.tgz && Download_src 12 | tar xzf redis-2.2.7.tgz 13 | cd redis-2.2.7 14 | make clean 15 | $php_install_dir/bin/phpize 16 | ./configure --with-php-config=$php_install_dir/bin/php-config 17 | make && make install 18 | cd .. 19 | /bin/rm -rf redis-2.2.7 20 | if [ -f "$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/redis.so" ];then 21 | [ -z "`cat $php_install_dir/etc/php.ini | grep '^extension_dir'`" ] && sed -i "s@extension_dir = \"ext\"@extension_dir = \"ext\"\nextension_dir = \"$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`\"@" $php_install_dir/etc/php.ini 22 | sed -i 's@^extension_dir\(.*\)@extension_dir\1\nextension = "redis.so"@' $php_install_dir/etc/php.ini 23 | service php-fpm restart 24 | else 25 | echo -e "\033[31mPHP Redis module install failed, Please contact the author! \033[0m" 26 | fi 27 | fi 28 | 29 | src_url=http://download.redis.io/releases/redis-2.8.19.tar.gz && Download_src 30 | tar xzf redis-2.8.19.tar.gz 31 | cd redis-2.8.19 32 | if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 32 ];then 33 | sed -i '1i\CFLAGS= -march=i686' src/Makefile 34 | sed -i 's@^OPT=.*@OPT=-O2 -march=i686@' src/.make-settings 35 | fi 36 | 37 | make 38 | 39 | if [ -f "src/redis-server" ];then 40 | mkdir -p $redis_install_dir/{bin,etc,var} 41 | /bin/cp src/{redis-benchmark,redis-check-aof,redis-check-dump,redis-cli,redis-sentinel,redis-server} $redis_install_dir/bin/ 42 | /bin/cp redis.conf $redis_install_dir/etc/ 43 | ln -s $redis_install_dir/bin/* /usr/local/bin/ 44 | sed -i 's@pidfile.*@pidfile /var/run/redis.pid@' $redis_install_dir/etc/redis.conf 45 | sed -i "s@logfile.*@logfile $redis_install_dir/var/redis.log@" $redis_install_dir/etc/redis.conf 46 | sed -i "s@^dir.*@dir $redis_install_dir/var@" $redis_install_dir/etc/redis.conf 47 | sed -i 's@daemonize no@daemonize yes@' $redis_install_dir/etc/redis.conf 48 | 49 | Memtatol=`free -m | grep 'Mem:' | awk '{print $2}'` 50 | if [ $Memtatol -le 512 ];then 51 | [ -z "`grep ^maxmemory $redis_install_dir/etc/redis.conf`" ] && sed -i 's@maxmemory @maxmemory \nmaxmemory 64000000@' $redis_install_dir/etc/redis.conf 52 | elif [ $Memtatol -gt 512 -a $Memtatol -le 1024 ];then 53 | [ -z "`grep ^maxmemory $redis_install_dir/etc/redis.conf`" ] && sed -i 's@maxmemory @maxmemory \nmaxmemory 128000000@' $redis_install_dir/etc/redis.conf 54 | elif [ $Memtatol -gt 1024 -a $Memtatol -le 1500 ];then 55 | [ -z "`grep ^maxmemory $redis_install_dir/etc/redis.conf`" ] && sed -i 's@maxmemory @maxmemory \nmaxmemory 256000000@' $redis_install_dir/etc/redis.conf 56 | elif [ $Memtatol -gt 1500 -a $Memtatol -le 2500 ];then 57 | [ -z "`grep ^maxmemory $redis_install_dir/etc/redis.conf`" ] && sed -i 's@maxmemory @maxmemory \nmaxmemory 360000000@' $redis_install_dir/etc/redis.conf 58 | elif [ $Memtatol -gt 2500 -a $Memtatol -le 3500 ];then 59 | [ -z "`grep ^maxmemory $redis_install_dir/etc/redis.conf`" ] && sed -i 's@maxmemory @maxmemory \nmaxmemory 512000000@' $redis_install_dir/etc/redis.conf 60 | elif [ $Memtatol -gt 3500 ];then 61 | [ -z "`grep ^maxmemory $redis_install_dir/etc/redis.conf`" ] && sed -i 's@maxmemory @maxmemory \nmaxmemory 1024000000@' $redis_install_dir/etc/redis.conf 62 | fi 63 | 64 | cd .. 65 | /bin/rm -rf redis-2.8.19 66 | cd .. 67 | OS_CentOS='/bin/cp init/Redis-server-init-CentOS /etc/init.d/redis-server \n 68 | chkconfig --add redis-server \n 69 | chkconfig redis-server on' 70 | OS_Debian_Ubuntu="useradd -M -s /sbin/nologin redis \n 71 | chown -R redis:redis $redis_install_dir/var/ \n 72 | /bin/cp init/Redis-server-init-Ubuntu /etc/init.d/redis-server \n 73 | update-rc.d redis-server defaults" 74 | OS_command 75 | sed -i "s@/usr/local/redis@$redis_install_dir@g" /etc/init.d/redis-server 76 | 77 | service redis-server start 78 | else 79 | cd ../../ 80 | echo -e "\033[31mRedis install failed, Please contact the author! \033[0m" 81 | fi 82 | } 83 | -------------------------------------------------------------------------------- /shell/tengine.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Install_Tengine() 4 | { 5 | cd $ltmh_dir/src 6 | . ../tools/download.sh 7 | . ../tools/check_os.sh 8 | . ../options.conf 9 | 10 | #Check file && download 11 | src_url=ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz && Download_src 12 | src_url=http://labs.frickle.com/files/ngx_cache_purge-2.1.tar.gz && Download_src 13 | #src_url=https://github.com/yaoweibin/ngx_http_substitutions_filter_module/archive/master.zip && Download_src 14 | src_url=http://tengine.taobao.org/download/tengine-2.0.3.tar.gz && Download_src 15 | src_url=http://luajit.org/download/LuaJIT-2.0.3.tar.gz && Download_src 16 | 17 | tar xzf pcre-8.35.tar.gz 18 | cd pcre-8.35 19 | ./configure 20 | make && make install 21 | cd ../ 22 | 23 | # LuaJIT 24 | tar -zxvf LuaJIT-2.0.3.tar.gz 25 | cd LuaJIT-2.0.3 26 | mkdir /usr/local/luaJIT 27 | make 28 | make install PREFIX=/usr/local/luaJIT 29 | ln -sf LuaJIT-2.0.3 /usr/local/luaJIT/bin/luajit 30 | export LUAJIT_LIB=/usr/local/luaJIT/lib 31 | export LUAJIT_INC=/usr/local/luaJIT/include/luajit-2.0 32 | cd ../ 33 | 34 | #ngx_cache 35 | tar zxvf ngx_cache_purge-2.1.tar.gz 36 | 37 | #tengine 38 | tar xzf tengine-2.0.3.tar.gz 39 | useradd -M -s /sbin/nologin www 40 | cd tengine-2.0.3 41 | 42 | # Modify Tengine version 43 | #sed -i 's@TENGINE "/" TENGINE_VERSION@"Tengine/unknown"@' src/core/nginx.h 44 | 45 | # close debug 46 | sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc 47 | 48 | # make[1]: *** [objs/src/event/ngx_event_openssl.o] Error 1 49 | sed -i 's@\(.*\)this option allow a potential SSL 2.0 rollback (CAN-2005-2969)\(.*\)@#ifdef SSL_OP_MSIE_SSLV2_RSA_PADDING\n\1this option allow a potential SSL 2.0 rollback (CAN-2005-2969)\2@' src/event/ngx_event_openssl.c 50 | sed -i 's@\(.*\)SSL_CTX_set_options(ssl->ctx, SSL_OP_MSIE_SSLV2_RSA_PADDING)\(.*\)@\1SSL_CTX_set_options(ssl->ctx, SSL_OP_MSIE_SSLV2_RSA_PADDING)\2\n#endif@' src/event/ngx_event_openssl.c 51 | 52 | 53 | ./configure --prefix=$tengine_install_dir --user=www --group=www --with-http_stub_status_module --with-http_sub_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --with-http_concat_module=shared --with-http_sysguard_module=shared --with-ipv6 --with-http_spdy_module --add-module=../ngx_cache_purge-2.1 --with-http_slice_module=shared --with-http_random_index_module=shared --with-http_secure_link_module=shared --with-http_sysguard_module=shared --with-http_mp4_module=shared --with-http_lua_module=shared --with-luajit-inc=/usr/local/luaJIT/include/luajit-2.0 --with-luajit-lib=/usr/local/luaJIT/lib --with-jemalloc 54 | make && make install 55 | if [ -d "$tengine_install_dir" ];then 56 | echo -e "\033[32mTengine install successfully! \033[0m" 57 | else 58 | echo -e "\033[31mTengine install failed, Please Contact the author! \033[0m" 59 | kill -9 $$ 60 | fi 61 | 62 | [ -n "`cat /etc/profile | grep 'export PATH='`" -a -z "`cat /etc/profile | grep $tengine_install_dir`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$tengine_install_dir/sbin:\1@" /etc/profile 63 | . /etc/profile 64 | 65 | cd ../../ 66 | OS_CentOS='/bin/cp init/Nginx-init-CentOS /etc/init.d/nginx \n 67 | chkconfig --add nginx \n 68 | chkconfig nginx on' 69 | OS_Debian_Ubuntu='/bin/cp init/init.d.nginx /etc/init.d/nginx \n 70 | update-rc.d nginx defaults' 71 | OS_command 72 | sed -i "s@/usr/local/nginx@$tengine_install_dir@g" /etc/init.d/nginx 73 | 74 | mv $tengine_install_dir/conf/nginx.conf{,_bk} 75 | /bin/cp conf/nginx.conf $tengine_install_dir/conf/nginx.conf 76 | sed -i "s@/home/wwwroot/default@$home_dir/default@" $tengine_install_dir/conf/nginx.conf 77 | sed -i "s@/home/wwwlogs@$wwwlogs_dir@g" $tengine_install_dir/conf/nginx.conf 78 | [ "$je_tc_malloc" == '2' ] && sed -i 's@^pid\(.*\)@pid\1\ngoogle_perftools_profiles /tmp/tcmalloc;@' $tengine_install_dir/conf/nginx.conf 79 | #web firewall 80 | mkdir -p /data/logs/hack/ 81 | chown -R www:www /data/logs/hack/ 82 | chmod -R 755 /data/logs/hack/ 83 | /bin/cp -R tools/waf /usr/local/nginx/conf/waf 84 | # worker_cpu_affinity 85 | sed -i "s@^worker_processes.*@worker_processes auto;\nworker_cpu_affinity auto;\ndso {\n\tload ngx_http_lua_module.so;\n\tload ngx_http_concat_module.so;\n\tload ngx_http_sysguard_module.so;\n}@" $tengine_install_dir/conf/nginx.conf 86 | 87 | # logrotate nginx log 88 | cat > /etc/logrotate.d/nginx << EOF 89 | $wwwlogs_dir/*nginx.log { 90 | daily 91 | rotate 5 92 | missingok 93 | dateext 94 | compress 95 | notifempty 96 | sharedscripts 97 | postrotate 98 | [ -e /var/run/nginx.pid ] && kill -USR1 \`cat /var/run/nginx.pid\` 99 | endscript 100 | } 101 | EOF 102 | 103 | sed -i "s@^web_install_dir.*@web_install_dir=$tengine_install_dir@" options.conf 104 | sed -i "s@/home/wwwroot@$home_dir@g" vhost.sh 105 | sed -i "s@/home/wwwlogs@$wwwlogs_dir@g" vhost.sh 106 | cp /usr/local/luaJIT/lib/libluajit-5.1.so.2 /usr/lib/libluajit-5.1.so.2 107 | ldconfig 108 | #service nginx start 109 | } 110 | -------------------------------------------------------------------------------- /shell/tengine_hhvm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Install_Tengine() 4 | { 5 | cd $ltmh_dir/src 6 | . ../tools/download.sh 7 | . ../tools/check_os.sh 8 | . ../options.conf 9 | 10 | #Check file && download 11 | src_url=ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz && Download_src 12 | src_url=http://labs.frickle.com/files/ngx_cache_purge-2.1.tar.gz && Download_src 13 | #src_url=https://github.com/yaoweibin/ngx_http_substitutions_filter_module/archive/master.zip && Download_src 14 | src_url=http://tengine.taobao.org/download/tengine-2.0.3.tar.gz && Download_src 15 | src_url=http://luajit.org/download/LuaJIT-2.0.3.tar.gz && Download_src 16 | 17 | tar xzf pcre-8.35.tar.gz 18 | cd pcre-8.35 19 | ./configure 20 | make && make install 21 | cd ../ 22 | 23 | # LuaJIT 24 | tar -zxvf LuaJIT-2.0.3.tar.gz 25 | cd LuaJIT-2.0.3 26 | mkdir /usr/local/luaJIT 27 | make 28 | make install PREFIX=/usr/local/luaJIT 29 | ln -sf LuaJIT-2.0.3 /usr/local/luaJIT/bin/luajit 30 | export LUAJIT_LIB=/usr/local/luaJIT/lib 31 | export LUAJIT_INC=/usr/local/luaJIT/include/luajit-2.0 32 | cd ../ 33 | 34 | #ngx_cache 35 | tar zxvf ngx_cache_purge-2.1.tar.gz 36 | 37 | #tengine 38 | tar xzf tengine-2.0.3.tar.gz 39 | useradd -M -s /sbin/nologin www 40 | cd tengine-2.0.3 41 | 42 | # Modify Tengine version 43 | #sed -i 's@TENGINE "/" TENGINE_VERSION@"Tengine/unknown"@' src/core/nginx.h 44 | 45 | # close debug 46 | sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc 47 | 48 | # make[1]: *** [objs/src/event/ngx_event_openssl.o] Error 1 49 | sed -i 's@\(.*\)this option allow a potential SSL 2.0 rollback (CAN-2005-2969)\(.*\)@#ifdef SSL_OP_MSIE_SSLV2_RSA_PADDING\n\1this option allow a potential SSL 2.0 rollback (CAN-2005-2969)\2@' src/event/ngx_event_openssl.c 50 | sed -i 's@\(.*\)SSL_CTX_set_options(ssl->ctx, SSL_OP_MSIE_SSLV2_RSA_PADDING)\(.*\)@\1SSL_CTX_set_options(ssl->ctx, SSL_OP_MSIE_SSLV2_RSA_PADDING)\2\n#endif@' src/event/ngx_event_openssl.c 51 | 52 | 53 | #install tengine 54 | ./configure --prefix=$tengine_install_dir --user=www --group=www --with-http_stub_status_module --with-http_sub_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --with-http_concat_module=shared --with-http_sysguard_module=shared --with-ipv6 --with-http_spdy_module --add-module=../ngx_cache_purge-2.1 --with-http_slice_module=shared --with-http_random_index_module=shared --with-http_secure_link_module=shared --with-http_sysguard_module=shared --with-http_mp4_module=shared --with-http_lua_module=shared --with-luajit-inc=/usr/local/luaJIT/include/luajit-2.0 --with-luajit-lib=/usr/local/luaJIT/lib --with-jemalloc 55 | make && make install 56 | if [ -d "$tengine_install_dir" ];then 57 | echo -e "\033[32mTengine install successfully! \033[0m" 58 | else 59 | echo -e "\033[31mTengine install failed, Please Contact the author! \033[0m" 60 | kill -9 $$ 61 | fi 62 | 63 | [ -n "`cat /etc/profile | grep 'export PATH='`" -a -z "`cat /etc/profile | grep $tengine_install_dir`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$tengine_install_dir/sbin:\1@" /etc/profile 64 | . /etc/profile 65 | 66 | cd ../../ 67 | OS_CentOS='/bin/cp init/Nginx-init-CentOS /etc/init.d/nginx \n 68 | chkconfig --add nginx \n 69 | chkconfig nginx on' 70 | OS_Debian_Ubuntu='/bin/cp init/init.d.nginx /etc/init.d/nginx \n 71 | update-rc.d nginx defaults' 72 | OS_command 73 | sed -i "s@/usr/local/nginx@$tengine_install_dir@g" /etc/init.d/nginx 74 | 75 | mv $tengine_install_dir/conf/nginx.conf{,_bk} 76 | /bin/cp conf/nginx_h.conf $tengine_install_dir/conf/nginx.conf 77 | sed -i "s@/home/wwwroot/default@$home_dir/default@" $tengine_install_dir/conf/nginx.conf 78 | sed -i "s@/home/wwwlogs@$wwwlogs_dir@g" $tengine_install_dir/conf/nginx.conf 79 | #web firewall 80 | mkdir -p /data/logs/hack/ 81 | chown -R www:www /data/logs/hack/ 82 | chmod -R 755 /data/logs/hack/ 83 | /bin/cp -R tools/waf /usr/local/nginx/conf/waf 84 | # worker_cpu_affinity 85 | sed -i "s@^worker_processes.*@worker_processes auto;\nworker_cpu_affinity auto;\ndso {\n\tload ngx_http_lua_module.so;\n\tload ngx_http_concat_module.so;\n\tload ngx_http_sysguard_module.so;\n}@" $tengine_install_dir/conf/nginx.conf 86 | 87 | # logrotate nginx log 88 | cat > /etc/logrotate.d/nginx << EOF 89 | $wwwlogs_dir/*nginx.log { 90 | daily 91 | rotate 5 92 | missingok 93 | dateext 94 | compress 95 | notifempty 96 | sharedscripts 97 | postrotate 98 | [ -e /var/run/nginx.pid ] && kill -USR1 \`cat /var/run/nginx.pid\` 99 | endscript 100 | } 101 | EOF 102 | 103 | sed -i "s@^web_install_dir.*@web_install_dir=$tengine_install_dir@" options.conf 104 | sed -i "s@/home/wwwroot@$home_dir@g" vhost.sh 105 | sed -i "s@/home/wwwlogs@$wwwlogs_dir@g" vhost.sh 106 | ldconfig 107 | cp /usr/local/luaJIT/lib/libluajit-5.1.so.2 /usr/lib/libluajit-5.1.so.2 108 | ldconfig 109 | #service nginx start 110 | } 111 | -------------------------------------------------------------------------------- /shell/tengine_hhvm_centos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Install_Tengine() 4 | { 5 | cd $ltmh_dir/src 6 | . ../tools/download.sh 7 | . ../tools/check_os.sh 8 | . ../options.conf 9 | 10 | #Check file && download 11 | src_url=ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz && Download_src 12 | src_url=http://labs.frickle.com/files/ngx_cache_purge-2.1.tar.gz && Download_src 13 | #src_url=https://github.com/yaoweibin/ngx_http_substitutions_filter_module/archive/master.zip && Download_src 14 | src_url=http://tengine.taobao.org/download/tengine-2.0.3.tar.gz && Download_src 15 | 16 | tar xzf pcre-8.35.tar.gz 17 | cd pcre-8.35 18 | ./configure 19 | make && make install 20 | cd ../ 21 | 22 | #ngx_cache 23 | tar zxvf ngx_cache_purge-2.1.tar.gz 24 | 25 | #tengine 26 | tar xzf tengine-2.0.3.tar.gz 27 | useradd -M -s /sbin/nologin www 28 | cd tengine-2.0.3 29 | 30 | # Modify Tengine version 31 | #sed -i 's@TENGINE "/" TENGINE_VERSION@"Tengine/unknown"@' src/core/nginx.h 32 | 33 | # close debug 34 | sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc 35 | 36 | # make[1]: *** [objs/src/event/ngx_event_openssl.o] Error 1 37 | sed -i 's@\(.*\)this option allow a potential SSL 2.0 rollback (CAN-2005-2969)\(.*\)@#ifdef SSL_OP_MSIE_SSLV2_RSA_PADDING\n\1this option allow a potential SSL 2.0 rollback (CAN-2005-2969)\2@' src/event/ngx_event_openssl.c 38 | sed -i 's@\(.*\)SSL_CTX_set_options(ssl->ctx, SSL_OP_MSIE_SSLV2_RSA_PADDING)\(.*\)@\1SSL_CTX_set_options(ssl->ctx, SSL_OP_MSIE_SSLV2_RSA_PADDING)\2\n#endif@' src/event/ngx_event_openssl.c 39 | 40 | 41 | #install tengine 42 | ./configure --prefix=$tengine_install_dir --user=www --group=www --with-http_stub_status_module --with-http_sub_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --with-http_concat_module=shared --with-http_sysguard_module=shared --with-ipv6 --with-http_spdy_module --add-module=../ngx_cache_purge-2.1 --with-http_slice_module=shared --with-http_random_index_module=shared --with-http_secure_link_module=shared --with-http_sysguard_module=shared --with-http_mp4_module=shared --with-jemalloc 43 | make && make install 44 | if [ -d "$tengine_install_dir" ];then 45 | echo -e "\033[32mTengine install successfully! \033[0m" 46 | else 47 | echo -e "\033[31mTengine install failed, Please Contact the author! \033[0m" 48 | kill -9 $$ 49 | fi 50 | 51 | [ -n "`cat /etc/profile | grep 'export PATH='`" -a -z "`cat /etc/profile | grep $tengine_install_dir`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$tengine_install_dir/sbin:\1@" /etc/profile 52 | . /etc/profile 53 | 54 | cd ../../ 55 | OS_CentOS='/bin/cp init/Nginx-init-CentOS /etc/init.d/nginx \n 56 | chkconfig --add nginx \n 57 | chkconfig nginx on' 58 | OS_Debian_Ubuntu='/bin/cp init/init.d.nginx /etc/init.d/nginx \n 59 | update-rc.d nginx defaults' 60 | OS_command 61 | sed -i "s@/usr/local/nginx@$tengine_install_dir@g" /etc/init.d/nginx 62 | 63 | mv $tengine_install_dir/conf/nginx.conf{,_bk} 64 | /bin/cp conf/nginx_h.conf $tengine_install_dir/conf/nginx.conf 65 | sed -i "s@/home/wwwroot/default@$home_dir/default@" $tengine_install_dir/conf/nginx.conf 66 | sed -i "s@/home/wwwlogs@$wwwlogs_dir@g" $tengine_install_dir/conf/nginx.conf 67 | 68 | # worker_cpu_affinity 69 | sed -i "s@^worker_processes.*@worker_processes auto;\nworker_cpu_affinity auto;\ndso {\n\tload ngx_http_concat_module.so;\n}@" $tengine_install_dir/conf/nginx.conf 70 | 71 | # logrotate nginx log 72 | cat > /etc/logrotate.d/nginx << EOF 73 | $wwwlogs_dir/*nginx.log { 74 | daily 75 | rotate 5 76 | missingok 77 | dateext 78 | compress 79 | notifempty 80 | sharedscripts 81 | postrotate 82 | [ -e /var/run/nginx.pid ] && kill -USR1 \`cat /var/run/nginx.pid\` 83 | endscript 84 | } 85 | EOF 86 | 87 | sed -i "s@^web_install_dir.*@web_install_dir=$tengine_install_dir@" options.conf 88 | sed -i "s@/home/wwwroot@$home_dir@g" vhost.sh 89 | sed -i "s@/home/wwwlogs@$wwwlogs_dir@g" vhost.sh 90 | 91 | ldconfig 92 | #service nginx start 93 | } 94 | -------------------------------------------------------------------------------- /shell/xcache.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Install_XCache() 4 | { 5 | cd $ltmh_dir/src 6 | . ../tools/download.sh 7 | . ../options.conf 8 | 9 | src_url=http://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz && Download_src 10 | tar xzf xcache-3.2.0.tar.gz 11 | cd xcache-3.2.0 12 | make clean 13 | $php_install_dir/bin/phpize 14 | ./configure --enable-xcache --enable-xcache-coverager --enable-xcache-optimizer --with-php-config=$php_install_dir/bin/php-config 15 | make && make install 16 | if [ -f "$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/xcache.so" ];then 17 | /bin/cp -R htdocs $home_dir/default/xcache 18 | chown -R www.www $home_dir/default/xcache 19 | touch /tmp/xcache;chown www.www /tmp/xcache 20 | 21 | Memtatol=`free -m | grep 'Mem:' | awk '{print $2}'` 22 | if [ $Memtatol -le 512 ];then 23 | xcache_size=40M 24 | elif [ $Memtatol -gt 512 -a $Memtatol -le 1024 ];then 25 | xcache_size=80M 26 | elif [ $Memtatol -gt 1024 -a $Memtatol -le 1500 ];then 27 | xcache_size=100M 28 | elif [ $Memtatol -gt 1500 -a $Memtatol -le 2500 ];then 29 | xcache_size=160M 30 | elif [ $Memtatol -gt 2500 -a $Memtatol -le 3500 ];then 31 | xcache_size=180M 32 | elif [ $Memtatol -gt 3500 ];then 33 | xcache_size=200M 34 | fi 35 | 36 | cat >> $php_install_dir/etc/php.ini << EOF 37 | [xcache-common] 38 | extension = "xcache.so" 39 | [xcache.admin] 40 | xcache.admin.enable_auth = On 41 | xcache.admin.user = "admin" 42 | xcache.admin.pass = "$xcache_admin_md5_pass" 43 | 44 | [xcache] 45 | xcache.size = $xcache_size 46 | xcache.count = $(expr `cat /proc/cpuinfo | grep -c processor` + 1) 47 | xcache.slots = 8K 48 | xcache.ttl = 3600 49 | xcache.gc_interval = 300 50 | xcache.var_size = $xcache_size 51 | xcache.var_count = $(expr `cat /proc/cpuinfo | grep -c processor` + 1) 52 | xcache.var_slots = 8K 53 | xcache.var_ttl = 0 54 | xcache.var_maxttl = 0 55 | xcache.var_gc_interval = 300 56 | xcache.test = Off 57 | xcache.readonly_protection = Off 58 | xcache.shm_scheme = "mmap" 59 | xcache.mmap_path = "/tmp/xcache" 60 | xcache.coredump_directory = "" 61 | xcache.cacher = On 62 | xcache.stat = On 63 | xcache.optimizer = Off 64 | 65 | [xcache.coverager] 66 | ; enabling this feature will impact performance 67 | ; enable only if xcache.coverager == On && xcache.coveragedump_directory == "non-empty-value" 68 | ; enable coverage data collecting and xcache_coverager_start/stop/get/clean() functions 69 | xcache.coverager = Off 70 | xcache.coverager_autostart = On 71 | xcache.coveragedump_directory = "" 72 | EOF 73 | service php-fpm restart 74 | else 75 | echo -e "\033[31meXcache module install failed, Please contact the author! \033[0m" 76 | fi 77 | cd .. 78 | /bin/rm -rf xcache-3.2.0 79 | cd .. 80 | } 81 | -------------------------------------------------------------------------------- /shell/zendopcache.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Install_ZendOPcache() 4 | { 5 | cd $ltmh_dir/src 6 | . ../options.conf 7 | 8 | rm -rf ZendOptimizerPlus-master* 9 | wget -c --no-check-certificate -O ZendOptimizerPlus-master.zip https://github.com/zendtech/ZendOptimizerPlus/archive/master.zip 10 | unzip -q ZendOptimizerPlus-master.zip 11 | cd ZendOptimizerPlus-master 12 | make clean 13 | $php_install_dir/bin/phpize 14 | ./configure --with-php-config=$php_install_dir/bin/php-config 15 | make && make install 16 | Mem=`free -m | awk '/Mem:/{print $2}'` 17 | if [ $Mem -gt 1024 -a $Mem -le 1500 ];then 18 | Memory_limit=192 19 | elif [ $Mem -gt 1500 -a $Mem -le 3500 ];then 20 | Memory_limit=256 21 | elif [ $Mem -gt 3500 -a $Mem -le 4500 ];then 22 | Memory_limit=320 23 | elif [ $Mem -gt 4500 ];then 24 | Memory_limit=448 25 | else 26 | Memory_limit=128 27 | fi 28 | if [ -f "$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/opcache.so" ];then 29 | cat >> $php_install_dir/etc/php.ini << EOF 30 | [opcache] 31 | zend_extension="$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/opcache.so" 32 | opcache.memory_consumption=$Memory_limit 33 | opcache.interned_strings_buffer=8 34 | opcache.max_accelerated_files=4000 35 | opcache.revalidate_freq=60 36 | opcache.save_comments=0 37 | opcache.fast_shutdown=1 38 | opcache.enable_cli=1 39 | ;opcache.optimization_level=0 40 | EOF 41 | service php-fpm restart 42 | else 43 | echo -e "\033[31meZend OPcache module install failed, Please contact the author! \033[0m" 44 | fi 45 | cd .. 46 | /bin/rm -rf ZendOptimizerPlus-master 47 | cd .. 48 | } 49 | -------------------------------------------------------------------------------- /tools/check502.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CheckURL="http://www.hhvm.biz" 4 | 5 | STATUS_CODE=`curl -o /dev/null -m 10 --connect-timeout 10 -s -w %{http_code} $CheckURL` 6 | #echo "$CheckURL Status Code:\t$STATUS_CODE" 7 | if [ "$STATUS_CODE" = "502" ]; then 8 | /etc/init.d/php-fpm restart 9 | fi -------------------------------------------------------------------------------- /tools/check_os.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -f /etc/redhat-release ];then 4 | OS=CentOS 5 | elif [ ! -z "`cat /etc/issue | grep bian`" ];then 6 | OS=Debian 7 | elif [ ! -z "`cat /etc/issue | grep Ubuntu`" ];then 8 | OS=Ubuntu 9 | else 10 | echo -e "\033[31mDoes not support this OS, Please contact the author! \033[0m" 11 | kill -9 $$ 12 | fi 13 | 14 | OS_command() 15 | { 16 | if [ $OS == 'CentOS' ];then 17 | echo -e $OS_CentOS | bash 18 | elif [ $OS == 'Debian' -o $OS == 'Ubuntu' ];then 19 | echo -e $OS_Debian_Ubuntu | bash 20 | else 21 | echo -e "\033[31mDoes not support this OS, Please contact the author! \033[0m" 22 | kill -9 $$ 23 | fi 24 | } 25 | -------------------------------------------------------------------------------- /tools/download.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | Download_src() 4 | { 5 | [ -s "${src_url##*/}" ] && echo "${src_url##*/} found" || wget -c --no-check-certificate $src_url 6 | if [ ! -e "${src_url##*/}" ];then 7 | echo -e "\033[31m${src_url##*/} download failed, Please contact the author! \033[0m" 8 | kill -9 $$ 9 | fi 10 | } 11 | -------------------------------------------------------------------------------- /tools/get_ip_area.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #coding:utf-8 3 | try: 4 | import sys,urllib2 5 | # import sys,urllib2,json 6 | # Python 2.4(CentOS/RHEL 5) does not support 'json' module 7 | apiurl = "http://ip.taobao.com/service/getIpInfo.php?ip=%s" % sys.argv[1] 8 | content = urllib2.urlopen(apiurl).read() 9 | # data = json.loads(content)['data'] 10 | # code = json.loads(content)['code'] 11 | data = eval(content)['data'] 12 | code = eval(content)['code'] 13 | if code == 0: 14 | print data['country_id'] 15 | else: 16 | print data 17 | except: 18 | print "Usage:%s IP" % sys.argv[0] 19 | -------------------------------------------------------------------------------- /tools/get_local_ip.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import socket 3 | def Get_local_ip(): 4 | """ 5 | Returns the actual ip of the local machine. 6 | This code figures out what source address would be used if some traffic 7 | were to be sent out to some well known address on the Internet. In this 8 | case, a Google DNS server is used, but the specific address does not 9 | matter much. No traffic is actually sent. 10 | """ 11 | try: 12 | csock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 13 | csock.connect(('8.8.8.8', 80)) 14 | (addr, port) = csock.getsockname() 15 | csock.close() 16 | return addr 17 | except socket.error: 18 | return "127.0.0.1" 19 | 20 | if __name__ == "__main__": 21 | local_IP = Get_local_ip() 22 | print local_IP 23 | -------------------------------------------------------------------------------- /tools/get_public_ip.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import re,urllib2 3 | class Get_public_ip: 4 | def getip(self): 5 | try: 6 | myip = self.visit("http://www.whereismyip.com/") 7 | except: 8 | try: 9 | myip = self.visit("http://www.ip138.com/ip2city.asp") 10 | except: 11 | myip = "So sorry!!!" 12 | return myip 13 | def visit(self,url): 14 | opener = urllib2.urlopen(url) 15 | if url == opener.geturl(): 16 | str = opener.read() 17 | return re.search('\d+\.\d+\.\d+\.\d+',str).group(0) 18 | 19 | if __name__ == "__main__": 20 | getmyip = Get_public_ip() 21 | print getmyip.getip() 22 | -------------------------------------------------------------------------------- /tools/init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | INIT() 3 | { 4 | cd $ltmh_dir/src 5 | . ../tools/download.sh 6 | . ../options.conf 7 | 8 | 9 | src_url=https://gist.githubusercontent.com/ck-on/4959032/raw/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb/ocp.php && Download_src 10 | 11 | /bin/cp $ltmh_dir/conf/index.html /home/wwwroot/default/index.html 12 | /bin/cp $ltmh_dir/conf/phpinfo.php /home/wwwroot/default/phpinfo.php 13 | /bin/cp $ltmh_dir/conf/p.php /home/wwwroot/default/p.php 14 | ldconfig 15 | service mysqld start 16 | service php-fpm start 17 | service nginx start 18 | [ "$PHP_cache" == '1' ] && /bin/cp ocp.php $home_dir/default && sed -i 's@xcache@Opcache@' $home_dir/default/index.html 19 | [ "$PHP_cache" == '3' ] && sed -i 's@xcache@APC@' $home_dir/default/index.html 20 | [ "$PHP_cache" == '4' ] && /bin/cp eaccelerator-*/control.php $home_dir/default && sed -i 's@xcache@eAccelerator@' $home_dir/default/index.html 21 | chown -R www.www $home_dir/default 22 | #[ -e "$db_install_dir" -a -z "`ps -ef | grep -v grep | grep mysql`" ] && service mysqld start 23 | cd .. 24 | } 25 | -------------------------------------------------------------------------------- /tools/init_hhvm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | INIT() 3 | { 4 | cd $ltmh_dir/src 5 | . ../tools/download.sh 6 | . ../options.conf 7 | 8 | 9 | src_url=https://gist.githubusercontent.com/ck-on/4959032/raw/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb/ocp.php && Download_src 10 | 11 | /bin/cp $ltmh_dir/conf/index.html /home/wwwroot/default/index.html 12 | /bin/cp $ltmh_dir/conf/phpinfo.php /home/wwwroot/default/phpinfo.php 13 | /bin/cp $ltmh_dir/conf/p.php /home/wwwroot/default/p.php 14 | ldconfig 15 | service mysqld start 16 | service hhvm start 17 | service nginx start 18 | [ "$PHP_cache" == '1' ] && /bin/cp ocp.php $home_dir/default && sed -i 's@xcache@Opcache@' $home_dir/default/index.html 19 | [ "$PHP_cache" == '3' ] && sed -i 's@xcache@APC@' $home_dir/default/index.html 20 | [ "$PHP_cache" == '4' ] && /bin/cp eaccelerator-*/control.php $home_dir/default && sed -i 's@xcache@eAccelerator@' $home_dir/default/index.html 21 | chown -R www.www $home_dir/default 22 | #[ -e "$db_install_dir" -a -z "`ps -ef | grep -v grep | grep mysql`" ] && service mysqld start 23 | cd .. 24 | } 25 | -------------------------------------------------------------------------------- /tools/remove_disable_function.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin 3 | export PATH 4 | 5 | # Check if user is root 6 | if [ $(id -u) != "0" ]; then 7 | echo "Error: You must be root to run this script, please use root to install ltmp" 8 | exit 1 9 | fi 10 | 11 | clear 12 | printf "=======================================================================\n" 13 | printf "Remove php disable functions for LTMP V0.1 , Written by Andy \n" 14 | printf "=======================================================================\n" 15 | printf "LTMP is a tool to auto-compile & install Tengine+MySQL+PHP on Linux \n" 16 | printf "This script is a tool to remove php disable functions for ltmp \n" 17 | printf "\n" 18 | printf "more information please visit http://www.hhvmc.com \n" 19 | printf "=======================================================================\n" 20 | cur_dir=$(pwd) 21 | 22 | ver="" 23 | echo "Remove all php disable function please type: 1" 24 | echo "Only remove scandir function please type: 2" 25 | echo "Only remove exec function please type: 3" 26 | read -p "Please input 1 2 or 3:" ver 27 | if [ "$ver" = "" ]; then 28 | ver="1" 29 | fi 30 | 31 | if [ "$ver" = "1" ]; then 32 | echo "You will remove all php disable functions." 33 | elif [ "$ver" = "2" ]; then 34 | echo "You will remove scandir php disable function." 35 | elif [ "$ver" = "3" ]; then 36 | echo "You will remove exec php disable_function." 37 | fi 38 | 39 | get_char() 40 | { 41 | SAVEDSTTY=`stty -g` 42 | stty -echo 43 | stty cbreak 44 | dd if=/dev/tty bs=1 count=1 2> /dev/null 45 | stty -raw 46 | stty echo 47 | stty $SAVEDSTTY 48 | } 49 | echo "" 50 | echo "Press any key to start...or Press Ctrl+c to cancel" 51 | char=`get_char` 52 | 53 | 54 | function remove_all_disable_function() 55 | { 56 | sed -i 's/disable_functions =.*/disable_functions =/g' /usr/local/php/etc/php.ini 57 | } 58 | 59 | function remove_scandir_function() 60 | { 61 | sed -i 's/,scandir//g' /usr/local/php/etc/php.ini 62 | } 63 | 64 | function remove_exec_function() 65 | { 66 | sed -i 's/,exec//g' /usr/local/php/etc/php.ini 67 | } 68 | 69 | if [ "$ver" = "1" ]; then 70 | remove_all_disable_function 71 | elif [ "$ver" = "2" ]; then 72 | remove_scandir_function 73 | elif [ "$ver" = "3" ]; then 74 | remove_exec_function 75 | fi 76 | 77 | if [ -s /etc/init.d/httpd ] && [ -s /usr/local/apache ]; then 78 | echo "Restarting Apache......" 79 | /etc/init.d/httpd -k restart 80 | else 81 | echo "Restarting php-fpm......" 82 | /etc/init.d/php-fpm restart 83 | fi 84 | 85 | printf "=======================================================================\n" 86 | printf "Remove php disable funtion completed,enjoy it!\n" 87 | printf "=======================================================================\n" 88 | printf "Remove php disable functions for LTMP V0.1 , Written by Andy \n" 89 | printf "=======================================================================\n" 90 | printf "LTMP is a tool to auto-compile & install Tengine+MySQL+PHP on Linux \n" 91 | printf "This script is a tool to remove php disable functions for LTMP \n" 92 | printf "\n" 93 | printf "For more information please visit http://www.hhvmc.com \n" 94 | printf "=======================================================================\n" -------------------------------------------------------------------------------- /tools/reset_mysql_root_password.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin 3 | export PATH 4 | 5 | # Check if user is root 6 | if [ $(id -u) != "0" ]; then 7 | echo "Error: You must be root to run this script!" 8 | exit 1 9 | fi 10 | 11 | echo "=========================================================================" 12 | echo "Reset MySQL/MariaDB root Password for LTMP , Written by Andy " 13 | echo "=========================================================================" 14 | echo "LTMP is a tool to auto-compile & install Tengine+MySQL+PHP on Linux " 15 | echo "This script is a tool to reset mysql/mariadb root password for ltmp " 16 | echo "For more information please visit http://www.hhvmc.com" 17 | echo "" 18 | echo "Usage: bash reset_mysql_root_password.sh" 19 | echo "=========================================================================" 20 | 21 | if [ -s /usr/local/mariadb/bin/mysql ]; then 22 | M_Name="mariadb" 23 | else 24 | M_Name="mysql" 25 | fi 26 | 27 | mysql_root_password="" 28 | read -p "(Please input New MySQL root password):" mysql_root_password 29 | if [ "$mysql_root_password" = "" ]; then 30 | echo "Error: Password can't be NULL!!" 31 | exit 1 32 | fi 33 | 34 | echo "Stoping MySQL..." 35 | /etc/init.d/$M_Name stop 36 | echo "Starting MySQL with skip grant tables" 37 | /usr/local/$M_Name/bin/mysqld_safe --skip-grant-tables >/dev/null 2>&1 & 38 | echo "using mysql to flush privileges and reset password" 39 | sleep 5 40 | echo "update user set password = Password('$mysql_root_password') where User = 'root'" 41 | /usr/local/$M_Name/bin/mysql -u root mysql << EOF 42 | update user set password = Password('$mysql_root_password') where User = 'root'; 43 | EOF 44 | 45 | reset_status=`echo $?` 46 | if [ $reset_status = "0" ]; then 47 | echo "Password reset succesfully. Now killing mysqld softly" 48 | killall mysqld 49 | sleep 5 50 | echo "Restarting the actual mysql service" 51 | /etc/init.d/$M_Name start 52 | echo "Password successfully reset to '$mysql_root_password'" 53 | else 54 | echo "Reset MySQL root password failed!" 55 | fi -------------------------------------------------------------------------------- /tools/waf/config.lua: -------------------------------------------------------------------------------- 1 | RulePath = "/usr/local/nginx/conf/waf/wafconf/" 2 | attacklog = "on" 3 | logdir = "/data/logs/hack/" 4 | UrlDeny="on" 5 | Redirect="on" 6 | CookieMatch="on" 7 | postMatch="on" 8 | whiteModule="on" 9 | ipWhitelist={"127.0.0.1"} 10 | ipBlocklist={"1.0.0.1"} 11 | CCDeny="off" 12 | CCrate="100/60" 13 | html=[[Please go away~~ ]] 14 | -------------------------------------------------------------------------------- /tools/waf/init.lua: -------------------------------------------------------------------------------- 1 | require 'config' 2 | local match = string.match 3 | local ngxmatch=ngx.re.match 4 | local unescape=ngx.unescape_uri 5 | local get_headers = ngx.req.get_headers 6 | local optionIsOn = function (options) return options == "on" and true or false end 7 | logpath = logdir 8 | rulepath = RulePath 9 | UrlDeny = optionIsOn(UrlDeny) 10 | PostCheck = optionIsOn(postMatch) 11 | CookieCheck = optionIsOn(cookieMatch) 12 | WhiteCheck = optionIsOn(whiteModule) 13 | PathInfoFix = optionIsOn(PathInfoFix) 14 | attacklog = optionIsOn(attacklog) 15 | CCDeny = optionIsOn(CCDeny) 16 | Redirect=optionIsOn(Redirect) 17 | function getClientIp() 18 | IP = ngx.req.get_headers()["X-Real-IP"] 19 | if IP == nil then 20 | IP = ngx.var.remote_addr 21 | end 22 | if IP == nil then 23 | IP = "unknown" 24 | end 25 | return IP 26 | end 27 | function write(logfile,msg) 28 | local fd = io.open(logfile,"ab") 29 | if fd == nil then return end 30 | fd:write(msg) 31 | fd:flush() 32 | fd:close() 33 | end 34 | function log(method,url,data,ruletag) 35 | if attacklog then 36 | local realIp = getClientIp() 37 | local ua = ngx.var.http_user_agent 38 | local servername=ngx.var.server_name 39 | local time=ngx.localtime() 40 | if ua then 41 | line = realIp.." ["..time.."] \""..method.." "..servername..url.."\" \""..data.."\" \""..ua.."\" \""..ruletag.."\"\n" 42 | else 43 | line = realIp.." ["..time.."] \""..method.." "..servername..url.."\" \""..data.."\" - \""..ruletag.."\"\n" 44 | end 45 | local filename = logpath..'/'..servername.."_"..ngx.today().."_sec.log" 46 | write(filename,line) 47 | end 48 | end 49 | ------------------------------------规则读取函数------------------------------------------------------------------- 50 | function read_rule(var) 51 | file = io.open(rulepath..'/'..var,"r") 52 | if file==nil then 53 | return 54 | end 55 | t = {} 56 | for line in file:lines() do 57 | table.insert(t,line) 58 | end 59 | file:close() 60 | return(t) 61 | end 62 | 63 | urlrules=read_rule('url') 64 | argsrules=read_rule('args') 65 | uarules=read_rule('user-agent') 66 | wturlrules=read_rule('whiteurl') 67 | postrules=read_rule('post') 68 | ckrules=read_rule('cookie') 69 | 70 | 71 | function say_html() 72 | if Redirect then 73 | ngx.header.content_type = "text/html" 74 | ngx.say(html) 75 | ngx.exit(200) 76 | end 77 | end 78 | 79 | function whiteurl() 80 | if WhiteCheck then 81 | if wturlrules ~=nil then 82 | for _,rule in pairs(wturlrules) do 83 | if ngxmatch(ngx.var.request_uri,rule,"imjo") then 84 | return true 85 | end 86 | end 87 | end 88 | end 89 | return false 90 | end 91 | 92 | function args() 93 | for _,rule in pairs(argsrules) do 94 | local args = ngx.req.get_uri_args() 95 | for key, val in pairs(args) do 96 | if type(val)=='table' then 97 | data=table.concat(val, " ") 98 | else 99 | data=val 100 | end 101 | if data and type(data) ~= "boolean" and rule ~="" and ngxmatch(unescape(data),rule,"imjo") then 102 | log('GET',ngx.var.request_uri,"-",rule) 103 | say_html() 104 | return true 105 | end 106 | end 107 | end 108 | return false 109 | end 110 | 111 | 112 | function url() 113 | if UrlDeny then 114 | for _,rule in pairs(urlrules) do 115 | if rule ~="" and ngxmatch(ngx.var.request_uri,rule,"imjo") then 116 | log('GET',ngx.var.request_uri,"-",rule) 117 | say_html() 118 | return true 119 | end 120 | end 121 | end 122 | return false 123 | end 124 | 125 | function ua() 126 | local ua = ngx.var.http_user_agent 127 | if ua ~= nil then 128 | for _,rule in pairs(uarules) do 129 | if rule ~="" and ngxmatch(ua,rule,"imjo") then 130 | log('UA',ngx.var.request_uri,"-",rule) 131 | say_html() 132 | return true 133 | end 134 | end 135 | end 136 | return false 137 | end 138 | function body(data) 139 | for _,rule in pairs(postrules) do 140 | if rule ~="" and ngxmatch(unescape(data),rule,"imjo") then 141 | log('POST',ngx.var.request_uri,data,rule) 142 | say_html() 143 | return true 144 | end 145 | end 146 | return false 147 | end 148 | function cookie() 149 | local ck = ngx.var.http_cookie 150 | if CookieCheck and ck then 151 | for _,rule in pairs(ckrules) do 152 | if rule ~="" and ngxmatch(ck,rule,"imjo") then 153 | log('Cookie',ngx.var.request_uri,"-",rule) 154 | say_html() 155 | return true 156 | end 157 | end 158 | end 159 | return false 160 | end 161 | 162 | function denycc() 163 | if CCDeny then 164 | local uri=ngx.var.uri 165 | CCcount=tonumber(string.match(CCrate,'(.*)/')) 166 | CCseconds=tonumber(string.match(CCrate,'/(.*)')) 167 | local token = getClientIp()..uri 168 | local limit = ngx.shared.limit 169 | local req,_=limit:get(token) 170 | if req then 171 | if req > CCcount then 172 | ngx.exit(503) 173 | return true 174 | else 175 | limit:incr(token,1) 176 | end 177 | else 178 | limit:set(token,1,CCseconds) 179 | end 180 | end 181 | return false 182 | end 183 | 184 | function get_boundary() 185 | local header = get_headers()["content-type"] 186 | if not header then 187 | return nil 188 | end 189 | 190 | if type(header) == "table" then 191 | header = header[1] 192 | end 193 | 194 | local m = match(header, ";%s*boundary=\"([^\"]+)\"") 195 | if m then 196 | return m 197 | end 198 | 199 | return match(header, ";%s*boundary=([^\",;]+)") 200 | end 201 | 202 | function whiteip() 203 | if next(ipWhitelist) ~= nil then 204 | for _,ip in pairs(ipWhitelist) do 205 | if getClientIp()==ip then 206 | return true 207 | end 208 | end 209 | end 210 | return false 211 | end 212 | 213 | function blockip() 214 | if next(ipBlocklist) ~= nil then 215 | for _,ip in pairs(ipBlocklist) do 216 | if getClientIp()==ip then 217 | ngx.exit(403) 218 | return true 219 | end 220 | end 221 | end 222 | return false 223 | end 224 | -------------------------------------------------------------------------------- /tools/waf/install.sh: -------------------------------------------------------------------------------- 1 | mkdir -p /data/src 2 | cd /data/src 3 | if [ ! -x "LuaJIT-2.0.0.tar.gz" ]; then 4 | wget http://luajit.org/download/LuaJIT-2.0.0.tar.gz 5 | fi 6 | tar zxvf LuaJIT-2.0.0.tar.gz 7 | cd LuaJIT-2.0.0 8 | make 9 | make install PREFIX=/usr/local/lj2 10 | ln -s /usr/local/lj2/lib/libluajit-5.1.so.2 /lib64/ 11 | cd /data/src 12 | if [ ! -x "v0.2.17rc2.zip" ]; then 13 | wget https://github.com/simpl/ngx_devel_kit/archive/v0.2.17rc2.zip 14 | fi 15 | unzip v0.2.17rc2 16 | if [ ! -x "v0.7.4.zip" ]; then 17 | wget https://github.com/chaoslawful/lua-nginx-module/archive/v0.7.4.zip 18 | fi 19 | unzip v0.7.4 20 | cd /data/src 21 | if [ ! -x "pcre-8.10.tar.gz" ]; then 22 | wget http://blog.s135.com/soft/linux/nginx_php/pcre/pcre-8.10.tar.gz 23 | fi 24 | tar zxvf pcre-8.10.tar.gz 25 | cd pcre-8.10/ 26 | ./configure 27 | make && make install 28 | cd .. 29 | if [ ! -x "nginx-1.2.4.tar.gz" ]; then 30 | wget 'http://nginx.org/download/nginx-1.2.4.tar.gz' 31 | fi 32 | tar -xzvf nginx-1.2.4.tar.gz 33 | cd nginx-1.2.4/ 34 | export LUAJIT_LIB=/usr/local/lj2/lib/ 35 | export LUAJIT_INC=/usr/local/lj2/include/luajit-2.0/ 36 | ./configure --user=daemon --group=daemon --prefix=/usr/local/nginx/ --with-http_stub_status_module --with-http_sub_module --with-http_gzip_static_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --add-module=../ngx_devel_kit-0.2.17rc2/ --add-module=../lua-nginx-module-0.7.4/ 37 | make -j8 38 | make install 39 | #rm -rf /data/src 40 | cd /usr/local/nginx/conf/ 41 | wget https://github.com/loveshell/ngx_lua_waf/archive/master.zip --no-check-certificate 42 | unzip master.zip 43 | mv ngx_lua_waf-master/* /usr/local/nginx/conf/ 44 | rm -rf ngx_lua_waf-master 45 | rm -rf /data/src 46 | mkdir -p /data/logs/hack 47 | chmod -R 775 /data/logs/hack 48 | -------------------------------------------------------------------------------- /tools/waf/waf.lua: -------------------------------------------------------------------------------- 1 | local content_length=tonumber(ngx.req.get_headers()['content-length']) 2 | local method=ngx.req.get_method() 3 | if whiteip() then 4 | elseif blockip() then 5 | elseif denycc() then 6 | elseif ngx.var.http_Acunetix_Aspect then 7 | ngx.exit(444) 8 | elseif ngx.var.http_X_Scan_Memo then 9 | ngx.exit(444) 10 | elseif whiteurl() then 11 | elseif ua() then 12 | elseif url() then 13 | elseif args() then 14 | elseif cookie() then 15 | elseif PostCheck then 16 | if method=="POST" then 17 | local boundary = get_boundary() 18 | if boundary then 19 | local len = string.len 20 | local sock, err = ngx.req.socket() 21 | if not sock then 22 | return 23 | end 24 | ngx.req.init_body(128 * 1024) 25 | sock:settimeout(0) 26 | local content_length = nil 27 | content_length=tonumber(ngx.req.get_headers()['content-length']) 28 | local chunk_size = 4096 29 | if content_length < chunk_size then 30 | chunk_size = content_length 31 | end 32 | local size = 0 33 | while size < content_length do 34 | local data, err, partial = sock:receive(chunk_size) 35 | data = data or partial 36 | if not data then 37 | return 38 | end 39 | ngx.req.append_body(data) 40 | if body(data) then 41 | return true 42 | end 43 | size = size + len(data) 44 | local less = content_length - size 45 | if less < chunk_size then 46 | chunk_size = less 47 | end 48 | end 49 | ngx.req.finish_body() 50 | else 51 | ngx.req.read_body() 52 | local args = ngx.req.get_post_args() 53 | if not args then 54 | return 55 | end 56 | for key, val in pairs(args) do 57 | if type(val) == "table" then 58 | data=table.concat(val, ", ") 59 | else 60 | data=val 61 | end 62 | if data and type(data) ~= "boolean" and body(data) then 63 | return true 64 | end 65 | end 66 | end 67 | end 68 | else 69 | return 70 | end 71 | -------------------------------------------------------------------------------- /tools/waf/wafconf/args: -------------------------------------------------------------------------------- 1 | \.\./ 2 | \:\$ 3 | \$\{ 4 | select.+(from|limit) 5 | (?:(union(.*?)select)) 6 | having|rongjitest 7 | sleep\((\s*)(\d*)(\s*)\) 8 | benchmark\((.*)\,(.*)\) 9 | base64_decode\( 10 | (?:from\W+information_schema\W) 11 | (?:(?:current_)user|database|schema|connection_id)\s*\( 12 | (?:etc\/\W*passwd) 13 | into(\s+)+(?:dump|out)file\s* 14 | group\s+by.+\( 15 | xwork.MethodAccessor 16 | (?:define|eval|file_get_contents|include|require|require_once|shell_exec|phpinfo|system|passthru|preg_\w+|execute|echo|print|print_r|var_dump|(fp)open|alert|showmodaldialog)\( 17 | xwork\.MethodAccessor 18 | (gopher|doc|php|glob|file|phar|zlib|ftp|ldap|dict|ogg|data)\:\/ 19 | java\.lang 20 | \$_(GET|post|cookie|files|session|env|phplib|GLOBALS|SERVER)\[ 21 | \<(iframe|script|body|img|layer|div|meta|style|base|object|input) 22 | (onmouseover|onerror|onload)\= 23 | -------------------------------------------------------------------------------- /tools/waf/wafconf/cookie: -------------------------------------------------------------------------------- 1 | \.\./ 2 | \:\$ 3 | \$\{ 4 | select.+(from|limit) 5 | (?:(union(.*?)select)) 6 | having|rongjitest 7 | sleep\((\s*)(\d*)(\s*)\) 8 | benchmark\((.*)\,(.*)\) 9 | base64_decode\( 10 | (?:from\W+information_schema\W) 11 | (?:(?:current_)user|database|schema|connection_id)\s*\( 12 | (?:etc\/\W*passwd) 13 | into(\s+)+(?:dump|out)file\s* 14 | group\s+by.+\( 15 | xwork.MethodAccessor 16 | (?:define|eval|file_get_contents|include|require|require_once|shell_exec|phpinfo|system|passthru|preg_\w+|execute|echo|print|print_r|var_dump|(fp)open|alert|showmodaldialog)\( 17 | xwork\.MethodAccessor 18 | (gopher|doc|php|glob|file|phar|zlib|ftp|ldap|dict|ogg|data)\:\/ 19 | java\.lang 20 | \$_(GET|post|cookie|files|session|env|phplib|GLOBALS|SERVER)\[ 21 | -------------------------------------------------------------------------------- /tools/waf/wafconf/post: -------------------------------------------------------------------------------- 1 | \.\./ 2 | select.+(from|limit) 3 | (?:(union(.*?)select)) 4 | having|rongjitest 5 | sleep\((\s*)(\d*)(\s*)\) 6 | benchmark\((.*)\,(.*)\) 7 | base64_decode\( 8 | (?:from\W+information_schema\W) 9 | (?:(?:current_)user|database|schema|connection_id)\s*\( 10 | (?:etc\/\W*passwd) 11 | into(\s+)+(?:dump|out)file\s* 12 | group\s+by.+\( 13 | xwork.MethodAccessor 14 | (?:define|eval|file_get_contents|include|require|require_once|shell_exec|phpinfo|system|passthru|preg_\w+|execute|echo|print|print_r|var_dump|(fp)open|alert|showmodaldialog)\( 15 | xwork\.MethodAccessor 16 | (gopher|doc|php|glob|file|phar|zlib|ftp|ldap|dict|ogg|data)\:\/ 17 | java\.lang 18 | \$_(GET|post|cookie|files|session|env|phplib|GLOBALS|SERVER)\[ 19 | \<(iframe|script|body|img|layer|div|meta|style|base|object|input) 20 | (onmouseover|onerror|onload)\= 21 | -------------------------------------------------------------------------------- /tools/waf/wafconf/url: -------------------------------------------------------------------------------- 1 | \.(svn|htaccess|bash_history) 2 | \.(bak|inc|old|mdb|sql|backup|java|class)$ 3 | (vhost|bbs|host|wwwroot|www|site|root|hytop|flashfxp).*.rar 4 | (phpmyadmin|jmx-console|jmxinvokerservlet) 5 | java\.lang 6 | /(attachments|upimg|images|css|uploadfiles|html|uploads|templets|static|template|data|inc|forumdata|upload|includes|cache|avatar)/(\\w+).(php|jsp) 7 | -------------------------------------------------------------------------------- /tools/waf/wafconf/user-agent: -------------------------------------------------------------------------------- 1 | (HTTrack|harvest|audit|dirbuster|pangolin|nmap|sqln|-scan|hydra|Parser|libwww|BBBike|sqlmap|w3af|owasp|Nikto|fimap|havij|PycURL|zmeu|BabyKrokodil|netsparker|httperf|bench| SF/) 2 | -------------------------------------------------------------------------------- /tools/waf/wafconf/whiteurl: -------------------------------------------------------------------------------- 1 | /123/ 2 | -------------------------------------------------------------------------------- /uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Check if user is root 3 | [ $(id -u) != "0" ] && echo "Error: You must be root to run this script" && kill -9 $$ 4 | 5 | export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 6 | clear 7 | echo "#########################################################################################################" 8 | echo "# LTMH/LNMH/LNMP/LTMP for CentOS 6+ Debian 7+ and Ubuntu 14+ #" 9 | echo "# Uninstall LTMH/LNMH/LNMP/LTMP #" 10 | echo "# For more information Please visit http://www.hhvmc.com/forum-36-1.html #" 11 | echo "#########################################################################################################" 12 | . ./options.conf 13 | 14 | Uninstall() 15 | { 16 | [ -e "$db_install_dir" ] && service mysqld stop && rm -rf /etc/init.d/mysqld /etc/my.cnf /etc/ld.so.conf.d/mysql.conf /usr/include/mysql 17 | [ -e "$apache_install_dir" ] && service httpd stop && rm -rf /etc/init.d/httpd 18 | [ -e "$php_install_dir" ] && service php-fpm stop && rm -rf /etc/init.d/php-fpm 19 | [ -e "$web_install_dir" ] && service nginx stop && rm -rf /etc/init.d/nginx /etc/logrotate.d/nginx /var/ngx_pagespeed_cache 20 | [ -e "$hhvm_install_dir" ] && service hhvm stop && rm -rf /etc/init.d/hhvm 21 | [ -e "$pureftpd_install_dir" ] && service pureftpd stop && rm -rf /etc/init.d/pureftpd 22 | [ -e "$redis_install_dir" ] && service redis-server stop && rm -rf /etc/init.d/redis-server 23 | [ -e "$memcached_install_dir" ] && service memcached stop && rm -rf /etc/init.d/memcached 24 | 25 | /bin/mv ${home_dir}{,_$(date +%F)} 26 | /bin/mv ${db_data_dir}{,_$(date +%F)} 27 | for D in `cat ./options.conf | grep dir= | grep -v lnmp | awk -F'=' '{print $2}' | sort | uniq` 28 | do 29 | [ -e "$D" ] && rm -rf $D 30 | done 31 | 32 | sed -i 's@^ltmh_dir=.*@ltmh_dir=@' ./options.conf 33 | sed -i 's@^web_install_dir=.*@web_install_dir=@' ./options.conf 34 | sed -i 's@^db_install_dir=.*@db_install_dir=@' ./options.conf 35 | sed -i 's@^db_data_dir=.*@db_data_dir=@' ./options.conf 36 | sed -i 's@^dbrootpwd=.*@dbrootpwd=@' ./options.conf 37 | sed -i 's@^ftpmanagerpwd=.*@ftpmanagerpwd=@' ./options.conf 38 | sed -i 's@^conn_ftpusers_dbpwd=.*@conn_ftpusers_dbpwd=@' ./options.conf 39 | sed -i "s@^export.*$db_install_dir.*@@g" /etc/profile && . /etc/profile 40 | echo -e "\033[32mUninstall completed.\033[0m" 41 | } 42 | 43 | get_char() 44 | { 45 | SAVEDSTTY=`stty -g` 46 | stty -echo 47 | stty cbreak 48 | dd if=/dev/tty bs=1 count=1 2> /dev/null 49 | stty -raw 50 | stty echo 51 | stty $SAVEDSTTY 52 | } 53 | 54 | echo 55 | echo -e "\033[31mYou will uninstall LTMH, Please backup your configure files and DB data! \033[0m" 56 | echo 57 | echo -e "\033[33mThe following directory or files will be remove: \033[0m" 58 | for D in `cat ./options.conf | grep dir= | grep -v lnmp | awk -F'=' '{print $2}' | sort | uniq` 59 | do 60 | [ -e "$D" ] && echo $D 61 | done 62 | [ -e "$web_install_dir" ] && echo -e "/etc/init.d/nginx\n/etc/logrotate.d/nginx" && [ -e "/var/ngx_pagespeed_cache" ] && echo '/var/ngx_pagespeed_cache' 63 | [ -e "$db_install_dir" ] && echo -e "/etc/init.d/mysqld\n/etc/my.cnf\n/etc/ld.so.conf.d/mysql.conf\n/usr/include/mysql" 64 | [ -e "$php_install_dir" ] && echo '/etc/init.d/php-fpm' 65 | [ -e "$pureftpd_install_dir" ] && echo '/etc/init.d/pureftpd' 66 | [ -e "$memcached_install_dir" ] && echo '/etc/init.d/memcached' 67 | [ -e "$redis_install_dir" ] && echo '/etc/init.d/redis-server' 68 | echo 69 | echo "Press Ctrl+c to cancel or Press any key to continue..." 70 | char=`get_char` 71 | 72 | while : 73 | do 74 | echo 75 | read -p "Do you want to uninstall LTMH? [y/n]: " uninstall_yn 76 | if [ "$uninstall_yn" != 'y' -a "$uninstall_yn" != 'n' ];then 77 | echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m" 78 | else 79 | break 80 | fi 81 | done 82 | 83 | [ "$uninstall_yn" == 'y' ] && Uninstall 84 | -------------------------------------------------------------------------------- /up_php.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | # Check if user is root 5 | [ $(id -u) != "0" ] && echo "Error: You must be root to run this script" && exit 1 6 | 7 | export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 8 | clear 9 | echo "#######################################################################"######################### 10 | echo "# LTMH/LNMH/LNMP/LTMP for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ " 11 | echo "# Upgrade phpMyAdmin for LTMP/LNMP #" 12 | echo "# For more information please visit http://www.hhvmc.com/forum-36-1.html #" 13 | echo "################################################################################################" 14 | 15 | cd src 16 | . ../options.conf 17 | [ ! -e "$php_install_dir" ] && echo -e "\033[31mThe PHP is not installed on your system!\033[0m " && exit 1 18 | 19 | get_char() 20 | { 21 | SAVEDSTTY=`stty -g` 22 | stty -echo 23 | stty cbreak 24 | dd if=/dev/tty bs=1 count=1 2> /dev/null 25 | stty -raw 26 | stty echo 27 | stty $SAVEDSTTY 28 | } 29 | 30 | echo 31 | Old_php_version=`$php_install_dir/bin/php -r 'echo PHP_VERSION;'` 32 | echo -e "Current PHP Version: \033[32m$Old_php_version\033[0m" 33 | while : 34 | do 35 | echo 36 | read -p "Please input upgrade PHP Version: " php_version 37 | if [ "${php_version%.*}" == "${Old_php_version%.*}" ]; then 38 | if [ "${php_version##*.}" -ge "${Old_php_version##*.}" ]; then 39 | [ ! -e "php-$php_version.tar.gz" ] && wget -c http://www.php.net/distributions/php-$php_version.tar.gz > /dev/null 2>&1 40 | if [ -e "php-$php_version.tar.gz" ];then 41 | echo -e "Download \033[32mphp-$php_version.tar.gz\033[0m successfully! " 42 | else 43 | echo -e "\033[31mIt does not exist!\033[0m" 44 | fi 45 | break 46 | else 47 | echo -e "Error: You must input PHP version not less than \033[32m$Old_php_version\033[0m!! " 48 | fi 49 | else 50 | echo -e "\033[31minput error!\033[0m Please only input '\033[32m${Old_php_version%.*}.xx' \033[0m" 51 | fi 52 | done 53 | 54 | if [ -e "php-$php_version.tar.gz" ];then 55 | echo -e "\033[32mphp-$php_version.tar.gz\033[0m [found]" 56 | echo "Press Ctrl+c to cancel or Press any key to continue..." 57 | char=`get_char` 58 | tar xzf php-$php_version.tar.gz 59 | wget -O fpm-race-condition.patch 'https://bugs.php.net/patch-display.php?bug_id=65398&patch=fpm-race-condition.patch&revision=1375772074&download=1' 60 | patch -d php-$php_version -p0 < fpm-race-condition.patch 61 | cd php-$php_version 62 | make clean 63 | $php_install_dir/bin/php -i |grep 'Configure Command' | awk -F'=>' '{print $2}' | bash 64 | make ZEND_EXTRA_LIBS='-liconv' 65 | make install 66 | cd .. 67 | echo "Restarting php-fpm..." 68 | /etc/init.d/php-fpm restart 69 | echo -e "You have \033[32msuccessfully\033[0m upgrade from \033[32m$Old_php_version\033[0m to \033[32m$php_version\033[0m" 70 | fi 71 | -------------------------------------------------------------------------------- /up_phpmyadmin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | # Check if user is root 5 | [ $(id -u) != "0" ] && echo "Error: You must be root to run this script" && exit 1 6 | 7 | export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 8 | clear 9 | echo "#######################################################################"################################### 10 | echo "# LTMH/LNMH/LNMP/LTMP for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ #" 11 | echo "# Upgrade phpMyAdmin for LTMH/LNMH/LNMP/LTMP #" 12 | echo "# For more information please visit http://www.hhvmc.com/forum-36-1.html #" 13 | echo "##########################################################################################################" 14 | 15 | cd src 16 | . ../options.conf 17 | 18 | [ ! -e "$home_dir/default/phpMyAdmin" ] && echo -e "\033[31mThe phpMyAdmin is not installed on your system!\033[0m " && exit 1 19 | 20 | get_char() 21 | { 22 | SAVEDSTTY=`stty -g` 23 | stty -echo 24 | stty cbreak 25 | dd if=/dev/tty bs=1 count=1 2> /dev/null 26 | stty -raw 27 | stty echo 28 | stty $SAVEDSTTY 29 | } 30 | echo 31 | 32 | Upgrade_phpMyAdmin() 33 | { 34 | Old_phpMyAdmin_version=`grep Version $home_dir/default/phpmyadmin/README | awk '{print $2}'` 35 | echo -e "Current phpMyAdmin Version: \033[32m$Old_phpMyAdmin_version\033[0m" 36 | while : 37 | do 38 | echo 39 | read -p "Please input upgrade phpMyAdmin Version(example: 4.1.5): " phpMyAdmin_version 40 | if [ "$phpMyAdmin_version" != "$Old_phpMyAdmin_version" ];then 41 | [ ! -e "phpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz" ] && wget -c http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/$phpMyAdmin_version/phpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz > /dev/null 2>&1 42 | if [ -e "phpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz" ];then 43 | echo -e "Download \033[32mphpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz\033[0m successfully! " 44 | break 45 | else 46 | echo -e "\033[31mphpMyAdmin version does not exist!\033[0m" 47 | fi 48 | else 49 | echo -e "\033[31minput error! The upgrade phpMyAdmin version is the same as the old version\033[0m" 50 | fi 51 | done 52 | 53 | if [ -e "phpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz" ];then 54 | echo -e "\033[32mphpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz\033[0m [found]" 55 | echo "Press Ctrl+c to cancel or Press any key to continue..." 56 | char=`get_char` 57 | tar xzf phpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz 58 | rm -rf $home_dir/default/phpmyadmin 59 | /bin/mv phpMyAdmin-${phpMyAdmin_version}-all-languages $home_dir/default/phpmyadmin 60 | /bin/cp $home_dir/default/phpmyadmin/{config.sample.inc.php,config.inc.php} 61 | mkdir $home_dir/default/phpmyadmin/{upload,save} 62 | sed -i "s@UploadDir.*@UploadDir'\] = 'upload';@" $home_dir/default/phpmyadmin/config.inc.php 63 | sed -i "s@SaveDir.*@SaveDir'\] = 'save';@" $home_dir/default/phpmyadmin/config.inc.php 64 | chown -R www.www $home_dir/default/phpmyadmin 65 | cd .. 66 | echo -e "You have \033[32msuccessfully\033[0m upgrade from \033[32m$Old_phpMyAdmin_version\033[0m to \033[32m$phpMyAdmin_version\033[0m" 67 | fi 68 | } 69 | Upgrade_phpMyAdmin 70 | -------------------------------------------------------------------------------- /up_redis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Check if user is root 3 | [ $(id -u) != "0" ] && echo "Error: You must be root to run this script" && exit 1 4 | 5 | export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 6 | clear 7 | echo "#######################################################################"#################### 8 | echo "# LTMH/LNMH/LNMP/LTMP for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ #" 9 | echo "# Upgrade phpMyAdmin for LTMH #" 10 | echo "# For more information please visit http://www.hhvmc.com/forum-36-1.html #" 11 | echo "###########################################################################################" 12 | 13 | cd src 14 | . ../options.conf 15 | 16 | [ ! -d "$redis_install_dir" ] && echo -e "\033[31mThe Redis is not installed on your system!\033[0m " && exit 1 17 | 18 | get_char() 19 | { 20 | SAVEDSTTY=`stty -g` 21 | stty -echo 22 | stty cbreak 23 | dd if=/dev/tty bs=1 count=1 2> /dev/null 24 | stty -raw 25 | stty echo 26 | stty $SAVEDSTTY 27 | } 28 | echo 29 | 30 | Upgrade_Redis() 31 | { 32 | Old_redis_version=`$redis_install_dir/bin/redis-cli --version | awk '{print $2}'` 33 | echo -e "Current Redis Version: \033[32m$Old_redis_version\033[0m" 34 | while : 35 | do 36 | echo 37 | read -p "Please input upgrade Redis Version(example: 2.8.4): " redis_version 38 | if [ "$redis_version" != "$Old_redis_version" ];then 39 | [ ! -e "redis-$redis_version.tar.gz" ] && wget -c http://download.redis.io/releases/redis-$redis_version.tar.gz > /dev/null 2>&1 40 | if [ -e "redis-$redis_version.tar.gz" ];then 41 | echo -e "Download \033[32mredis-$redis_version.tar.gz\033[0m successfully! " 42 | break 43 | else 44 | echo -e "\033[31mRedis version does not exist!\033[0m" 45 | fi 46 | else 47 | echo -e "\033[31minput error! The upgrade Redis version is the same as the old version\033[0m" 48 | fi 49 | done 50 | 51 | if [ -e "redis-$redis_version.tar.gz" ];then 52 | echo -e "\033[32mredis-$redis_version.tar.gz\033[0m [found]" 53 | echo "Press Ctrl+c to cancel or Press any key to continue..." 54 | char=`get_char` 55 | tar xzf redis-$redis_version.tar.gz 56 | cd redis-$redis_version 57 | make clean 58 | if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 32 ];then 59 | sed -i '1i\CFLAGS= -march=i686' src/Makefile 60 | sed -i 's@^OPT=.*@OPT=-O2 -march=i686@' src/.make-settings 61 | fi 62 | 63 | make 64 | 65 | if [ -f "src/redis-server" ];then 66 | echo -e "\nRestarting Redis..." 67 | service redis-server stop 68 | /bin/cp src/{redis-benchmark,redis-check-aof,redis-check-dump,redis-cli,redis-sentinel,redis-server} $redis_install_dir/bin/ 69 | service redis-server start 70 | echo -e "You have \033[32msuccessfully\033[0m upgrade from \033[32m$Old_redis_version\033[0m to \033[32m$redis_version\033[0m" 71 | else 72 | echo -e "\033[31mUpgrade Redis failed! \033[0m" 73 | fi 74 | cd .. 75 | fi 76 | } 77 | 78 | Upgrade_Redis 79 | -------------------------------------------------------------------------------- /up_web_ser.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | # Check if user is root 5 | [ $(id -u) != "0" ] && echo "Error: You must be root to run this script" && exit 1 6 | 7 | export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 8 | clear 9 | echo "#######################################################################"#################### 10 | echo "# LTMH/LNMH/LNMP/LTMP for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ #" 11 | echo "# Upgrade phpMyAdmin for LTMH #" 12 | echo "# For more information please visit http://www.hhvmc.com/forum-36-1.html #" 13 | echo "###########################################################################################" 14 | 15 | cd src 16 | . ../options.conf 17 | . ../tools/download.sh 18 | 19 | [ ! -e "$web_install_dir/sbin/nginx" ] && echo -e "\033[31mThe Nginx/Tengine is not installed on your system!\033[0m " && exit 1 20 | 21 | get_char() 22 | { 23 | SAVEDSTTY=`stty -g` 24 | stty -echo 25 | stty cbreak 26 | dd if=/dev/tty bs=1 count=1 2> /dev/null 27 | stty -raw 28 | stty echo 29 | stty $SAVEDSTTY 30 | } 31 | echo 32 | 33 | Upgrade_Nginx() 34 | { 35 | Old_nginx_version_tmp=`$web_install_dir/sbin/nginx -v 2>&1` 36 | Old_nginx_version=${Old_nginx_version_tmp##*/} 37 | echo -e "Current Nginx Version: \033[32m$Old_nginx_version\033[0m" 38 | while : 39 | do 40 | echo 41 | read -p "Please input upgrade Nginx Version(example: 1.4.7): " nginx_version 42 | if [ "$nginx_version" != "$Old_nginx_version" ];then 43 | [ ! -e "nginx-$nginx_version.tar.gz" ] && wget -c http://nginx.org/download/nginx-$nginx_version.tar.gz > /dev/null 2>&1 44 | if [ -e "nginx-$nginx_version.tar.gz" ];then 45 | echo -e "Download \033[32mnginx-$nginx_version.tar.gz\033[0m successfully! " 46 | break 47 | else 48 | echo -e "\033[31mNginx version does not exist!\033[0m" 49 | fi 50 | else 51 | echo -e "\033[31minput error! The upgrade Nginx version is the same as the old version\033[0m" 52 | fi 53 | done 54 | 55 | if [ -e "nginx-$nginx_version.tar.gz" ];then 56 | echo -e "\033[32mnginx-$nginx_version.tar.gz\033[0m [found]" 57 | echo "Press Ctrl+c to cancel or Press any key to continue..." 58 | char=`get_char` 59 | tar xzf nginx-$nginx_version.tar.gz 60 | cd nginx-$nginx_version 61 | make clean 62 | $web_install_dir/sbin/nginx -V &> $$ 63 | nginx_configure_arguments=`cat $$ | grep 'configure arguments:' | awk -F: '{print $2}'` 64 | rm -rf $$ 65 | ./configure $nginx_configure_arguments 66 | make 67 | if [ -f "objs/nginx" ];then 68 | /bin/mv $web_install_dir/sbin/nginx $web_install_dir/sbin/nginx$(date +%m%d) 69 | /bin/cp objs/nginx $web_install_dir/sbin/nginx 70 | kill -USR2 `cat /var/run/nginx.pid` 71 | kill -QUIT `cat /var/run/nginx.pid.oldbin` 72 | echo -e "You have \033[32msuccessfully\033[0m upgrade from \033[32m$Old_nginx_version\033[0m to \033[32m$nginx_version\033[0m" 73 | echo "Restarting Nginx..." 74 | /etc/init.d/nginx restart 75 | else 76 | echo -e "\033[31mUpgrade Nginx failed! \033[0m" 77 | fi 78 | cd .. 79 | fi 80 | } 81 | 82 | Upgrade_Tengine() 83 | { 84 | Old_tengine_version_tmp=`$web_install_dir/sbin/nginx -v 2>&1` 85 | Old_tengine_version="`echo ${Old_tengine_version_tmp#*/} | awk '{print $1}'`" 86 | echo -e "Current Tengine Version: \033[32m$Old_tengine_version\033[0m" 87 | while : 88 | do 89 | echo 90 | read -p "Please input upgrade Tengine Version(example: 1.5.1): " tengine_version 91 | if [ "$tengine_version" != "$Old_tengine_version" ];then 92 | [ ! -e "tengine-$tengine_version.tar.gz" ] && wget -c http://tengine.taobao.org/download/tengine-$tengine_version.tar.gz > /dev/null 2>&1 93 | if [ -e "tengine-$tengine_version.tar.gz" ];then 94 | echo -e "Download \033[32mtengine-$tengine_version.tar.gz\033[0m successfully! " 95 | break 96 | else 97 | echo -e "\033[31mTengine version does not exist!\033[0m" 98 | fi 99 | else 100 | echo -e "\033[31minput error! The upgrade Tengine version is the same as the old version\033[0m" 101 | fi 102 | done 103 | 104 | if [ -e "tengine-$tengine_version.tar.gz" ];then 105 | echo -e "\033[32mtengine-$tengine_version.tar.gz\033[0m [found]" 106 | echo "Press Ctrl+c to cancel or Press any key to continue..." 107 | char=`get_char` 108 | tar xzf tengine-$tengine_version.tar.gz 109 | cd tengine-$tengine_version 110 | make clean 111 | # make[1]: *** [objs/src/event/ngx_event_openssl.o] Error 1 112 | sed -i 's@\(.*\)this option allow a potential SSL 2.0 rollback (CAN-2005-2969)\(.*\)@#ifdef SSL_OP_MSIE_SSLV2_RSA_PADDING\n\1this option allow a potential SSL 2.0 rollback (CAN-2005-2969)\2@' src/event/ngx_event_openssl.c 113 | sed -i 's@\(.*\)SSL_CTX_set_options(ssl->ctx, SSL_OP_MSIE_SSLV2_RSA_PADDING)\(.*\)@\1SSL_CTX_set_options(ssl->ctx, SSL_OP_MSIE_SSLV2_RSA_PADDING)\2\n#endif@' src/event/ngx_event_openssl.c 114 | $web_install_dir/sbin/nginx -V &> $$ 115 | tengine_configure_arguments=`cat $$ | grep 'configure arguments:' | awk -F: '{print $2}'` 116 | rm -rf $$ 117 | ./configure $tengine_configure_arguments 118 | make 119 | if [ -f "objs/nginx" ];then 120 | /bin/mv $web_install_dir/sbin/nginx $web_install_dir/sbin/nginx$(date +%m%d) 121 | /bin/mv $web_install_dir/sbin/dso_tool $web_install_dir/sbin/dso_tool$(date +%m%d) 122 | /bin/mv $web_install_dir/modules $web_install_dir/modules$(date +%m%d) 123 | /bin/cp objs/nginx $web_install_dir/sbin/nginx 124 | /bin/cp objs/dso_tool $web_install_dir/sbin/dso_tool 125 | chmod +x $web_install_dir/sbin/* 126 | make install 127 | if [ -e "$web_install_dir/modules$(date +%m%d)/ngx_pagespeed.so" ];then 128 | cd $lnmp_dir/src 129 | rm -rf ngx_pagespeed* 130 | src_url=https://dl.google.com/dl/page-speed/psol/1.8.31.4.tar.gz && Download_src 131 | [ -s "ngx_pagespeed-1.8.31.4-beta.zip" ] && echo "ngx_pagespeed-1.8.31.4-beta.zip found" || wget -c --no-check-certificate -O ngx_pagespeed-1.8.31.4-beta.zip https://github.com/pagespeed/ngx_pagespeed/archive/master.zip 132 | 133 | unzip -q ngx_pagespeed-1.8.31.4-beta.zip 134 | /bin/mv ngx_pagespeed-master ngx_pagespeed-1.8.31.4-beta 135 | tar xzf 1.8.31.4.tar.gz -C ngx_pagespeed-1.8.31.4-beta 136 | cd tengine-$tengine_version 137 | $web_install_dir/sbin/dso_tool --add-module=$lnmp_dir/src/ngx_pagespeed-1.8.31.4-beta 138 | fi 139 | 140 | kill -USR2 `cat /var/run/nginx.pid` 141 | kill -QUIT `cat /var/run/nginx.pid.oldbin` 142 | echo -e "You have \033[32msuccessfully\033[0m upgrade from \033[32m$Old_tengine_version\033[0m to \033[32m$tengine_version\033[0m" 143 | echo "Restarting Tengine..." 144 | /etc/init.d/nginx restart 145 | else 146 | echo -e "\033[31mUpgrade Tengine failed! \033[0m" 147 | fi 148 | cd .. 149 | fi 150 | } 151 | 152 | if [ ! -e "$web_install_dir/sbin/dso_tool" ];then 153 | Upgrade_Nginx 154 | elif [ -e "$web_install_dir/sbin/dso_tool" ];then 155 | Upgrade_Tengine 156 | fi 157 | -------------------------------------------------------------------------------- /vhost_hhvm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Check if user is root 3 | if [ $(id -u) != "0" ]; then 4 | echo "Error: You must be root to run this script, use sudo sh $0" 5 | exit 1 6 | fi 7 | 8 | clear 9 | echo "=========================================================================" 10 | echo "Add Virtual Host for LTMH , Written by Andy " 11 | echo "=========================================================================" 12 | echo "LTMH is a tool to auto-compile & install Tengine+MySQL+HHVM on Linux " 13 | echo "This script is a tool to add virtual host for tengine " 14 | echo "For more information please visit http://www.hhvmc.com" 15 | echo "" 16 | echo "=========================================================================" 17 | 18 | if [ "$1" != "--help" ]; then 19 | 20 | 21 | domain="www.hhvmc.com" 22 | echo "Please input domain:" 23 | read -p "(Default domain: www.hhvmc.com):" domain 24 | if [ "$domain" = "" ]; then 25 | domain="www.hhvmc.com" 26 | fi 27 | if [ ! -f "/usr/local/nginx/conf/vhost/$domain.conf" ]; then 28 | echo "===========================" 29 | echo "domain=$domain" 30 | echo "===========================" 31 | else 32 | echo "===========================" 33 | echo "$domain is exist!" 34 | echo "===========================" 35 | fi 36 | 37 | echo "Do you want to add more domain name? (y/n)" 38 | read add_more_domainame 39 | 40 | if [ "$add_more_domainame" == 'y' ]; then 41 | 42 | echo "Type domainname,example(bbs.hhvmc.com forums.hhvmc.com ip.hhvmc.com):" 43 | read moredomain 44 | echo "===========================" 45 | echo domain list="$moredomain" 46 | echo "===========================" 47 | moredomainame=" $moredomain" 48 | fi 49 | 50 | vhostdir="/home/wwwroot/$domain" 51 | echo "Please input the directory for the domain:$domain :" 52 | read -p "(Default directory: /home/wwwroot/$domain):" vhostdir 53 | if [ "$vhostdir" = "" ]; then 54 | vhostdir="/home/wwwroot/$domain" 55 | fi 56 | echo "===========================" 57 | echo Virtual Host Directory="$vhostdir" 58 | echo "===========================" 59 | 60 | echo "===========================" 61 | echo "Allow Rewrite rule? (y/n)" 62 | echo "===========================" 63 | read allow_rewrite 64 | 65 | if [ "$allow_rewrite" == 'n' ]; then 66 | rewrite="none" 67 | else 68 | rewrite="other" 69 | echo "Please input the rewrite of programme :" 70 | echo "wordpress,discuz,typecho,sablog,dabr rewrite was exist." 71 | read -p "(Default rewrite: other):" rewrite 72 | if [ "$rewrite" = "" ]; then 73 | rewrite="other" 74 | fi 75 | fi 76 | echo "===========================" 77 | echo You choose rewrite="$rewrite" 78 | echo "===========================" 79 | 80 | echo "===========================" 81 | echo "Allow access_log? (y/n)" 82 | echo "===========================" 83 | read access_log 84 | 85 | if [ "$access_log" == 'n' ]; then 86 | al="access_log off;" 87 | else 88 | echo "Type access_log name(Default access log file:$domain.log):" 89 | read al_name 90 | if [ "$al_name" = "" ]; then 91 | al_name="$domain" 92 | fi 93 | al="access_log /home/wwwlogs/$al_name.log access;" 94 | echo "===========================" 95 | echo You access log file="$al_name.log" 96 | echo "===========================" 97 | fi 98 | 99 | get_char() 100 | { 101 | SAVEDSTTY=`stty -g` 102 | stty -echo 103 | stty cbreak 104 | dd if=/dev/tty bs=1 count=1 2> /dev/null 105 | stty -raw 106 | stty echo 107 | stty $SAVEDSTTY 108 | } 109 | echo "" 110 | echo "Press any key to start create virtul host..." 111 | char=`get_char` 112 | 113 | 114 | if [ ! -d /usr/local/nginx/conf/vhost ]; then 115 | mkdir /usr/local/nginx/conf/vhost 116 | fi 117 | 118 | echo "Create Virtul Host directory......" 119 | mkdir -p $vhostdir 120 | touch /home/wwwlogs/$al_name.log 121 | echo "set permissions of Virtual Host directory......" 122 | chmod -R 755 $vhostdir 123 | chown -R www:www $vhostdir 124 | 125 | if [ ! -f /usr/local/nginx/conf/$rewrite.conf ]; then 126 | echo "Create Virtul Host ReWrite file......" 127 | touch /usr/local/nginx/conf/$rewrite.conf 128 | echo "Create rewirte file successful,now you can add rewrite rule into /usr/local/nginx/conf/$rewrite.conf." 129 | else 130 | echo "You select the exist rewrite rule:/usr/local/nginx/conf/$rewrite.conf" 131 | fi 132 | 133 | cat >/usr/local/nginx/conf/vhost/$domain.conf<