shell脚本编译安装LAMP环境
#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环境的更多相关文章
- CentOS6.5下编译安装LAMP环境
LAMP(Linux-Apache-MySQL-PHP)网站架构是目前国际流行的Web框架.该框架能够满足大流量.大并发量的网站需求:当然.也可以直接使用高性能的服务器.高性能的负载均衡硬件以及CDN ...
- 编译安装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 ...
- CentOS 6.3编译安装LAMP环境笔记
转载地址:http://www.jb51.net/article/54969.htm 最近抽空在虚拟机上测试成功了LAMP各个最新版本的整合编译安装,算是把之前的博文整合精简,以下内容均在CENTOS ...
- Shell脚本一键安装LNMP环境
https://sourceforge.net/projects/opensourcefile/files/ Nginx是一款高性能的HTTP和反向代理服务器.Nginx在反向代理,Rewrite规则 ...
- centos6.7下编译安装lamp环境
编译C源代码: 前提:提供开发工具及开发环境 通过“包组”提供开发组件,CentOS 6: "Development Tools", "Server Platform D ...
- shell脚本自动化安装LAMP
#!/bin/bash#auto make install LAMP#by authors yehailun #arp和apr-util依赖APR_FILES=apr-1.6.2.tar.gz APR ...
- 源码编译安装LAMP环境及配置基于域名访问的多虚拟主机
实验环境及软件版本: CentOS版本: 6.6(2.6.32.-504.el6.x86_64) apache版本: apache2.2.27 mysql版本: Mysql-5.6.23 php版本 ...
- Centos7源码编译安装LAMP环境
参考地址:https://www.linuxidc.com/Linux/2018-03/151133.htm
- 安装 LAMP 环境(yum 版本) shell脚本
#!/bin/bash # 安装 LAMP 环境(yum 版本) # 本脚本适用于 RHEL7(RHEL6 中数据库为 mysql) yum makecache &>/dev/null ...
随机推荐
- 9png图片制作
制作步骤不多说了,这儿有链接:http://blog.csdn.net/pugongying1988/article/details/6938972 链接中去边框一个像素可以不用做,直接用androi ...
- web之css伪类
利用伪类清楚浮动: 代码: <!DOCTYPE html> <htmllang="en"> <head> <metacharset=&qu ...
- 仿QQ的底部选项
效果图: item_add.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout ...
- 九宝老师微信小程序开发的过程
- modelsim无法识别include文件的解决方法
modelsim发现include关联的文件编译报语法错误,文件名需要写绝对路径,即使这个文件和工程其它文件在一个目录上.例如只写成 `include "c0_ddr3_model_para ...
- 集合框架遍历方式之——for-each循环
从Java5起,在Java中有了for-each循环,可以用来循环遍历collection和array.Foreach循环允许你在无需保持传统for循环中的索引,或在使用iterator /ListI ...
- Android新建数据库和建表demo
public class DBHelper extends SQLiteOpenHelper{ public final static String DATABASENAME ="diary ...
- php入门,配置wampserver
wamp安装过程中将网站的根目录设置在www目录下,这里记录如何定义自己的根目录,以便以后需要是查看 1.启动wampserver,左键选择apache下的httpd.conf,将文件中Documen ...
- 关于JS 事件冒泡和onclick,click,on()事件触发顺序
今天在给JQgrid中的标签添加click事件的时候,发现一个问题. JQgrid的table中,点击任何位置,都会勾选点击行的checkbox,而我希望在点击我的标签的时候,不要勾选checkbox ...
- Create side-by-side stereo pairs in the Unity game engine
Create side-by-side stereo pairs in the Unity game engine Paul BourkeDecember 2008 Sample Island pro ...