该脚本基于阿里云服务器安装脚本,并只能运用于centos / aliyun os,该脚本使用时,需要与阿里云安装脚本的install.sh放在同一目录下。有缘人切忌乱用:

 #! /bin/bash
#by dxd in -
#only suit for centos/aliyun os, and based on aliyun install script PHP_EXT_SOURCE_PATH=""
PHP_BIN_PATH=/alidata/server/php/bin DOWNLOAD_LIBEVENT_URL=http://download.verymall.cn/libevent-1.4.14b.tar.gz
INSTALL_LIBEVENT_PATH=/alidata/lib/libevent
NEW_LIBEVENT="" DOWNLOAD_MEMCACHE_URL=http://download.verymall.cn/memcached-1.4.25.zip
INSTALL_MEMCACHE_PATH=/alidata/server/memcache
MEMCACHE_PORT=
MEMCACHE_PID_FILE=/tmp/memcached.pid CURR_PATH=$(pwd); DOWNLOAD_LIBMEMCACHED_URL=http://download.verymall.cn/libmemcached-1.0.18.zip
INSTALL_LIBMEMCACHED_PATH=/alidata/lib/libmemcached DOWNLOAD_PHP_MEMCACHED=http://download.verymall.cn/php_memcached-2.2.0.zip
PHP_INI_PATH=/alidata/server/php/etc/php.ini #check current path auth
if [ ! -w "$CURR_PATH" ]
then
echo "no write"
exit
fi #check user name
if [ "$(whoami)" != "root" ]
then
echo "please run as root"
exit
fi #check current path
if [ "$(ls | grep 'install.sh')" = "" ]
then
echo "please put this script where install.sh locates"
exit
fi #select php ext path
for dir in $(ls)
do
TMP_PATH=$CURR_PATH/$dir/ext
if [ -d $TMP_PATH ]
then
PHP_EXT_SOURCE_PATH=$TMP_PATH
break
fi
done
if [ -z "$PHP_EXT_SOURCE_PATH" ]
then
echo "could not find php install path"
exit
fi echo -n "php ext source path is $PHP_EXT_SOURCE_PATH , (Y/N): "
read USER_ANSWER
until [ "$USER_ANSWER" = "Y" ] || [ "$USER_ANSWER" = "y" ]
do
if [ "$USER_ANSWER" = "N" ] || [ "$USER_ANSWER" = "n" ]
then
echo "php ext source path is fault, then exit"
exit
fi echo -n "php ext source path is $PHP_EXT_SOURCE_PATH , (Y/N): "
read USER_ANSWER
done #maybe gcc is not installed,but it is rare, I'm not going to handle this situation
which gcc > /dev/null >&
if [ "$?" != "" ]
then
echo "please install gcc first"
exit
fi #check is port occupied
if [ -n "$(netstat -ano | grep $MEMCACHE_PORT)" ]
then
echo "PORT $MEMCACHE_PORT is occupied, please check"
if [ -f $MEMCACHE_PID_FILE ]
then
echo 'maybe by old memcache server'
echo "PID: $(cat $MEMCACHE_PID_FILE)"
fi
exit
fi #test zip if exist
unzip > /dev/null >&
if [ "$?" != "" ] #not tested yet!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
then
yum install unzip
fi #clear old memcache files
if [ -d $INSTALL_MEMCACHE_PATH ]
then
rm -rf $INSTALL_MEMCACHE_PATH > /dev/null >&
if "$?"=""
then
echo "$INSTALL_MEMCACHE_PATH could not be removed"
exit
fi
fi if [ -d $INSTALL_LIBMEMCACHED_PATH ]
then
rm -rf $INSTALL_LIBMEMCACHED_PATH > /dev/null >&
if "$?"=""
then
echo "$INSTALL_LIBMEMCACHED_PATH could not be removed"
exit
fi
fi #create lib path
mkdir /alidata/lib > /dev/null >& #install libevent
libevent=$(ldconfig -p | grep 'libevent')
if [ -z "$libevent" ] #not tested yet!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
then
rm -rf $INSTALL_LIBEVENT_PATH > /dev/null >&
mkdir $INSTALL_LIBEVENT_PATH
chmod -R $INSTALL_LIBEVENT_PATH rm -f $CURR_PATH/libevent-1.4.14b.tar.gz
rm -rf $CURR_PATH/libevent-1.4.14b
wget $DOWNLOAD_LIBEVENT_URL
tar -zxvf libevent-1.4.14b.tar.gz
chmod -R ./libevent-1.4.14b
cd ./libevent-1.4.14b
./configure --prefix=$INSTALL_LIBEVENT_PATH
make
make install NEW_LIBEVENT=""
fi cd $CURR_PATH #install memcache
rm -f $CURR_PATH/memcached-1.4..zip
rm -rf $CURR_PATH/memcached-1.4.
wget $DOWNLOAD_MEMCACHE_URL
unzip memcached-1.4..zip
chmod -R ./memcached-1.4.
cd ./memcached-1.4.
if [ $NEW_LIBEVENT="" ] #install libevent in this script
then
./configure --prefix=$INSTALL_MEMCACHE_PATH --with-libevent=$INSTALL_LIBEVENT_PATH
else
./configure --prefix=$INSTALL_MEMCACHE_PATH
fi
make
make install #start memcache
rm -f /tmp/memcached.pid
$INSTALL_MEMCACHE_PATH/bin/memcached -d -m -u root -p $MEMCACHE_PORT -c -P $MEMCACHE_PID_FILE cd $CURR_PATH #install libmemcached
rm -f $CURR_PATH/libmemcached-1.0..zip
rm -rf $CURR_PATH/libmemcached-1.0.
wget $DOWNLOAD_LIBMEMCACHED_URL
unzip libmemcached-1.0..zip
chmod -R ./libmemcached-1.0.
cd ./libmemcached-1.0.
mkdir $INSTALL_LIBMEMCACHED_PATH
chmod -R $INSTALL_LIBMEMCACHED_PATH
./configure --prefix=$INSTALL_LIBMEMCACHED_PATH --with-memcached
make
make install cd $CURR_PATH #install php extension Memcached
rm -f $CURR_PATH/php_memcached-2.2..zip
rm -rf $CURR_PATH/memcached-2.2.
rm -rf $PHP_EXT_SOURCE_PATH/memcached-2.2.
wget $DOWNLOAD_PHP_MEMCACHED
unzip php_memcached-2.2..zip
chmod -R ./memcached-2.2.
mv $CURR_PATH/memcached-2.2. $PHP_EXT_SOURCE_PATH/memcached-2.2.
cd $PHP_EXT_SOURCE_PATH/memcached-2.2.
$PHP_BIN_PATH/phpize
./configure --enable-memcached --with-php-config=$PHP_BIN_PATH/php-config --with-libmemcached-dir=$INSTALL_LIBMEMCACHED_PATH --disable-memcached-sasl
make
make install #write php.ini
memcached_exist=$(cat $PHP_INI_PATH | grep 'memcached.so')
if [ -z "$memcached_exist" ]
then
echo "extension=memcached.so" >> $PHP_INI_PATH
fi cd $CURR_PATH #restart php fpm
/etc/init.d/php-fpm restart echo "install successfully"
exit

