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

[经验分享] bash

[复制链接]

尚未签到

发表于 2018-11-21 11:21:53 | 显示全部楼层 |阅读模式
  安装包版本:
httpd-2.2.29.tar.gz
zlib-1.2.8.tar.gz
apr-util-1.5.4.tar.gz
apr-1.5.1.tar.gz
libpng-1.6.17.tar.gz
jpegsrc.v9a.tar.gz
libgd-gd-2.1.1.tar.gz
php-5.6.7.tar.gz
freetype-2.5.5.tar.gz
libmcrypt-2.5.8.tar.gz
libxml2-2.9.2.tar.gz
mysql-5.6.23.tar.gz

======安装包下载网站=======================
httpd  http://mirrors.sohu.com/apache/
mysql  http://mirrors.sohu.com/mysql/
php  http://mirrors.sohu.com/php/
phpMyAdmin  http://www.phpmyadmin.net/home_page/downloads.php
libxml2  ftp://xmlsoft.org/libxml2/
libmcrypt  http://sourceforge.net/projects/mcrypt/files/Libmcrypt
gd  http://libgd.github.io
zlib  http://www.zlib.net
autoconf  http://ftp.gnu.org/gnu/autoconf/
freetype  http://download.savannah.gnu.org/releases/freetype/
libpng  ftp://ftp.simplesystems.org/pub/libpng/png/src/
jpegsrc  http://www.ijg.org/files/
  ============================================
shell-scripts源码安装LAMP服务
#!/bin/bash
#auto install LAMP by source code
#by colink on 2015-05-01
TARPATH='/soft/install/'
WGETPATH='/soft/lamp/'
#提前安装一些工具包和依赖包
echo -e "\033[32mInstall cmake and ntpdate servers,Please wait...\033[0m"
yum -y install  cmake  vim  wget  lrzsz  unzip man  ntpdate  gcc*  autoconf  libtool  python-devel  libXpm-devel  ncurses-devel  git
#初始化部分系统环境
#echo "alias vi='vim'" >>/root/.bashrc && source /root/.bashrc
echo -e "\033[32mNtpdate is running,Please wait...\033[0m"
ntpdate pool.ntp.org
sleep 3
#create download directory  
if [ ! -d ${WGETPATH} ];then
echo -e "The ${WGETPATH} does not exist, Will create it. "
    mkdir -p ${WGETPATH}
fi
#Download LAMP install package
#wget --no-clobber -c --directory-prefix=${WGETPATH} "http://mirrors.sohu.com/php/php-5.6.8.tar.gz" "http://mirror.bit.edu.cn/mysql/Downloads/MySQL-5.7/mysql-5.7.6-m16.tar.gz" "http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.12.tar.gz"
#Create tar directory  
if [ ! -d ${TARPATH} ];then
echo -e "The ${TARPATH} does not exist, Will create it. "
    mkdir -p ${TARPATH}
