一、安装Memcached(为了让下面配置完客户端验证,这个1.5.1版本不能做主主复制,支持复制功能的 Memcached 安装包是1.2.8版本。)
步骤:
yum -y install gcc*
tar zxf libevent-2.1.8-stable.tar.gz -C /usr/src/
cd /usr/src/libevent-2.1.8-stable/
./configure --prefix=/usr/local/libevent
make && make install
tar zxf memcached-1.5.1.tar.gz -C /usr/src/
cd /usr/src/memcached-1.5.1/
./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent
make && make install
配置Memcached 管理脚本:
# vim /usr/local/memcached/memcached_service.sh
#!/bin/bash
CMD="/usr/local/memcached/bin/memcached"
start(){
$CMD -d -m 128 -u root
}
stop(){
killall memcached;
}
ACTION=$1
case $ACTION in
'start')
start;;
'stop')
stop;;
'restart')
stop
sleep 2
start;;
*)
echo 'Usage:{start|stop|restart}'
esac
修改权限,执行脚本
chmod 755 /usr/local/memcached/memcached_service.sh
/usr/local/memcached/memcached_service.sh start
netstat -naptl |grep memcached
二、配置Memcached API 客户端
前提环境:lamp
快速搭建lamp两种方法:
1.脚本
配置阿里云源:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
vim lamp.sh
添加以下内容:
#!/bin/bash
#使用说明:chmod +x lamp.sh 授权脚本
#by:清
yum -y install httpd httpd-devel
systemctl start httpd
systemctl enable httpd
systemctl status httpd
netstat -anpt|grep 80
echo "apache安装完毕"
yum -y install mariadb mariadb-server mariadb-libs mariadb-devel
systemctl start mariadb
systemctl enable mariadb
netstat -anpt|grep 3306
echo mysql安装完毕
yum -y install php
rpm -ql php
echo php与mysql关联
yum -y install php-mysql
yum -y install php-devel
rpm -ql php-mysql
yum install -y php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel php-bcmath
echo "
phpinfo();
?>" > /var/www/html/index.php
echo 结束,浏览器访问本机IP/index.php
systemctl restart httpd