centos系统为php安装memcached扩展
1. 通过yum安装
yum -y install memcached
#安装完成后执行:
memcached -h
#出现memcached帮助信息说明安装成功
2. 加入启动服务
chkconfig --level 2345 memcached on
3. 配置Memcached
vim /etc/sysconfig/memcached
#文件中内容如下,按需要修改:
PORT="11211" #端口
USER="root" #用户名
MAXCONN="1024" #最大连接数
CACHESIZE="64" #内存大小
OPTIONS="" #附加参数
4. 安装libmemached
wget https://launchpad.net/libmemcached/1.0/1.0.16/+download/libmemcached-1.0.16.tar.gz
tar -zxvf libmemcached-1.0.16.tar.gz
cd libmemcached-1.0.16
./configure -prefix=/usr/local/libmemcached -with-memcached
make && make install
报错:g++: command not found的解决
yum -y install gcc+ gcc-c++
make clean后,重新执行:make && make install
5. 安装php-devel
yum install php-devel
6. 安装PHP Memcached扩展
wget http://pecl.php.net/get/memcached-2.1.0.tgz
tar -zxvf memcached-2.1.0.tgz
cd memcached-2.1.0
/usr/local/php/bin/phpize
./configure -enable-memcached -with-php-config=/usr/local/php/bin/php-config -with-zlib-dir -with-libmemcached-dir=/usr/local/libmemcached -prefix=/usr/local/phpmemcached
make && make install
报错:memcache support requires ZLIB解决办法
yum install zlib-devel
记录下安装成功后的提示,类似于:
Installing shared extensions: /usr/lib/php/modules/
7.增加扩展extension配置文件
vi /etc/php.d/memcached.ini
增加1行
extension=memcached.so
最后验证一下是否安装完成
php -m|grep memcached
应该会显示memcached
8.重启nginx/amapche,重启php-fpm,使用phpinfo()查看memcached模块是否安装成功。
memcached能启动但无法用php连接的问题(浏览器打开包含memcached的页面,firebug报500错误)
1.SELINUX=enforcing 改为 SELINUX=disabled
2.在终端尝试使用:telnet localhost 11211或者telnet 127.0.0.1 11211来连接到memcached的服务器
如果提示bash: telnet: command not found
执行:yum install telnet -y,再次回到浏览器尝试打开。
测试脚本:
<?php $m = new Memcached;$m->addServer('127.0.0.1', 11211);$m->set('foo', 200);var_dump($m->get('foo'));?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c
