lamp环境部署脚本-y

系统环境:centos6.X

关于lamp环境的安装脚本,直接复制即可使用

注:apache2.2.X 版本和apache2.4.X版本

本人推荐兼容性版本安装 apache2.4.25 + apr1.5.2 + apr-util 1.5.4 (并且支持ssl模块,https证书访问),安装前需要先根据自己需求修改版本号进行安装

#!/bin/bash
#date:2018-01-01
#
################################# function 配置区域 #######################################
################################ 环境统一依赖安装包 ######################################

depend_pkg (){
    yum install gcc gcc-c++ make cmake ncurses-devel libxml2-devel \
        perl-devel libcurl-devel libgcrypt libgcrypt-devel libxslt \
        libxslt-devel pcre-devel openssl-devel wget bzip2-devel \
        curl-devel db4-devel libjpeg-devel libpng-devel libXpm-devel \
        gmp-devel libc-client-devel openldap-devel gd freetype \
        freetype-devel libjpeg* libpng zlib zlib-devel autoconf \
        automake libtool expat-devel bison libtermcap-devel -y
    CPU_NUM=`cat /proc/cpuinfo | grep processor | wc -l`
    let CPUS=${CPU_NUM}-1
}

######################### 变量修改函数区域 | 以及全局环境变量 ############################

