威尼斯wns.9778官网活动_vnsc威尼斯城官网

热门关键词: 威尼斯wns.9778官网活动,vnsc威尼斯城官网
当前位置:威尼斯wns.9778官网活动 > 计算机教程 > shell 脚本安装PHP扩展的简单方法

shell 脚本安装PHP扩展的简单方法

文章作者:计算机教程 上传时间:2019-05-11

实例如下:

本文实例为大家分享了mysql5.6.29的shell脚本,供大家参考,具体内容如下

#!/bin/bash
#This script is to install PHP extensions
#Author=steven
#Email=775189187@qq.com
#WriteTime=Sun Aug 14 23:32:18 CST 2016




#The environment variable
Extension_HOME=/usr/local/src/php-5.6.16/ext/mysql
PHP_HOME=/usr/local/webserver/php
Extension_Install=mysql.so


#Enter the extension directory
cd $Extension_HOME
#Some of the set about PHP plugin modules
$PHP_HOME/bin/phpize
#Target characteristics of the test installation platform
$Extension_HOME/configure --with-php-config=$PHP_HOME/bin/php-config
#compile
make
#install
make install
#php.ini file insert the extension=$Extension_Install
if grep -Fxq "extension=$Extension_Install" $PHP_HOME/etc/php.ini
 then
    echo "extension=$Extension_Install exist "
 else
    echo -e "n[mysql]nextension=$Extension_Install" >> $PHP_HOME/etc/php.ini
fi
#restart php-fpm process
kill -SIGUSR2 `cat $PHP_HOME/var/run/php-fpm.pid`

创建脚本mysql.sh,直接运行sh mysql.sh

以上这篇shell 脚本安装PHP扩展的简单方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

#!/bin/bash
if [ -d /software ] ;then
  cd /software
else
  mkdir /software && cd /software
fi

#is exist command ,if not,yum install
is_exist() {
  which $1
  if [ $? -ne 0 ] ;then
     yum -y install $1
  fi
}

#dolownad the mysql install package,if exist,check the md5sum,if correct,tar;else rm and download
if [ -f mysql-5.6.29.tar.gz ] ;then
  mysql_md5=`md5sum mysql-5.6.29.tar.gz | cut -d " " -f 1 `
  mysql_md5_true="aaa21c6450adee3a1894fd1710f02bf5"
  if [ "$mysql_md5" = "$mysql_md5_true" ] ;then
    tar -zxvf mysql-5.6.29.tar.gz
  else
    rm -rf mysql-5.6.29.tar.gz
    rm -rf mysql-5.6.29
  fi
else
  is_exist wget
  wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.29.tar.gz
  tar -zxvf mysql-5.6.29.tar.gz
fi

#see the yum source is use
yum cleanup
yum makecache

#install the depend package
yum -y install gcc make cmake ncurses-devel libxml2-devel libtool-ltdl-devel gcc-c   autoconf automake bison zlib-devel

#add mysql group and user
is_user_mysql=`cat /etc/passwd |awk -F ":" '{print $1}' |grep mysql`
is_group_mysql=`cat /etc/group |awk -F ":" '{print $1}' |grep mysql`

if [ "$is_group_mysql" != "mysql" ] ;then
  groupadd mysql
fi
if [ "$is_user_mysql" != "mysql" ] ;then
   useradd -r -s /sbin/nologin -g mysql mysql
fi

#compile and install
cd mysql-5.6.29
cmake .
make && make install

chown -R mysql.mysql /usr/local/mysql

#init database
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data

#copy the important file to /etc
#cp /usr/local/mysql/my.cnf /etc/my.cnf

sed -i 's/# basedir = ...../basedir = /usr/local/mysql/g' /usr/local/mysql/my.cnf
sed -i 's/# port = ...../port = 3306/g' /usr/local/mysql/my.cnf
sed -i 's/# datadir = ...../datadir = /usr/local/mysql/data/g' /usr/local/mysql/my.cnf
sed -i '/[mysqld]/alog-error=/usr/local/mysql/log/error.log' /usr/local/mysql/my.cnf
#sed -i '/[mysqld]/alog=/usr/local/mysql/log/log' /usr/local/mysql/my.cnf
#sed -i '/[mysqld]/alog-slow-queries=/usr/local/mysql/log/slowquery.log' /usr/local/mysql/my.cnf
sed -i '/[mysqld]/along_query_time=2' /usr/local/mysql/my.cnf
sed -i '/[mysqld]/apid-file=/usr/local/mysql/data/mysql.pid' /usr/local/mysql/my.cnf
sed -i '/[mysqld]/acharacter-set-server=utf8' /usr/local/mysql/my.cnf

echo "[client] " >> /usr/local/mysql/my.cnf
echo "socket = /var/lib/mysql/mysql.sock" >>/usr/local/mysql/my.cnf

/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
#use database
/usr/local/mysql/bin/mysqld_safe --user=mysql &

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on

`ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock`
#start the service
service mysqld restart

#import environment
PATH=$PATH:/usr/local/mysql/bin
echo "export PATH=$PATH:/usr/local/mysql/bin >> /etc/profile"
source /etc/profile

本文由威尼斯wns.9778官网活动发布于计算机教程,转载请注明出处:shell 脚本安装PHP扩展的简单方法

关键词: