标签:base mkdir isa input apach apr-util init.d ftp div
1 #!/bin/bash 2 3 #description:mysql-5.5.53.tar apache2.4.23 php5.6.27 4 5 6 function check_ok(){ 7 if [ $? -eq 0 ] 8 then 9 echo "-------------ok-------" 10 else 11 echo "please check error" 12 exit 13 fi 14 } 15 16 function set_yum(){ 17 echo "set yum repo" 18 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak 19 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo 20 # yum clean all &>/dev/null 21 yum makecache &>/dev/null 22 check_ok 23 } 24 25 26 function install_mysql(){ 27 echo "mysql5.5.53 will be installed,please be patient" 28 wget -O /usr/local/src/mysql-5.5.53.tar http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.53.tar.gz 29 cd /usr/local/src 30 tar -zxf mysql-5.5.53.tar 31 check_ok 32 cd /usr/local/src/mysql-5.5.53 33 useradd -u 8001 -s /sbin/nologin mysql 34 mkdir /data 35 yum install cmake -y 36 yum install ncurses-devel -y 37 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data -DMYSQL_USER=mysql 38 check_ok 39 make -j 4 && make install 40 check_ok 41 chown -R mysql:mysql /usr/local/mysql/ 42 chown -R mysql:mysql /data 43 44 cp support-files/my-large.cnf /etc/my.cnf 45 cp support-files/mysql.server /etc/init.d/mysqld 46 chmod +x /etc/init.d/mysqld 47 sed -i ‘s/^basedir=$/basedir=\/usr\/local\/mysql/‘ /etc/init.d/mysqld 48 sed -i ‘s/^datadir=$/datadir=\/data/‘ /etc/init.d/mysqld 49 chkconfig mysqld on 50 chmod +x scripts/mysql_install_db 51 /usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data --user=mysql 52 service mysqld start 53 54 iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT 55 /etc/init.d/iptables save 56 check_ok 57 echo ‘export PATH=/usr/local/mysql/bin:$PATH‘ >>/etc/profile 58 source /etc/profile 59 } 60 61 function install_apache(){ 62 echo "apache2.4.23 will be installed,please be patient" 63 cd /usr/local/src 64 wget http://mirrors.cnnic.cn/apache/apr/apr-1.5.2.tar.gz 65 wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.5.4.tar.gz 66 check_ok 67 tar zxf apr-1.5.2.tar.gz 68 cd apr-1.5.2 69 ./configure --prefix=/usr/local/apr 70 check_ok 71 make && make install 72 check_ok 73 74 cd /usr/local/src 75 tar zxf apr-util-1.5.4.tar.gz 76 cd apr-util-1.5.4 77 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr 78 check_ok 79 make && make install 80 check_ok 81 82 cd /usr/local/src 83 wget http://ftp.exim.llorien.org/pcre/pcre-8.39.tar.gz 84 tar xvf pcre-8.39.tar.gz 85 cd pcre-8.39 86 ./configure --prefix=/usr/local/pcre 87 make && make install 88 check_ok 89 90 cd /usr/local/src 91 wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.23.tar.gz 92 tar zxf httpd-2.4.23.tar.gz 93 /bin/cp -r apr-1.5.2 /usr/local/src/httpd-2.4.23/srclib/apr 94 /bin/cp -r apr-util-1.5.4 /usr/local/src/httpd-2.4.23/srclib/apr-util 95 cd /usr/local/src/httpd-2.4.23 96 ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre --enable-mods-shared=most --enable-so --with-included-apr 97 check_ok 98 make && make install 99 check_ok 100 cp -a /usr/local/apache2/bin/apachectl /etc/init.d/httpd 101 sed -i ‘1a #chkconfig: 2345 10 90‘ /etc/init.d/httpd 102 sed -i ‘2a #description: Activates/Deactivates Apache Web Server‘ /etc/init.d/httpd 103 echo "export PATH=$PATH:/usr/local/apache2/bin" >>/etc/profile 104 source /etc/profile 105 check_ok 106 chkconfig --add httpd 107 chkconfig httpd on 108 iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT 109 /etc/init.d/iptables save 110 check_ok 111 /usr/local/apache2/bin/apachectl 112 check_ok 113 service httpd restart 114 } 115 116 function install_php(){ 117 echo "php5.6.27 will be installed,please be patient" 118 cd /usr/local/src 119 wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz 120 tar zxvf libmcrypt-2.5.7.tar.gz 121 cd libmcrypt-2.5.7 122 ./configure --prefix=/usr/local/libmcrypt 123 make && make install 124 cd /usr/local/src 125 126 wget http://am1.php.net/get/php-5.6.27.tar.gz/from/this/mirror 127 128 tar zxf php-5.6.27.tar.gz 129 cd php-5.6.27 130 yum install openssl openssl-devel -y 131 yum install bzip2 bzip2-devel -y 132 ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt=/usr/local/libmcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif --disable-ipv6 133 134 135 check_ok 136 make -j 4 && make install 137 check_ok 138 139 cp /usr/local/src/php-5.6.27/php.ini-production /usr/local/php/etc/php.ini 140 sed -i ‘s#^;date.timezone =#date.timezone=Asia/Shanghai#‘ /usr/local/php/etc/php.ini 141 check_ok 142 # 143 } 144 function set_lamp(){ 145 sed -i ‘/AddType application\/x-gzip .gz .tgz/a\ AddType application/x-httpd-php .php\n‘ /usr/local/apache2/conf/httpd.conf 146 sed -i ‘s#index.html#index.html index.php#‘ /usr/local/apache2/conf/httpd.conf 147 sed -i ‘/#ServerName www.example.com:80/a\ServerName localhost:80\n‘ /usr/local/apache2/conf/httpd.conf 148 check_ok 149 cat >>/usr/local/apache2/htdocs/test.php<<EOF 150 <?php 151 echo "PHP is OK\n"; 152 phpinfo(); 153 ?> 154 EOF 155 156 /usr/local/apache2/bin/apachectl graceful 157 check_ok 158 } 159 160 161 function install_lamp(){ 162 install_mysql 163 install_apache 164 install_php 165 set_lamp 166 167 } 168 install_lamp
标签:base mkdir isa input apach apr-util init.d ftp div
原文地址:http://www.cnblogs.com/yuguangyuan/p/6020991.html