All_path_1(){
    Server_ip=192.168.1.102         # 本主机IP    
    Apache_version=2.4.25           # Apache 服务的版本号,如果没有限制,推荐默认安装的版本为 2.4.25 和 apr 1.5.2 apr-util1.5.4 是兼容的
    Mysql_version=5.6.17            # Mysql 版本号,如果没有限制,默认安装的版本为 5.6.17
Libmcrypt_version=2.5.8 # 默认推荐安装的版本2.5.8
Mhash_version=0.9.9.9           # 默认推荐的版本0.9.9.9
Libiconv_version=1.13           # 默认推荐的版本1.13 Php_version=5.6.32 # Php的版本号,如果没有限制,默认安装的版本为 5.6.26 Apr_version=1.5.2 # Apr 的版本号,如果没有兼容性要求,默认安装的版本为 1.5.2 Apr_util_version=1.5.4 # Apr_util 的版本号,如果没有兼容性要求,默认安装的版本为 1.5.4 Mysql_port=3306 # MySQL 的监听端口号 }

 

All_path_2(){
    Work_source_dir=/usr/local                                  # 配置路径,可以进行修改
    Work_boost_dir=${Work_source_dir}                           # 针对MySQL boost文件配置的存放路径
    Work_dir=${Work_source_dir}/src                             # 源码包的存放路径,可以根据修改 {Work_source_dir}这个变量进行,变更位置
    Web_home_dir=/apptest                                       # web
    Web_root_dir=${Web_home_dir}/web/project                    # web 测试网站的程序目录位置
    Web_logs_dir=${Web_home_dir}/logs                           # web 日志路径位置 
    Http_install_dir=${Work_source_dir}/httpd${Apache_version}  # apache 的安装路径
    Httpd_config_dir=${Http_install_dir}/conf                   # apache 的主配置文件目录 
    Mysql_install_dir=${Work_source_dir}/mysql${Mysql_version}  # mysql 的安装路径
    Mysql_conf_dir=${Mysql_install_dir}/etc                     # mysql 配置文件的路径 
    Mysql_data_dir=${Mysql_install_dir}/data                    # mysql 数据存放目录
    Mysql_log_dir=${Mysql_install_dir}/data                     # mysql 日志存放目录
    Mysql_socket_dir=${Mysql_install_dir}/data                  # mysql socket 存放路径位置 
    Mysql_server_id=1                                           # mysql 唯一的ID值
    Php_install_dir=${Work_source_dir}/php${Php_version}        # php 安装路径
    Php_config_dir=${Php_install_dir}/etc                       # php 配置文件路径
}

#############################     Apache 安装相关函数   #################################

Apr_install(){
    cd $Work_dir
    [ -f "apr-${Apr_version}.tar.gz" ]             || wget  http://archive.apache.org/dist/apr/apr-${Apr_version}.tar.gz
    tar   xvf   apr-${Apr_version}.tar.gz
    cd apr-${Apr_version}
    echo  -e "\033[34m 开始安装apache依赖软件包apr. . . . . .\033[0m"
    sleep  2
    ./configure --prefix=${Work_source_dir}/apr
    make  -j ${CPUS} && make install
}
Apr_util_install(){
    if  [ $? -eq 0 ];then
        echo  -e "\033[34m  Apr  Install  Successed ! \033[0m"
        sleep  2
        echo  -e "\033[34m  Beging  Starting   Install  Apr-util  \033[0m"
        sleep  2
        cd $Work_dir
        [ -f "apr-util-${Apr_util_version}.tar.gz" ]   || wget  http://archive.apache.org/dist/apr/apr-util-${Apr_util_version}.tar.gz
        tar   xvf   apr-util-${Apr_util_version}.tar.gz
        cd    apr-util-${Apr_util_version}
        sleep  2 
        ./configure  --with-apr=${Work_source_dir}/apr 
        #./configure --prefix=${Work_source_dir}/apr-util --with-apr=${Work_source_dir}/apr
        make  -j ${CPUS} &&   make install
        if  [ $? -eq 0 ];then
            echo  -e "\033[34m Apr-util  Install  Successed ! \033[0m" ; sleep 2 
        else
            echo  -e "\033[34m Apr-util  Install  Failed ! \033[0m"
        fi
    else
        echo  -e "\033[34m  Apr  Install  Failed ! \033[0m"
        exit 1
    fi
    sleep 2
}
Apache_install(){
    cd $Work_dir
    [ -f "httpd-${Apache_version}.tar.gz" ]        || wget  http://archive.apache.org/dist/httpd/httpd-${Apache_version}.tar.gz
    tar   zxf   httpd-${Apache_version}.tar.gz
    cd    httpd-${Apache_version}
    #优化apache的请求数操作
    perl -pi -e "s/DEFAULT_SERVER_LIMIT 256/DEFAULT_SERVER_LIMIT 15000/g"  server/mpm/prefork/prefork.c
    echo  -e "\033[34m 开始编译 apache 服务. . . . . .\033[0m"
    sleep 2
    #./configure --prefix=$Http_install_dir   --with-apr=${Work_source_dir}/apr --with-apr-util=${Work_source_dir}/apr-util
    ./configure --prefix=$Http_install_dir   --enable-modules=all  --with-apr=${Work_source_dir}/apr    \
                --enable-expires=shared --enable-usertrack=shared  --enable-vhost-alias=shared          \
                --enable-rewrite=shared --enable-speling=shared  --enable-proxy=shared --enable-so      \
                --with-mpm=prefork --with-expat=builtin   --enable-ssl 
    make  -j  ${CPUS}  &&   make install
    if  [ $? -eq 0 ] ;then 
        echo  -e  "\033[34m  Apache  Service  Install  Successed ! \033[0m"
        sleep 2
        useradd  -s /sbin/nologin  apache 
        sed -i "s/#ServerName www.example.com:80/ServerName ${Server_ip}:80/g"     ${Httpd_config_dir}/httpd.conf
        sed -i "$ a Include conf/extra/httpd-vhosts.conf"                          ${Httpd_config_dir}/httpd.conf
        sed -i "s/User daemon/User apache/g"                                       ${Httpd_config_dir}/httpd.conf
        sed -i "s/Group daemon/Group apache/g"                                     ${Httpd_config_dir}/httpd.conf
        sed -i 's/DirectoryIndex index.html/DirectoryIndex index.php index.html/g' ${Httpd_config_dir}/httpd.conf
##############     Include conf/extra/httpd-vhosts.conf      ###################
        mkdir  -p  ${Httpd_config_dir}/extra
        mkdir  -p  ${Web_root_dir}
        mkdir  -p  ${Web_logs_dir}
        \cp   ${Httpd_config_dir}/extra/httpd-vhosts.conf  ${Httpd_config_dir}/extra/httpd-vhosts.conf.BAK
        echo ${Apache_version}  | grep  "2.4.*"  > /dev/null  2>&1
        if [ $? -eq 0 ] ;then
            #apache 2.4.X 版本的配置,版本2.2 和2.4 版本的配置文件有点区别
            cat  << EOF  >  ${Httpd_config_dir}/extra/httpd-vhosts.conf
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "${Web_root_dir}"
    ServerName  ${Server_ip}
    ErrorLog "${Web_logs_dir}/project_error.log"
    CustomLog "${Web_logs_dir}/project_access.log" combined
    DirectoryIndex index.php index.Html index.html
<Directory "${Web_root_dir}">
    Options  FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>
</VirtualHost>
EOF
        else
            ##apache 2.2.X 版本的配置        
            cat  << EOF  >  ${Httpd_config_dir}/extra/httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
        DocumentRoot "${Web_root_dir}"
        ServerName ${Server_ip}
        DirectoryIndex index.php index.Html index.html
        CustomLog "${Web_logs_dir}/project_access.log" common
        ErrorLog "${Web_logs_dir}/project_error.log"
        SetEnv APPLICATION_ENV development
        <Directory "${Web_root_dir}">
                Options -Indexes MultiViews FollowSymLinks
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>
EOF
        fi
        cat  << EOF >> ${Httpd_config_dir}/httpd.conf
<IfModule prefork.c>
StartServers         10
MinSpareServers      10
MaxSpareServers      30
MaxClients           1500
MaxRequestsPerChild  0
</IfModule>
EOF
########## 配置网站默认页以及连接数据库的状态信息 #################
        cat << EOF >  ${Web_root_dir}/index.html
<center><h1>Test ${Server_ip} : Apache-${Apache_version}</h1></center>
EOF
        cat << EOF >  ${Web_root_dir}/index.php
<?php
\$link = mysql_connect('localhost','root','123456');   
if (\$link)
    echo "Success...";
else
    echo "Failure...";
mysql_close(); 
phpinfo();
?>
EOF
#####################   正在启动apahce 服务  ###################
        echo -e "\033[34m 正在启动Apache Service \033[0m"
        sleep 2
        ${Http_install_dir}/bin/apachectl   -k   start   &&  ss  -ntl | grep  80
        if [ $? -eq 0 ]; then
            echo  -e  "\033[34m  Apache  Service  Started  Successed ! \033[0m"
        else
            echo  -e  "\033[34m  Apache  Service  Started   Failed ! \033[0m"
        fi
    else
        echo  -e  "\033[34m  Apache  make  install  abnormal ! \033[0m"
        exit 1
    fi
}

 

############################     MySQL 安装相关函数   ###################################

Mysql_install(){
    /usr/sbin/useradd  -s /sbin/nologin mysql
    mkdir -p ${Mysql_data_dir} ${Mysql_conf_dir}
    cd $Work_dir
    if [  -f $Mysql_install_dir ];then
        echo  -e "\033[34m  检查是否已经有安装过 Mysql 相同的安装目录 \033[0m"
    echo  -e "\033[34m  经过检查,已有Mysql服务安装,请注意。 \033[0m"
        exit 1 
    fi
    [ -f "mysql-${Mysql_version}.tar.gz" ] || wget https://downloads.mysql.com/archives/get/file/mysql-${Mysql_version}.tar.gz
    tar zxvf mysql-${Mysql_version}.tar.gz -C   $Work_dir/
    cd mysql-${Mysql_version}
    echo -e "\033[34m 开始安装编译 mysql . . . . . . \033[0m"
    sleep 2
###########    判断MySQL 的版本进行选择性的编译5.7的版本有一些区别   ########
    echo $Mysql_version  | grep  "5.7.*"  > /dev/null  2>&1
    if [ $? -eq 0 ];then
        [ -f "${Work_dir}/boost_1_59_0.tar.gz" ]  || wget  http://liquidtelecom.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz 
        tar zxvf ${Work_dir}/boost_1_59_0.tar.gz  -C  $Work_boost_dir
        /usr/bin/cmake -DCMAKE_INSTALL_PREFIX=${Mysql_install_dir}         \
                       -DMYSQL_UNIX_ADDR=${Mysql_socket_dir}/mysql.sock    \
                       -DSYSCONFDIR=${Mysql_conf_dir}                      \
                       -DDEFAULT_CHARSET=utf8                              \
                       -DDEFAULT_COLLATION=utf8_general_ci                 \
                       -DWITH_EXTRA_CHARSETS:STRING=all                    \
                       -DWITH_MYISAM_STORAGE_ENGINE=1                      \
                       -DWITH_INNOBASE_STORAGE_ENGINE=1                    \
                       -DWITH_MEMORY_STORAGE_ENGINE=1                      \
                       -DWITH_READLINE=1                                   \
                       -DENABLED_LOCAL_INFILE=1                            \
                       -DWITH_SSL=bundled                                  \
                       -DWITH_ZLIB=system                                  \
                       -Dwith-mysqld-ldflags=-all-static                   \
                       -Dwith-client-ldflags=-all-static                   \
                       -DMYSQL_DATADIR=${Mysql_data_dir}                   \
                       -DMYSQL_USER=mysql                                  \
                       -DMYSQL_TCP_PORT=$Mysql_port                        \
                       -DWITH_BOOST=${Work_boost_dir}/boost_1_59_0   
    else
        /usr/bin/cmake -DCMAKE_INSTALL_PREFIX=${Mysql_install_dir}         \
                       -DMYSQL_UNIX_ADDR=${Mysql_socket_dir}/mysql.sock    \
                       -DSYSCONFDIR=${Mysql_conf_dir}                      \
                       -DDEFAULT_CHARSET=utf8                              \
                       -DDEFAULT_COLLATION=utf8_general_ci                 \
                       -DWITH_EXTRA_CHARSETS:STRING=all                    \
                       -DWITH_MYISAM_STORAGE_ENGINE=1                      \
                       -DWITH_INNOBASE_STORAGE_ENGINE=1                    \
                       -DWITH_MEMORY_STORAGE_ENGINE=1                      \
                       -DWITH_READLINE=1                                   \
                       -DENABLED_LOCAL_INFILE=1                            \
                       -DWITH_SSL=bundled                                  \
                       -DWITH_ZLIB=system                                  \
                       -Dwith-mysqld-ldflags=-all-static                   \
                       -Dwith-client-ldflags=-all-static                   \
                       -DMYSQL_DATADIR=${Mysql_data_dir}                   \
                       -DMYSQL_USER=mysql                                  \
                       -DMYSQL_TCP_PORT=${Mysql_port}                   
    fi
    make  -j  ${CPUS}  &&  make install
    if [ $? -ne 0 ];then
        echo -e "\033[34m  MySQL Server Intall  Failed. . . . .  \033[0m"
    fi
##################### init database & start up  ###################
    chown -R   mysql.mysql ${Mysql_data_dir}
    cd     ${Mysql_install_dir}
    echo  ${Mysql_version}  | grep  "5.7.*"  > /dev/null  2>&1
    if [ $? -eq 0 ];then
        ${Mysql_install_dir}/bin/mysqld  --initialize-insecure  --user=mysql  --basedir=${Mysql_install_dir}  --datadir=${Mysql_data_dir}
        sleep 1
    else
        chmod  +x   scripts/mysql_install_db 
        scripts/mysql_install_db   --user=mysql    --datadir=${Mysql_data_dir}
        sleep 1
    fi
    if [ $?  -eq 0 ];then
        echo  -e "\033[34m  初始化 OK \033[0m"
    else
        echo  -e "\033[34m  初始化 down  \033[0m"
    fi
    #cp $Mycnf_sample  $Mysql_conf_dir/my.cnf
    cat  <<  EOF  >  ${Mysql_conf_dir}/my.cnf 
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
innodb_buffer_pool_size = 1024M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
log_bin = mysql-bin
max_binlog_size = 256M
default-storage-engine = InnoDB
character-set-server = utf8
# These are commonly set, remove the # and set as required.
basedir = ${Mysql_install_dir}
datadir = ${Mysql_data_dir}
port = ${Mysql_port}
server_id = ${Mysql_server_id}
socket = ${Mysql_socket_dir}/mysql.sock
#
#开启安全更新模式
#SQL_SAFE_UPDATES = 1
# per table  for ibdatafile
innodb-file-per-table=1
pid-file=${Mysql_data_dir}/mysql.pid

#binlog do db
#binlog-do-db    = atrip_db_blog
#binlog-do-db    = atrip_db_website
#binlog-ignore-db = mysql
#binlog-ignore-db = test

# add connecton  config by liuxg
max_heap_table_size = 64M
tmp_table_size = 64M
max_connections = 10000
max_connect_errors = 10000

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
EOF

    egrep -i "${Mysql_install_dir}/bin/mysqld_safe --defaults-file=${Mysql_conf_dir}/my.cnf --user=mysql &" /etc/rc.local > /dev/null 2>&1
    if [ $? -ne 0 ];then
        echo "${Mysql_install_dir}/bin/mysqld_safe --defaults-file=${Mysql_conf_dir}/my.cnf --user=mysql &" >> /etc/rc.local
    fi
    echo "You Can Startup MySQL Database According To  /etc/rc.local ..."

    echo -e "\e[1;33m  开始启动Mysql服务,以及查看版本信息\e[0m"
    ${Mysql_install_dir}/bin/mysqld_safe --defaults-file=${Mysql_conf_dir}/my.cnf --user=mysql &
    sleep 2
    ${Mysql_install_dir}/bin/mysql  -e "select @@version;"
    sleep 1
    ss -ntl | grep  ${Mysql_port}  > /dev/null  2>&1 
    if  [ $?  -eq   0  ] ;then
    echo    
    echo -e "\e[1;33m       +------------------------------------------+ \e[0m"
    echo -e "\e[1;33m      /|                                         /| \e[0m"
    echo -e "\e[1;33m     +------------------------------------------+ | \e[0m"
    echo -e "\e[1;33m     | |                                        | | \e[0m"
    echo -e "\e[1;33m     | +-- Wecome to use MySQL${Mysql_version}------------|-+ \e[0m"
    echo -e "\e[1;33m     |/                                         |/  \e[0m"
    echo -e "\e[1;33m     +___________Successful_____________________+   \e[0m"
    echo -e "\e[1;33m    /                                          /    \e[0m"
    echo -e "\e[1;33m   /            Perfect                       /     \e[0m"   
    echo -e "\e[1;33m  /__________________________________________/      \e[0m"
    exit 1
    else
    echo -e "\e[1;35m    +---------------------------------+        \e[0m"
    echo -e "\e[1;35m    |\          Failed                |\       \e[0m"
    echo -e "\e[1;35m    | +-------------------------------|-+      \e[0m"                           
    echo -e "\e[1;35m    | |                               | |      \e[0m"
    echo -e "\e[1;35m    +-|---I'm Sorry,Please Checking---+-|      \e[0m"
    echo -e "\e[1;35m     \|                                \|      \e[0m"
    echo -e "\e[1;35m      +---------------------------------+      \e[0m"
    echo -e "\e[1;35m       \                                 \     \e[0m"       
    echo -e "\e[1;35m        \       请重新执行脚本              \    \e[0m"
    echo -e "\e[1;35m         \                                 \   \e[0m"
    echo -e "\e[1;35m          +---------------------------------+  \e[0m"   
    exit 1
    fi    
}

 

#########################     Php 安装相关函数     ######################################

Qdbm_install(){
    cd  ${Work_dir}
    [ -f  qdbm-1.8.78.tar.gz ]  ||  wget http://fallabs.com/qdbm/qdbm-1.8.78.tar.gz
    tar  xf   qdbm-1.8.78.tar.gz
    cd   qdbm-1.8.78
    ./configure 
    make  -j  ${CPUS}   &&   make   install 
}

#此libmcrypt安装主要是考虑到后面会用到mcrypt模块,提前先安装上,如果需要安装mcrypt模块的话直接在php源码目录里装即可

Libmcrypt_install(){
    cd ${Work_dir}
    [ -f "libmcrypt-${Libmcrypt_version}.tar.gz" ] || wget https://jaist.dl.sourceforge.net/project/mcrypt/Libmcrypt/${Libmcrypt_version}/libmcrypt-${Libmcrypt_version}.tar.gz
    tar -zxvf libmcrypt-${Libmcrypt_version}.tar.gz
    cd libmcrypt-${Libmcrypt_version}
    ./configure
    make -j $CPUS && make install
    cd libltdl
    ./configure --with-gmetad --enable-gexec --enable-ltdl-install
    make -j $CPUS && make install
}

  Mhash_install(){
      cd ${Work_dir}
      [ -f "mhash-${Mhash_version}.tar.gz" ] || wget https://jaist.dl.sourceforge.net/project/mhash/mhash/${Mhash_version}/mhash-${Mhash_version}.tar.gz
      tar -zxvf mhash-${Mhash_version}.tar.gz
      cd mhash-${Mhash_version}
      ./configure
      make -j $CPUS && make install
  }

  Libiconv_install(){
      cd $Work_dir
      [ -f "libiconv-${Libiconv_version}.tar.gz" ] || wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-${Libiconv_version}.tar.gz
      tar -zxvf libiconv-${Libiconv_version}.tar.gz
      cd libiconv-${Libiconv_version}
      ./configure
      make -j $CPUS && make install
  }


Php_install(){ cd ${Work_dir} [ -f "php-${Php_version}.tar.gz" ] || wget http://am1.php.net/distributions/php-${Php_version}.tar.gz tar xvf php-${Php_version}.tar.gz cd php-${Php_version} echo -e "\033[34m 开始安装编译 php . . . . . . \033[0m" sleep 3 ./configure --prefix=${Php_install_dir} --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-apxs2=${Http_install_dir}/bin/apxs \ --with-config-file-path=${Php_install_dir}/etc --enable-pic --disable-static --enable-mbstring --enable-inline-optimization \ --with-regex=system --with-gettext --with-gd --with-png --with-zlib --enable-debugger --disable-debug --enable-magic-quotes \ --enable-safe-mode --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-track-vars --enable-yp --enable-ftp --with-xml \ --with-freetype-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --with-ttf --with-ncurses --with-gmp --with-iconv \ --with-jpeg-dir=/usr --with-expat-dir=/usr --enable-bcmath --enable-exif --enable-sockets --enable-discard-path --enable-wddx \ --enable-trans-sid --enable-wddx --enable-versioning --enable-calendar --enable-dbx --enable-dio --enable-mcal --enable-shmop \ --with-curl --with-openssl --with-qdbm --enable-fpm --enable-fastcgi if [ $? -eq 0 ];then echo -e "\e[1;33m +++++++++++++++++++++ \e[0m" echo -e "\e[1;33m \ make 开始编译 \ \e[0m" echo -e "\e[1;33m +++++++++++++++++++++ \e[0m" sleep 3 make -j ${CPUS} #make -j ${CPUS} ZEND_EXTRA_LIBS='-liconv' echo -e "\e[1;33m +++++++++++++++++++++++++ \e[0m" echo -e "\e[1;33m \make install 开始编译 \ \e[0m" echo -e "\e[1;33m ++++++++++++++++++++++++ \e[0m" sleep 3 make install if [ $? -eq 0 ];then echo -e "\033[34m PHP Install Successed ! \033[0m" cp php.ini-production ${Php_config_dir}/php.ini echo "data.timezone = Asia/Shanghai" >> ${Php_config_dir}/php.ini echo ";date.timezone=PRC" >> ${Php_config_dir}/php.ini sed -i 's/upload_max_filesize = 2M/ upload_max_filesize = 50M/g' ${Php_config_dir}/php.ini sed -i 's/display_errors = Off/display_errors = On/g' ${Php_config_dir}/php.ini echo -e "\033[34m php.ini config complete !!! \033[0m" mkdir -p ${Web_root_dir} ${Web_logs_dir} #lamp环境编译php时,主要进行的配置 echo "AddType application/x-httpd-php .php" >> ${Httpd_config_dir}/httpd.conf echo "AddType application/x-httpd-php-source .phps" >> ${Httpd_config_dir}/httpd.conf echo -e "\033[34m php modules append to httpd.conf complete!!! \033[0m" echo -e "\033[34m 重启动 apache 服务\033[0m" ${Http_install_dir}/bin/apachectl restart sleep 3 egrep -i "export PHPRC=${Php_config_dir}/php.ini " /etc/profile > /dev/null 2>&1 if [ $? -ne 0 ] ;then echo "export PHPRC=${Php_config_dir}/php.ini " >> /etc/profile fi source /etc/profile else echo -e "\033[34m PHP Install Failed ! \033[0m" exit 1 fi else echo -e "\033[34m Congfigure Install Php Abnormal \033[0m" exit 1 fi }

###################################################################################
############################# 脚本主程序内容 #########################################

while [ 1 ]
do
echo
All_path_1
echo -e "\t\t\tSys Admin Menu\n"
echo -e "\t  1. Install Apache:   ${Apache_version}\n"
echo -e "\t  2. Install Mysql:    ${Mysql_version}\n"
echo -e "\t  3. Install Php:      ${Php_version}\n"
read -n 1 -p "Please Input  Numbers : " NUM  
case $NUM in
    1)
    echo  -e "\033[34m  安装配置 Apache 环境 ............... \033[0m"
    sleep 2
    depend_pkg;
    All_path_1;
    All_path_2;
    Apr_install;
    Apr_util_install;
    Apache_install;
    ;;
    2)
    echo  -e "\033[34m  安装配置 MySQL 环境 ............... \033[0m"
    sleep 2
    depend_pkg;
    All_path_1;
    All_path_2;
    Mysql_install;
    ;;
    3)
    echo  -e "\033[34m  安装配置 Php 环境 ............... \033[0m"
    sleep 2
    depend_pkg;
    All_path_1;
    All_path_2;
    Qdbm_install;
Libmcrypt_install;
Mhash_install;
Libiconv_install;
Php_install;
;;
*)
clear
echo -e "\033[34m Please Input [ 1 | 2 | 3 ] \033[0m"
esac
echo -en "\n\n\t\t\t 任意键继续"
read -n 1 line
done