Skip to content

Instantly share code, notes, and snippets.

@yungke
Created April 17, 2015 05:11
Show Gist options
  • Save yungke/488815e78e238e9d7c1d to your computer and use it in GitHub Desktop.
Save yungke/488815e78e238e9d7c1d to your computer and use it in GitHub Desktop.
LNMP 1.1 php 5.23 環境 memcaches 升級腳本
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
# Check if user is root
if [ $(id -u) != "0" ]; then
echo "Error: You must be root to run this script, please use root to install lnmp"
exit 1
fi
clear
printf "=======================================================================\n"
printf "Install Memcached for LNMP V0.9 , Written by Licess \n"
printf "=======================================================================\n"
printf "LNMP is a tool to auto-compile & install Nginx+MySQL+PHP on Linux \n"
printf "This script is a tool to install memcached for lnmp \n"
printf "\n"
printf "For more information please visit http://www.lnmp.org \n"
printf "======================================================= 2014.09.02 ====\n"
cur_dir=$(pwd)
get_char()
{
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
echo ""
echo "Press any key to start install Memcached 1.4.22 ..."
char=`get_char`
printf "=========================== install memcached ======================\n"
if [ -s /usr/local/autoconf-2.69 ]; then
echo "autoconf-2.69 [found]"
else
if [ -s autoconf-2.69.tar.gz ]; then
echo "autoconf-2.69.tar.gz [found]"
else
echo "Error: autoconf-2.69.tar.gz not found!!!download now......"
wget -c http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
fi
rm -rf autoconf-2.69
tar zxvf autoconf-2.69.tar.gz
cd autoconf-2.69/
./configure --prefix=/usr/local/autoconf-2.69
make && make install
cd ../
fi
if [ -s memcache-3.0.8.tgz ]; then
echo "memcache-3.0.8.tgz [found]"
else
echo "Error: memcache-3.0.8.tgz not found!!!download now......"
wget -c http://soft.vpser.net/web/memcache/memcache-3.0.8.tgz
fi
rm -rf memcache-3.0.8
tar zxvf memcache-3.0.8.tgz
cd memcache-3.0.8/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
cd ../
if [ -s /usr/local/libevent/lib/libevent-2.1.so.4 ]; then
echo "libevent-2.1.4 [found]"
else
if [ -s libevent-2.1.4-alpha.tar.gz ]; then
echo "libevent-2.1.4-alpha.tar.gz [found]"
else
echo "Error: libevent-2.1.4-alpha.tar.gz not found!!!download now......"
wget -c http://jaist.dl.sourceforge.net/project/levent/libevent/libevent-2.1/libevent-2.1.4-alpha.tar.gz
fi
tar zxvf libevent-2.1.4-alpha.tar.gz
cd libevent-2.1.4-alpha/
./configure --prefix=/usr/local/libevent
make&& make install
cd ../
echo "/usr/local/libevent/lib/" >> /etc/ld.so.conf
ln -s /usr/local/libevent/lib/libevent-2.1.so.4 /lib/libevent-2.1.so.4
ldconfig
fi
if [ -s memcached-1.4.22.tar.gz ]; then
echo "memcached-1.4.22.tar.gz [found]"
else
echo "Error: memcached-1.4.22.tar.gz not found!!!download now......"
wget -c http://www.memcached.org/files/memcached-1.4.22.tar.gz
fi
rm -rf memcached-1.4.22
tar zxvf memcached-1.4.22.tar.gz
cd memcached-1.4.22/
./configure --prefix=/usr/local/memcached
make &&make install
cd ../
rm /usr/bin/memcached
ln /usr/local/memcached/bin/memcached /usr/bin/memcached
cp conf/memcached-init /etc/init.d/memcached
chmod +x /etc/init.d/memcached
useradd -s /sbin/nologin nobody
if [ -s /etc/debian_version ]; then
update-rc.d -f memcached defaults
elif [ -s /etc/redhat-release ]; then
chkconfig --level 345 memcached on
fi
echo "Copy Memcached PHP Test file..."
cp conf/memcached.php /vhost/default/memcached.php
echo "Starting Memcached..."
/etc/init.d/memcached start
sed -i '/extension = "memcache.so"/d' /opt/atphp/lib/php.ini
sed -i '/; http:\/\/php.net\/extension-dir/a extension = "memcache.so"' /opt/atphp/lib/php.ini
echo "Restarting php-fpm......"
/etc/init.d/php-fpm restart
printf "===================== install Memcached completed =====================\n"
printf "Install Memcached completed,enjoy it!\n"
printf "You Can visit Memcached PHP Test file: http://ip/memcached.php\n"
printf "=======================================================================\n"
printf "Install Memcached for LNMP V0.9 , Written by Licess \n"
printf "=======================================================================\n"
printf "LNMP is a tool to auto-compile & install Nginx+MySQL+PHP on Linux \n"
printf "This script is a tool to install Memcached for lnmp \n"
printf "\n"
printf "For more information please visit http://www.lnmp.org \n"
printf "======================================================= 2014.09.02 ====\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment