首页 技术 正文
技术 2022年11月15日
0 收藏 450 点赞 2,770 浏览 4921 个字

#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

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,999
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,511
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,357
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,140
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,770
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,848