自动安装memcached服务端与PHP扩展Memcached的更多相关文章

  1. 自动安装Redis服务端与PHP扩展Redis

    该脚本基于阿里云服务器安装脚本,并只能运用于centos / aliyun os,该脚本使用时,需要与阿里云安装脚本的install.sh放在同一目录下.有缘人切忌乱用: #! /bin/bash # ...

  2. 编译安装rabbitmq服务端

    有一种方式是:下载rabbitmq-server-generic-unix压缩包,是不用编译的.是已经编译好的源码了 下面介绍编译源码安装   总括: 需要以下步骤:   1.安装erlange.因为 ...

  3. Windows安装VNC服务端

    下载VNC服务端 由于服务器在IDC机房,只能使用系统自带远程桌面连接到服务器进行安装VPC服务端 但在安装过程发现,如果是通过远程桌面连接到服务器进行安装,VNC Mirror Driver会报错无 ...

  4. 多个Linux发行版安装ss服务端

    本文仅做技术探讨,请在遵守相应的法律法规的前提下使用. Centos 7一键安装脚本 简单快捷,随机生成密码,默认端口默认加密类型 bash <(curl -s http://morning.w ...

  5. Memcached服务端自动启动(转载)

    Memcached服务端自动启动 原文链接:http://www.cnblogs.com/technet/archive/2011/09/11/2173485.html  经测试,要使得Memcach ...

  6. suse安装svn服务端和客户端的使用

    suse安装svn服务端 一. 安装服务端 配置网络安装源(suse11sp1为例) 新建11.1.repo11.1为软件源名称,可自定义文件并添加如下内容后保存 linux-e0xg:/etc/zy ...

  7. centos 7安装vnc服务端&vnc客户端连接

    前言 工作需求,需要用到vnc,介绍一下相关内容. 安装vnc服务端 在执行其他相关的之前,需要先安装一下vnc的服务端,命令如下: yum install tigervnc-server 配置vnc ...

  8. 安装oracle服务端之后再安装oracle客户端导致sqlplus命令无法使用??

    首先小编自述一下所遇到的问题: 昨天在已经安装 oracle 服务端的 win7 X64 主机上安装 oracle client 之后,发现我的sqlplus命令无法用了??经过百度,都说我服务没有开 ...

  9. CentOS 7.4安装telnet服务端

    CentOS 7.4安装telnet服务端 安装xinetd服务 # yum -y install xinetd 安装telnet-server # yum -y install telnet-ser ...

随机推荐

  1. C语言实现修改文本文件中的特定行

         最近由于项目需要实现修改文件的功能,所以,博主认真查阅了一些资料,但是,很遗憾,并没有太多的收获. 好的,首先我先叙述下功能要求: 其实很简单,就是Shell中sed命令的C语言实现,实现定 ...

  2. Linux文件系统十问,你知道吗?

    关于文件系统,相信大家都不陌生.身为攻城狮的我们几乎天天都会与之打交道,但是细深剖一下,其中又有多少是我们理解深度不够的呢.那么让我们一起来看一下下面这一组Linux文件系统相关的问题吧: 1.机械磁 ...

  3. ssi-uploader上传图片插件,点击选择文件按钮自动提交表单解决办法

    先介绍一下这款插件,然后再谈使用中可能遇到的问题 ssi-uploader是一个JQuery的图片上传插件,界面比较美观 github地址:https://github.com/ssbeefeater ...

  4. PHP关于foreach使用引用变量的坑

    写PHP好多年,但仍然会犯低级错误,今天遇到个 foreach中引用变量时的坑,PHP版本为 5.6.12 代码如下: <?php $arr = ['a', 'b', 'c', 'd', 'e' ...

  5. mysql数据恢复问题

    现象 mysql> drop database zabbix; Query OK, 104 rows affected (0.30 sec)mysql> exitBye[root@mysq ...

  6. windows下运行hadoop2.7.2

    1.下载hadoop-2.7.2.tar.gz 2.解压到D:\hadoop\ 3.配置HADOOP_HOME环境变量 4.将%HADOOP_HOME%\bin目录添加到path环境变量中 5.配置J ...

  7. R和python连接SQL sever 数据库操作

    在R的使用中,为了方便提取数据, 我们经常要进行数据库进行操作,接下来我们尝试使用R进行连接数据. 这里我们使用R中的RODBC进行操作, 首先,我们需要先配置ODBC资源管理器 通过任务管理器或者w ...

  8. 自定义Dialog,从下面弹出

    Window window= getWindow(); 只要 打开一个Activity 就有一个窗口存放这个Activity ,手机又很多个窗口,不只是一个窗口 import android.app. ...

  9. Fiddler的安装设置

    一.安装设置Fiddler2  下载完成后安装,安装完成后打开 如下图设置Fiddler 代理: 二.设置手机代理 快捷键win+r打开运行窗口à输入:cmdà确定 在界面上输入:ipconfig,查 ...

  10. UNIX基础--Manual Pages

    联机手册 Manual Pages 最详细的使用说明文档莫过于 FreeBSD 里的联机手册了. 几乎每一个程序都会附上一份简短说明, 以介绍这个程序的的基本功能以及参数的用法. 我们能通过 man ...