要求:php源码包已经上传至/opt/php目录下面,写一个脚本一键部署
[root@localhost ~]# cat auto_install_php.sh#!/bin/bashPHP_P=\"/opt/php/\"PHP_T=\"/usr/local/php/\"MYSQL_BASE=`cat /etc/my.cnf|grep basedir|awk -F \'=\' \'{print $2}\'`APACHE_APXS=`find / -name \"apxs\"|grep bin`function install_php(){chmod 755 ${PHP_P}*rm -rf ${PHP_T}mkdir -p ${PHP_T}tar -zxvf ${PHP_P}`ls ${PHP_P}|grep php` -C ${PHP_T} >/dev/nullcd ${MYSQL_BASE}cd libLIBMYSQLCLIENT=`ls | grep libmysqlclient.so|sort|sed -n \'1p\'`rm -rf libmysqlclient_r.so >/dev/nullln -s ${LIBMYSQLCLIENT} libmysqlclient_r.so >/dev/nullcd ${PHP_T}`ls ${PHP_T}`echo \"开始预编译\"my=`echo ${MYSQL_BASE}`./configure \\--prefix=${PHP_T} \\--with-mysql=${my} \\--with-apxs2=${APACHE_APXS} \\--with-config-file-path=${PHP_T}if [ $? -eq 0 ]; thenecho \"php预编译成功\"sleep 5echo \"开始编译安装\"declare -i n=`cat /proc/cpuinfo| grep \"physical id\"|sort|wc -l`make -j ${n}make installfind / -name \"*httpd.exp*\"|grep modulesif [ $? -eq 0 ]; thenfind / -name \"*libphp5.so*\"|grep modulesif [ $? -eq 0 ]; thenecho \"\"echo -e \"\\033[47;34m 请在`pwd`路径下执行上方提示的内容\\033[0m\"echo \"\"else echo \"安装不完全,请检查错误\"fielseecho \"安装不完全,请检查错误\"fielseecho \"php预编译失败\"fi}install_php[root@localhost ~]#