#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. iOS开发app启动原理及视图和控制器的函数调用顺序

    main()函数是整个程序的入口,在程序启动之前,系统会调用exec()函数.在Unix中exec和system的不同在于,system是用shell来调用程序,相当于fork+exec+waitpi ...

  2. MyBatis怎么防止SQL注入

    SQL注入是一种代码注入技术,用于攻击数据驱动的应用,恶意的SQL语句被插入到执行的实体字段中(例如,为了转储数据库内容给攻击者).[摘自] SQL injection - Wikipedia SQL ...

  3. 【splay模板】

    #include <iostream> #include <cstring> #include <algorithm> #include <cstdio> ...

  4. 事务BEGIN TRANSACTION

    事务(Transaction)是并发控制的基本单位.所谓的事务,它是一个操作序列,这些操作要么都执行,要么都不执行,它是一个不可分割的工作单位.例如,银行转账工作:从一个账号扣款并使另一个账号增款,这 ...

  5. js高级选择器querySelector和querySelectorAll

    querySelector 和 querySelectorAll 方法是 W3C Selectors API规范中定义的.他们的作用是根据 CSS 选择器规范,便捷定位文档中指定元素. 目前几乎主流浏 ...

  6. eclipse- Web-app verson=2.5 调整将Dynamic Web Module3.0降为2.5

    如果提示cannot change version of project facet Dynamic Web Module to 2.5 1.把Dynamic Web Module复选框,勾选去掉,点 ...

  7. 转载:align

    1. 原理    int a;    int size = 8;        <----> 1000(bin)计算a以size为倍数的下界数:    就让这个数(要计算的这个数)表示成二 ...

  8. jeasyui datagrid控件的一个小问题

    页面上用了datagrid,但今天把easyui更新到1.4.2以后出了个错,Cannot read property 'width' of null,以前用1.3.6的时候没有这个问题. 由于表格中 ...

  9. Linux学习(一):从图形界面进入命令行及命令行进入图形界面

    一.从图形界面进入命令行 最近脑洞大开,想接触一下linux.本人设备是win7,于是安了VMware(12.0.0)虚拟机,在安Linux(我用的CentOS 6.3 64)时不太会搞,跟据提示(英 ...

  10. mb_系列函数和普通字符函数的区别

    <?php //phpinfo(); $str = 'abcdef'; echo strlen($str);// 6 echo '<br/>'; echo substr($str, ...