设为首页 收藏本站
查看: 746|回复: 0

LAMP一键安装脚本

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2014-11-6 08:33:35 | 显示全部楼层 |阅读模式
#!/bin/sh
#Copyright(c) 2010-2015 redapple (16325975@qq.com) 
#install LAMP
#Version 0.1.1
#Date 20140813
#------------增加yum源------------------------
rpm -ivh http://pkgs.repoforge.org/rpmfor ... 1.el6.rf.x86_64.rpm
rpm -ivh http://download.fedoraproject.or ... ease-6-8.noarch.rpm
#------------安装gcc------------------------
yum install gcc-c++  gcc ncurses-devel wget openssl openssl-devel zlib-devel unzip -y
#--------------时间同步--------------------
ntpdate tiger.sina.com.cn
hwclock -w
service iptables stop
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
yum -y remove httpd php mysql-server mysql php-mysql
installLog="/root/instlog.log"
function checkLog(){
[ $? -eq 0 ] && echo "Successfull! " || echo "configure is error,pls check it." && [ -f $installLog ] && tail -30 $installLog && exit 1
}
function msg(){
echo -n "now,Scripts is '$1' apache, this maybe take several mins, pls wait..."
}
function apr_err {
cd ..
[ ! -f apr-1.4.5.tar.gz ] && wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz  
[ ! -f apr-util-1.3.12.tar.gz ] && wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz  
[ ! -f pcre-8.10.zip ] && wget http://jaist.dl.sourceforge.net/ ... /8.10/pcre-8.10.zip  
yum remove apr-util-devel apr apr-util-mysql apr-docs apr-devel apr-util apr-util-docs -y
tar -zxf apr-1.4.5.tar.gz
#cd  apr-1.4.5
#./configure --prefix=/usr/local/apr  
#make && make install
#cd ..
tar -zxf apr-util-1.3.12.tar.gz  
#cd apr-util-1.3.12  
#./configure --prefix=/usr/local/apr-util -with- apr=/usr/local/apr/bin/apr-1-config  
#make && make install
[ ! -d ./httpd-2.4.10/srclib ] && echo "flies install err " && exit
\cp -rf ./apr-1.4.5  ./httpd-2.4.10/srclib/apr
\cp -rf ./apr-util-1.3.12   ./httpd-2.4.10/srclib/apr-util
unzip -o pcre-8.10.zip  
cd pcre-8.10
./configure --prefix=/usr/local/pcre >>$installLog
[ $? != 0 ] && echo "ERROR: pcre configure err" && checkLog
make && make install
cd ..
cd httpd-2.4.10
./configure \
--prefix=/usr/local/apache \
--with-included-apr \
--enable-so \
--with-mpm=prefork \
--enable-deflate=shared \
--enable-expires=shared \
--enable-headers=shared \
--enable-rewrite=shared \
--enable-static-support \
--with-crypto \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util/ \
--with-pcre=/usr/local/pcre >>$installLog
[ $? != 0 ] && echo "ERROR: Apache configure err" && checkLog
}
#----------------下载安装Apache------------------
groupadd apache
useradd -g apache -s /usr/sbin/nologin apache  
chown -R apache:apache /usr/local/apache
[ ! -f httpd-2.4.10.tar.gz ] && wget http://apache.fayea.com/apache-mirror/httpd/httpd-2.4.10.tar.gz
tar xf httpd-2.4.10.tar.gz
cd httpd-2.4.10
./configure \
--prefix=/usr/local/apache \
--with-included-apr \
--enable-so \
--enable-deflate=shared \
--enable-expires=shared \
--enable-headers=shared \
--enable-rewrite=shared \
--enable-static-support \
--with-mpm=prefork >>$installLog
[ $? != 0 ] && echo "ERROR: Apache configure err" && apr_err
msg make
make 2>&1
[ $? != 0 ] &&  echo "ERROR: Apache make err"
msg 'make install'
make install 2>&1
[ $? != 0 ] &&  echo "ERROR: Apache install err"
\cp ./build/rpm/httpd.init /etc/init.d/httpd
chmod 755 /etc/init.d/httpd
chkconfig --add httpd  
chkconfig --level 2345 httpd on  
chkconfig --list httpd
mv /etc/httpd  /etc/httpd_old
ln -fs /usr/local/apache/ /etc/httpd
ln -fs /usr/local/apache/bin/httpd /usr/sbin/httpd
ln -fs /usr/local/apache/bin/apachectl /usr/sbin/apachectl
rm -rf /var/log/httpd/  
ln -s /usr/local/apache/logs  /var/log/httpd  
sed -i '/#ServerName/a\ServerName localhost' /usr/local/apache/conf/httpd.conf
chown -R apache:apache /usr/local/apache
service  httpd start
ps -ef | grep httpd
echo "=============apache install OK !!!!============"
sleep 3
#----------------下载安装mysql------------------
cd ..
yum install cmake ncurses-devel -y
groupadd mysql
useradd -g mysql mysql -s /bin/false
mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql
[ ! -f mysql-5.5.38.tar.gz ] && wget http://mysql.mirror.kangaroot.ne ... mysql-5.5.38.tar.gz
tar xf mysql-5.5.38.tar.gz
cd mysql-5.5.38
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql \
-DSYSCONFDIR=/etc \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_unicode_ci \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_DEBUG=0
[ $? != 0 ] && exit
make && make install
[ -f /etc/my.cnf ] && rm -rf /etc/my.cnf
cp support-files/my-medium.cnf  /etc/my.cnf
sed -i 's#max_allowed_packet = 1M#max_allowed_packet = 16M#' /etc/my.cnf
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql --basedir=/usr/local/mysql
[ -f /etc/init.d/mysqld ] && rm -rf /etc/init.d/mysqld
cp ./support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
sed -i '46s#basedir=#basedir=/usr/local/mysql#' /etc/init.d/mysqld
sed -i '47s#datadir=#datadir=/data/mysql#' /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
service mysqld start
ps -ef |grep mysqld
echo "=============MYSQL install OK !!!!============"
#----------------下载并安装freetype------------------
cd ..
[ ! -f freetype-2.5.3.tar.gz ] && wget http://download.savannah.gnu.org ... eetype-2.5.3.tar.gz
tar -zxvf freetype-2.5.3.tar.gz
cd freetype-2.5.3
./configure --prefix=/usr/local/freetype
make && make install
#----------------下载并安装libmcrypt------------------
cd ..
[ ! -f libmcrypt-2.5.7.tar.gz ] && wget ftp://mcrypt.hellug.gr/pub/crypt ... mcrypt-2.5.7.tar.gz
tar -zxvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure   
make && make install
#----------------解决可能出现的libiconv错误------------------
[ ! -f libiconv-1.14.tar.gz ] && wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar xzf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make && make install
#----------------下载并安装jpegsrc.v9------------------
cd ..
[ ! -f jpegsrc.v9a.tar.gz ] && wget http://www.ijg.org/files/jpegsrc.v9a.tar.gz
tar -xf jpegsrc.v9a.tar.gz
cd jpeg-9a
./configure --prefix=/usr/local/jpeg
make && make install
#----------------下载并安装php------------------
cd ..
yum install -y libcurl bzip2-devel bzip2 libxml2-devel curl curl-devel gd libpng zlib
#---想让编译的php支持mcrypt、mhash扩展和libevent---------
#yum install libmcrypt libmcrypt-devel mhash mhash-devel mcrypt
[ ! -f php-5.5.15.tar.gz ] && wget http://cn2.php.net/distributions/php-5.5.15.tar.gz
tar xf php-5.5.15.tar.gz
cd php-5.5.15
./configure \
--prefix=/usr/local/php \
--with-mysql=/usr/local/mysql \
--with-openssl \
--enable-sockets \
--enable-sysvshm  \
--enable-xml  \
--enable-mbstring \
--enable-bcmath \
--enable-soap  \
--enable-shmop \
--enable-sysvsem \
--enable-pcntl \
--enable-zip \
--enable-fastcgi \
--enable-gd-native-ttf \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-iconv=/usr/local/libiconv \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-freetype-dir=/usr/local/freetype \
--with-jpeg-dir=/usr/local/jpeg \
--with-png-dir \
--with-zlib-dir \
--with-libxml-dir=/usr \
--with-mhash \
--with-mcrypt  \
--with-gettext \
--with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d \
--with-bz2 \
--with-curl \
--with-xmlrpc \
--without-pear  
[ $? != 0 ] && exit
make && make install
cp ./php.ini-production /usr/local/php/etc/php.ini
sed -i 's#;date.timezone =#date.timezone = PRC#' /etc/php.ini
sed -i 's#expose_php = On#expose_php = OFF#' /etc/php.ini
sed -i '/AddType text\/html .shtml/aAddType application\/x-httpd-php .php\n' /etc/httpd/conf/httpd.conf
service  httpd restart
ps -ef | grep httpd
#----------------新建index.php的测试页面------------------
cat > /var/www/html/index.php << EOF
<?php
phpinfo();
?>
EOF
echo "=============PHP install OK !!!!============"
echo "=============LAMP install OK !!!!============"

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-27196-1-1.html 上篇帖子: LNMP一键安装shell脚本 下篇帖子: Linux下查看nginx,apache,mysql,php的编译参数
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表