简体   繁体   English

如何在 xampp ubuntu 中安装 php-memcache?

[英]How to install php-memcache in xampp ubuntu?

I have installed xampp for linux from https://www.apachefriends.org/index.html in my Ubuntu 22.04 OS我在我的Ubuntu 22.04操作系统中从https://www.apachefriends.org/index.html安装了 xampp for linux

After successfully installed, my project is running fine but when I install the php-memchached in my system with the below command but it is not showing in my phpinfo() page.成功安装后,我的项目运行良好,但是当我使用以下命令在我的系统中安装 php-memchached 时,它没有显示在我的 phpinfo() 页面中。

Command:命令:

sudo apt-get install -y php-memcached

Also I tried with the code to check my Memcached Successfully installed or not.我还尝试使用代码来检查我的 Memcached 是否已成功安装。 But I got the error message that Class 'Memcached' not found但是我收到错误消息,指出Class 'Memcached' not found

Code:代码:

$memcached = new Memcached();
$memcached->addServer("127.0.0.1", 8080);
$response = $memcached->get("sample_key");

if($response==true) {
    echo $response;
} else {
    echo "Cache is empty";
    $memcached->set("sample_key", "Sample data from cache") ;
}

Error Output in Yii console: Yii 控制台错误输出:

Class 'Memcached' not found

Please let me know how to install the php-memcached in Xappp for my ubuntu system?请让我知道如何在 Xappp 中为我的 ubuntu 系统安装 php-memcached?

php-memcached extension uses the libmemcached library to provide an API for communicating with memcached servers. php-memcached扩展使用libmemcached库提供 API 用于与 memcached 服务器通信。

So, This extension requires libmemcached client library .所以,这个扩展需要libmemcached 客户端库

The steps in outline:大纲中的步骤:

sudo apt-get update
sudo apt-get install -y memcached
sudo apt-get install -y php-memcached
sudo systemctl restart memcached
sudo /opt/lampp/lampp restart

Don't forget to check extension=memcached.so in the php.ini, and path to extension dir...as shingo points out in his commentary不要忘记检查 php.ini 中的 extension=memcached.so 以及扩展目录的路径......正如 shingo 在他的评论中指出的那样

References for more details:更多细节参考:

https://www.php.net/manual/en/book.memcached.php https://www.php.net/manual/en/book.memcached.php

https://www.alibabacloud.com/blog/how-to-set-up-memcached-with-php-on-ubuntu-18-04_595628 https://www.alibabacloud.com/blog/how-to-set-up-memcached-with-php-on-ubuntu-18-04_595628

Steps for installing php-memcached in ubuntu在ubuntu中安装php-memcached的步骤

first, go to the /opt/lampp/bin/ then run the below command首先,转到 /opt/lampp/bin/ 然后运行以下命令

> sudo pecl install Memcached

OR要么

> /opt/lampp/bin/pecl install memcached

Once installed then open php.ini(my ini path /opt/lampp/etc/php.ini ) and add the below line in that file安装后打开 php.ini(我的 ini 路径/opt/lampp/etc/php.ini )并在该文件中添加以下行

extension=memcached.so

Finally, restart XAMPP最后,重启 XAMPP

> sudo /opt/lampp/lampp restart

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM