#filename lamp.sh
#version Centos6.7;apache2.4.23;mariadb-5.5.40;php5.5.38
#data 2016/09/28
#mail 2385372006@qq.com
init()
{ #install pre
yum -y install cmake l readline-devel zlib-devel openssl-devel cmake gcc-c++ gcc boost boost-devel bison bison-devel ncurses-devel
#edit selinux
sed -ir 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/sysconfig/selinux
setenforce 0
#edit iptables
echo "-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT" >> /etc/sysconfig/iptables
echo "-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT" >> /etc/sysconfig/iptables
echo "-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT" >> /etc/sysconfig/iptables
echo "-A INPUT -m state --state NEW -m tcp -p tcp --dport 9000 -j ACCEPT" >> /etc/sysconfig/iptables
service iptables stop
#mkdir file
[ -d /usr/local/src ] || mkdir -p /usr/local/src
}
mysql_install()
{ useradd -s /sbin/nologin mysql
[ -d /data/mysql ] || mkdir -p /data/mysql && chown -R mysql.mysql /data/mysql
cd /usr/local/src
#wget http://archive.mariadb.org//mariadb-5.5.40/source/mariadb-5.5.40.tar.gz
tar xf mariadb-5.5.40.tar.gz
cd mariadb-5.5.40
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STPRAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWIYH_READLINE=1 -DWIYH_SSL=system -DVITH_ZLIB=system -DWITH_LOBWRAP=0 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
if [ $? -ne 0 ];then
echo "MySQL cmake fail, stop..."
exit 1
fi
make && make install
if [ $? -ne 0 ];then
echo "MySQL install fail, stop..."
exit 1
fi
cd /usr/local/mysql
chown -R mysql:mysql *
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql --basedir=/usr/local/mysql
rm -rf /etc/my.cnf
cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod u+x /etc/init.d/mysqld
sed -i 's#socket = /tmp/mysql.sock#&\n datadir=/data/mysql#g' /etc/my.cnf
#sed -ir 's#basedir=#basedir=/usr/local/mysql#g' /etc/init.d/mysqld
#sed -ir 's#datadir=#datadir=/data/mysql#g' /etc/init.d/mysqld
chkconfig --add mysqld;chkconfig mysqld on;/etc/init.d/mysqld start
if [ $? -ne 0 ];then
echo "MySQL install fail, stop..."
exit 1
fi
}
apache_install()
{
yum install -y pcre pcre-devel zlib-devel openssl openssl-devel
cd /usr/local/src
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.5.2.tar.gz
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.5.4.tar.gz
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-iconv-1.2.1.tar.gz
wget http://mirrors.aliyun.com/apache/httpd/httpd-2.4.23.tar.gz
#compile install apr apr-util apr-iconv
tar xf apr-1.5.2.tar.gz
cd apr-1.5.2
./configure --prefix=/usr/local/apr && make && make install
cd /usr/local/src
tar xf apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && make && make install
cd /usr/local/src
tar xf apr-iconv-1.2.1.tar.gz
./configure --prefix=/usr/local/apr-iconv --with-apr=/usr/local/apr && make && make install
cd /usr/local/src
tar xf httpd-2.4.23.tar.gz
cd httpd-2.4.23
./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-mpms-shared=all --with-mpm=event --enable-modules=all --enable-cache --enable-ratelimit
if [ $? -ne 0 ];then
echo "apache configure fail , stop... "
exit 1
fi
make && make install
if [ $? -ne 0 ];then
echo "apache make fail , stop... "
exit 1
fi
/usr/local/apache/bin/apachectl start
curl localhost
if [ $? -eq 0 ];then
echo "apache started OK,continue... "
else
echo "apachec started fail,top..."
exit 1
fi

}
php_install()
{
yum install -y epel-release libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel
yum install -y bzip2 bzip2-devel openssl openssl-devel libmcrypt-devel libxml2-devel gd gd-devel
cd /usr/local/src
wget http://mirrors.sohu.com/php/php-5.5.38.tar.gz
tar xf php-5.5.38.tar.gz
cd php-5.5.38
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/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 --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
if [ $? -ne 0 ];then
echo "php configure fail , stop... "
exit 1
fi
make && make install
if [ $? -ne 0 ];then
echo "php make fail , stop... "
exit 1
fi
test -d /usr/local/php/etc/ || mkdir /usr/local/php/etc/
cp php.ini-production /usr/local/php/etc/php.ini

}

apache_resolve_php()
{
#support resilve php
cd /usr/local/src
sed -i -e 's#AddType application/x-gzip .gz .tgz#&\n AddType application/x-httpd-php .php#g' /etc/httpd24/httpd.conf
sed -i 's#DirectoryIndex index.html#& index.htm index.php#g' /etc/httpd24/httpd.conf
#set apachectl as global variable
echo -e 'PATH=$PATH:/usr/local/mysql/bin:/usr/local/apache/bin\nexport PATH' >/etc/profile.d/path.sh;
source /etc/profile.d/path.sh
apachectl -t
apachectl restart
cat > /usr/local/apache/htdocs/index.php<<EOF
<?php
phpinfo();
?>
EOF
curl localhost && echo "php resolve OK" || echo "php resolve fail"
}
lamp_install()
{
init
mysql_install
apache_install
php_install
apache_resolve_php
}

lamp_install 2>&1 | tee ~/lmap_install.log

shell脚本编译安装LAMP环境的更多相关文章

  1. CentOS6.5下编译安装LAMP环境

    LAMP(Linux-Apache-MySQL-PHP)网站架构是目前国际流行的Web框架.该框架能够满足大流量.大并发量的网站需求:当然.也可以直接使用高性能的服务器.高性能的负载均衡硬件以及CDN ...

  2. 编译安装lamp环境

    httpd 2.4.9 + mysql-5.5.33 + php-5.4.29编译安装过程: 准备好以下安装包: mysql-5.5.33-linux2.6-x86_64.tar.gz apr-uti ...

  3. CentOS 6.3编译安装LAMP环境笔记

    转载地址:http://www.jb51.net/article/54969.htm 最近抽空在虚拟机上测试成功了LAMP各个最新版本的整合编译安装,算是把之前的博文整合精简,以下内容均在CENTOS ...

  4. Shell脚本一键安装LNMP环境

    https://sourceforge.net/projects/opensourcefile/files/ Nginx是一款高性能的HTTP和反向代理服务器.Nginx在反向代理,Rewrite规则 ...

  5. centos6.7下编译安装lamp环境

    编译C源代码: 前提:提供开发工具及开发环境 通过“包组”提供开发组件,CentOS 6: "Development Tools", "Server Platform D ...

  6. shell脚本自动化安装LAMP

    #!/bin/bash#auto make install LAMP#by authors yehailun #arp和apr-util依赖APR_FILES=apr-1.6.2.tar.gz APR ...

  7. 源码编译安装LAMP环境及配置基于域名访问的多虚拟主机

    实验环境及软件版本: CentOS版本: 6.6(2.6.32.-504.el6.x86_64) apache版本: apache2.2.27 mysql版本:  Mysql-5.6.23 php版本 ...

  8. Centos7源码编译安装LAMP环境

    参考地址:https://www.linuxidc.com/Linux/2018-03/151133.htm

  9. 安装 LAMP 环境(yum 版本) shell脚本

    #!/bin/bash # 安装 LAMP 环境(yum 版本) # 本脚本适用于 RHEL7(RHEL6 中数据库为 mysql) yum makecache &>/dev/null ...

随机推荐

  1. Time.MONTH及Calendar.MONTH 默认的月份为 0-11

    Time.MONTH及Calendar.MONTH 默认的月份为  0-11 所以使用的时候要自己加1.

  2. Net分布式系统之五:C#使用Redis集群缓存

    本文介绍系统缓存组件,采用NOSQL之Redis作为系统缓存层. 一.背景 系统考虑到高并发的使用场景.对于并发提交场景,通过上一章节介绍的RabbitMQ组件解决.对于系统高并发查询,为了提供性能减 ...

  3. Flash Builder常见菊紧问题集锦

    FB的错误多多,不定什么时候就让你蛋碎,路遇操蛋问题集锦如下: 1.有次用Flash Builder 4.7,打开之后马上自动关闭,试了几次都这样,解决办法如下: 到C:\Documents and ...

  4. python install_opener用法

    opener:当你获取一个URL时,你使用一个opener(OpenerDirector).正常情况下我们一直使用默认的opener,通过urlopen,但你也可以创建自定义的openers. url ...

  5. @ViewDebug.ExportedProperty的使用

    原文链接:http://daemon369.github.io/android/2014/06/12/android-viewdebug-exportedproperty/ http://www.eo ...

  6. Expected one result (or null) to be returned by selectOne(), but found 2

    这个问题在于你查询sql返回结果是多个值.一个集合,但是你在service的实现层的dao都调用了.get方法.而是应该使用.getlist方法等.

  7. python中获取今天昨天和明天的日期

    import datetime today = datetime.date.today()oneday = datetime.timedelta(days=1)yesterday = today-on ...

  8. jQuery的开始

    一.下载 jQuery http://jquery.com/download/ 二.什么是jQuery: 1.jQuery 是一个 JavaScript 库. 2.jQuery 极大地简化了 Java ...

  9. em 换算

    1 ÷ 父元素的font-size × 需要转换的像素值 = em值 http://www.w3cplus.com/css/px-to-em

  10. Lucene教程(转)

    Lucene教程 1 lucene简介1.1 什么是lucene    Lucene是一个全文搜索框架,而不是应用产品.因此它并不像www.baidu.com 或者google Desktop那么拿来 ...