fi
#TAR all install package
for i in `find ${WGETPATH} -maxdepth 1 -name "*.tar.gz"`
do
tar -zxf "${i}" -C "${TARPATH}"
if [ $? -eq 0 ];then
echo -e "\033[32m解压文件${i}到${TARPATH}成功\033[0m"
else
exit
fi
done
#find ${TARPATH} -maxdepth 1 -type d >/tmp/installlist.txt
#Apr define path variable
APR_DIR="${TARPATH}apr-1.5.1"
APR_PREFIX='/usr/local/apr'
#Apr-util define path variable
APR_UTIL_DIR="${TARPATH}apr-util-1.5.4"
APR_UTIL_PREFIX='/usr/local/apr-util'
#Httpd define path variable
HTTPD_DIR="${TARPATH}httpd-2.2.29"
HTTPD_PREFIX='/usr/local/apache2'
function Apache_install()
{
cd ${APR_DIR}
./configure --prefix=${APR_PREFIX} && make && make install
if [ $? -eq 0 ];then
echo -e "\033[32mThe apr was installed successfully.\033[0m"
cd ${APR_UTIL_DIR}
    ./configure  --prefix=${APR_UTIL_PREFIX} --with-apr=${APR_PREFIX} && make -j4 && make -j4 install
if [ $? -eq 0 ];then
echo -e "\033[32mThe apr-util was installed successfully.\033[0m"
    cd ${HTTPD_DIR}
    ./configure --prefix=${HTTPD_PREFIX} --with-apr=${APR_PREFIX} --with-apr-util=${APR_UTIL_PREFIX} --enable-deflate=shared --enable-rewrite=shared --enable-static-support --with-mpm=worker && make -j4 && make -j4 install
    if [ $? -eq 0 ];then
echo -e "\033[32mThe httpd was installed successfully to ${HTTPD_PREFIX}\033[0m"
else
echo -e "\033[31mThe httpd is installed failed,Please check...\033[0m"
exit
fi
else
        echo -e "\033[31mThe apr-util is installed failed,Please check...\033[0m"
    exit
fi
else
echo -e "\033[31mThe apr is installed failed,Please check...\033[0m"
exit
fi
}
#Mysql define path variable
MYSQL_DIR="${TARPATH}mysql-5.6.23"
MYSQL_PREFIX='/usr/local/mysql2'
MYSQL_DATA_DIR='/data/mysql2'
#注意,如果上面修改了安装路径,请务必修改下面这条语句sed部分的mysql安装路径
MYSQL_STATUS_A=`ps -ef |grep mysql |awk 'NR==1 {print $9}' |sed 's/\/usr\/local\/mysql2\/bin\///g'`
#MYSQL_STATUS_B=``
function Mysql_install()
{
cd ${MYSQL_DIR} && mkdir -p ${MYSQL_DATA_DIR} && cmake . -LH && cmake . -DCMAKE_INSTALL_PREFIX=${MYSQL_PREFIX} -DMYSQL_DATADIR=${MYSQL_DATA_DIR} -DWITH_INNOBASE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci
if [ $? -eq 0 ];then
make -j4 && make -j4 install
    else
echo -e "\033[31mThe Mysql is installed failed,Please check...\033[0m"
       exit
    fi
cd ${MYSQL_PREFIX} ; groupadd mysql ; useradd -g mysql mysql ; chown -R root:mysql ${MYSQL_PREFIX} && chown -R mysql:mysql ${MYSQL_DATA_DIR} ;
cp ${MYSQL_PREFIX}/support-files/my-default.cnf /etc/my.cnf && cp ${MYSQL_PREFIX}/support-files/mysql.server /etc/init.d/mysqld &&
${MYSQL_PREFIX}/scripts/mysql_install_db --user=mysql --basedir=${MYSQL_PREFIX} --datadir=${MYSQL_DATA_DIR} &&
echo "export PATH="\$PATH":${MYSQL_PREFIX}/bin/" >>/root/.bash_profile && source /root/.bash_profile && service mysqld restart
if [ "${MYSQL_STATUS_A}" = 'mysqld_safe' ];then
echo -e "\033[32mThe Mysql was installed successfully to ${MYSQL_PREFIX}\033[0m"
service mysqld stop ;
else
    echo -e "\033[31mThe Mysql is installed failed,Please check...\033[0m"
        exit
fi
}
################################################
#INSTALL PHP AND GD
#PHP define path variable
PHP_DIR="${TARPATH}php-5.6.7"
PHP_PREFIX='/usr/local/php2'
#用i增长来判断php的扩展是否安装成功
i=0
#zlib define path variable
ZLIB_DIR="${TARPATH}zlib-1.2.8"
ZLIB_PREFIX='/usr/local/zlib'
#libxml2 define path variable
LIBXML2_DIR="${TARPATH}libxml2-2.9.2"
LIBXML2_PREFIX='/usr/local/libxml2'
#libmcrypt define path variable
LIBMCRYPT_DIR="${TARPATH}libmcrypt-2.5.8"
LIBMCRYPT_PREFIX='/usr/local/libmcrypt'
#Others define path variable
FREETYPE_DIR="${TARPATH}freetype-2.5.5"
JPEG9A_DIR="${TARPATH}jpeg-9a"
LIBPNG_DIR="${TARPATH}libpng-1.6.17"
#libgd define path variable
LIBGD_DIR="${TARPATH}libgd-gd-2.1.1"
LIBGD_PREFIX='/usr/local/libgd'
function php_install()
{
#install freetype
cd ${FREETYPE_DIR} && ./configure && make -j4 && make -j4 install
if [ $? -eq 0 ];then
        ((i++));
    else
echo -e "\033[31mThe ${FREETYPE_DIR} is installed failed,Please check...\033[0m"
exit
    fi
#install jpeg-9a
    cd ${JPEG9A_DIR} && ./configure && make -j4 && make -j4 install
    if [ $? -eq 0 ];then
        ((i++));
    else
        echo -e "\033[31mThe ${JPEG9A_DIR} is installed failed,Please check...\033[0m"
        exit
    fi
#install libpng
    cd ${LIBPNG_DIR} && ./configure && make -j4 && make -j4 install
    if [ $? -eq 0 ];then
        ((i++));
    else
        echo -e "\033[31mThe ${LIBPNG_DIR} is installed failed,Please check...\033[0m"
        exit
    fi
#install libgd
    cd ${LIBGD_DIR} &&
cmake . -DCMAKE_INSTALL_PREFIX=${LIBGD_PREFIX} -DENABLE_FREETYPE=on -DENABLE_JPEG=on -DENABLE_PNG=on -DENABLE_XPM=on -DFREETYPE_INCLUDE_DIR_freetype2=/usr/local/include/freetype2
    if [ $? -eq 0 ];then
make -j4 && make -j4 install
    if [ $? -eq 0 ];then
    ((i++));
    else
    echo -e "\033[31mThe ${LIBGD_DIR} is installed failed,Please check...\033[0m"
exit
    fi
else
echo -e "\033[31mThe ${LIBGD_DIR} is installed failed,Please check...\033[0m"
exit
fi
#install libmcrypt
    cd ${LIBMCRYPT_DIR} &&
./configure --prefix=${LIBMCRYPT_PREFIX} && make -j4 && make -j4 install
    if [ $? -eq 0 ];then
        ((i++));
    else
        echo -e "\033[31mThe ${LIBMCRYPT_PREFIX} is installed failed,Please check...\033[0m"
        exit
    fi
#install zlib
    cd ${ZLIB_DIR} &&
    ./configure --prefix=${ZLIB_PREFIX} && make -j4 && make -j4 install
    if [ $? -eq 0 ];then
        ((i++));
    else
        echo -e "\033[31mThe ${ZLIB_PREFIX} is installed failed,Please check...\033[0m"
        exit
    fi
#install libxml2
    cd ${LIBXML2_DIR} &&
    ./configure --prefix=${LIBXML2_PREFIX} && make -j4 && make -j4 install
    if [ $? -eq 0 ];then
        ((i++));
    else
        echo -e "\033[31mThe ${LIBXML2_PREFIX} is installed failed,Please check...\033[0m"
        exit
    fi
#判断i的值,如果i=7,将继续安装php,否则退出安装
#因为在安装php之前,安装了7个php的扩展包,所以i=7
    if [ $i -eq 7 ];then
#install php server
cd ${PHP_DIR} &&
./configure --prefix=${PHP_PREFIX} --with-config-file-path=${PHP_PREFIX}/etc --with-apxs2=${HTTPD_PREFIX}/bin/apxs --with-pdo-mysql=mysqlnd --with-mysql=mysqlnd  --with-mysqli=mysqlnd --enable-mysqlnd --with-libxml-dir=${LIBXML2_PREFIX} --with-zlib-dir=${ZLIB_PREFIX} --with-mcrypt=${LIBMCRYPT_PREFIX} --with-gd  --with-jpeg-dir  --with-png-dir --with-xpm-dir --with-freetype-dir --enable-mbstring=all --enable-sockets --enable-soap
if [ $? -eq 0 ];then
make -j4 && make -j4 install
if [ $? -eq 0 ];then
            cp ${PHP_DIR}/php.ini-production ${PHP_PREFIX}/etc/php.ini
#此处,如果php安装成功i=8的话,那就修改相应的配置文件
((i++));
echo -e "\033[32mThe PHP was installed successfully to ${PHP_PREFIX}\033[0m"
else
echo -e "\033[31mThe PHP is installed failed,Please check...\033[0m"
exit
        fi
else
    echo -e "\033[31mThe PHP is installed failed,Please check...\033[0m"
exit
fi
    else
        echo -e "\033[31mInstalled failed,Please check PHP's GD and so on...\033[0m"
        exit
    fi
#成功安装php之后,修改apache的配置文件,整合php等
    if [ $i -eq 8 ];then
echo -e "\033[32mWill modify the configuration of Apache and PHP\033[0m"
cp ${HTTPD_PREFIX}/conf/httpd.conf ${HTTPD_PREFIX}/conf/httpd.conf.bak
echo "Addtype application/x-httpd-php  .php  .phtml" >> ${HTTPD_PREFIX}/conf/httpd.conf
sed -i 's/Options Indexes FollowSymLinks/Options FollowSymLinks/g' ${HTTPD_PREFIX}/conf/httpd.conf
sed -i 's/DirectoryIndex index.html/DirectoryIndex index.html index.php /g' ${HTTPD_PREFIX}/conf/httpd.conf
#测试php是否全面安装成功
if [ $? -eq 0 ];then
echo -e "\033[32mIt's successfully, Will test the PHP... \033[0m"
cat >${HTTPD_PREFIX}/htdocs/phpinfo.php

运维网声明 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-637724-1-1.html 上篇帖子: apache编译问题汇总 下篇帖子: http服务器在apache上的配置
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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