I have installed xampp for linux from https://www.apachefriends.org/index.html in my Ubuntu 22.04 OS
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.
Command:
sudo apt-get install -y php-memcached
Also I tried with the code to check my Memcached Successfully installed or not. But I got the error message that 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:
Class 'Memcached' not found
Please let me know how to install the php-memcached in Xappp for my ubuntu system?
php-memcached extension uses the libmemcached library to provide an API for communicating with memcached servers.
So, This extension requires libmemcached client library.
The steps. Tried successfully from a basic ubuntu:22.04 image:
FROM ubuntu:22.04
RUN apt-get update && apt-get upgrade -y && apt-get install -y net-tools sudo wget nano
And xampp install:
cd /home
sudo wget https://downloadsapachefriends.global.ssl.fastly.net/8.1.6/xampp-linux-x64-8.1.6-0-installer.run
sudo chmod 755 xampp-linux-x64-8.1.6-0-installer.run
sudo ./xampp-linux-x64-8.1.6-0-installer.run
Then, there are a lot of dependencies to install:
sudo apt-get update
sudo apt-get install -y memcached
sudo apt-get install php-pear
sudo apt-get install libcurl3-openssl-dev
sudo apt-get install php-dev
sudo apt-get install zlib1g-dev
sudo apt-get install libmemcached-dev
sudo pecl install memcached #note the path to memcached.so
sudo nano /opt/lampp/etc/php.ini
add extension=/usr/lib/php/20210902/memcached.so #path noted before
sudo /opt/lampp/lampp restart
Or another possible install:
sudo apt-get update
sudo apt-get install autoconf
sudo apt-get install build-essential
sudo apt-get install -y pkg-config
sudo apt-get install zlib1g-dev
sudo apt-get install libmemcached-dev
sudo /opt/lampp/bin/pecl install memcached #note the path to memcached.so
sudo nano /opt/lampp/etc/php.ini
add extension=/opt/lampp/lib/php/extensions/no-debug-non-zts-20210902/memcached.so #path noted before
sudo /opt/lampp/lampp restart
With your 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") ;
}
Results:
Cache is empty
And phpinfo:
Reference for more details:
https://www.php.net/manual/en/book.memcached.php
Steps for installing php-memcached in ubuntu
first, go to the /opt/lampp/bin/ then run the below command
> sudo apt-get install libmemcached-dev
> 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
extension=memcached.so
Finally, restart XAMPP
> sudo /opt/lampp/lampp restart
Related
For some reason, my php cli switched to 5.6.40 instead of the 7.2 version that I had before. Then I was unable to restart apache2, so I tried to apt purge php7 & php5 to reinstall them.
But now, I only have this error:
(sorry for the French, it says packages have unsatisfied dependencies). How can I clean it ?
I have already tried the following commands :
apt-get -f install
apt-get clean
apt-get update
apt-get upgrade
You have to purge comlete php7.3:
sudo apt-get remove -y --purge php7.3*
add repository (if not exist):
sudo add-apt-repository ppa:ondrej/php
install dependents
sudo apt install php libapache2-mod-php
if you have apache:
sudo systemctl restart apache2
if you have nginx:
sudo service nginx restart
install php:
sudo apt install php-fpm
check php:
sudo service php7.3-fpm status
I've tried following commands:
sudo yum -y update
sudo yum install -y libevent libevent-devel
sudo yum install -y memcached
sudo yum install -y php-pecl-memcache
sudo service memcached restart
sudo service httpd restart
I can see only memcache module which is installed after run above commands.
Finally got Solution!
I've done some research on installation any module for php 7.1. I got success while run below command:
sudo yum install -y php71-memcached [use 72 instead of 71(php version) for php7.2]
I think you had tried commands from this link, but all are not working :D
https://devdocs.magento.com/guides/v2.3/config-guide/memcache/memcache_centos.html
Upgraded to Ubuntu 16.04 and facing problem after installing PHP5.
Installed PHP-5 with following:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5.5 # for PHP 5.5
Trying to install php-curl but its not working.
sudo apt-get install php5-curl
Error: E: Unable to locate package php5-curl
In Ubuntu 16.04 default PHP version is 7.0, if you want to use different version then you need to install PHP package according to PHP version:
PHP 7.4: sudo apt-get install php7.4-curl
PHP 7.3: sudo apt-get install php7.3-curl
PHP 7.2: sudo apt-get install php7.2-curl
PHP 7.1: sudo apt-get install php7.1-curl
PHP 7.0: sudo apt-get install php7.0-curl
PHP 5.6: sudo apt-get install php5.6-curl
PHP 5.5: sudo apt-get install php5.5-curl
This worked for me.
sudo apt-get install php-curl
This works for me:
sudo apt-get install php5.6-curl
Do:
apt-get update
And then:
apt-get install php5-curl
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt install php8.0-curl
To Install cURL 7.49.0 on Ubuntu 16.04 and Derivatives
wget http://curl.haxx.se/download/curl-7.49.0.tar.gz
tar -xvf curl-7.49.0.tar.gz
cd curl-7.49.0/
./configure
make
sudo make install
For Ubuntu 18.04 or PHP 7.2 users you can do:
apt-get install php7.2-curl
You can check your PHP version by running php -v to verify your PHP version and get the right curl version.
sudo apt-get install php5.6-curl
and restart the web browser.
You can check the modules by running php -m | grep curl
I'm trying to instal pecl_http on my server according to manual manual is for ubuntu, but apt-cache search pecl_http returned php5-pecl-http as pecl http packadge:
sudo apt-get update
sudo apt-get install php-pear php5-dev
sudo apt-get install php5-pecl-http
sudo apt-get install libcurl3-openssl-dev
in the end of php.ini added extension=http.so.
http_get() and func that I need http_parse_headers() says that func is undefined. What's the problem?
It's probably too late but for others a solution is explained here : http://www.mkfoster.com/2009/01/04/how-to-install-a-php-pecl-extensionmodule-on-ubuntu/
sudo apt-get update
sudo apt-get install php-pear php5-dev
sudo apt-get install libcurl3-openssl-dev
Then,
sudo pecl install pecl_http
I followed this tutorial to run solr using php. However I came across the above error. I looked into the SolrClient Class, but have no idea how to use it.
Is there a step by step guide for this?
Please run the following commands
sudo apt-get install libcurl4-gnutls-dev libxml2 libxml2-dev
sudo apt-get install libpcre3-dev
sudo pecl install -n solr
Please add extension in php.ini file
sudo echo "extension=solr.so" >> /etc/php5/apache2/php.ini
Please create solr.ini file in /etc/php5/apache2/conf.d/ and add extension=solr.so in that file.
or run this command in terminal
sudo echo "extension=solr.so" > /etc/php5/apache2/conf.d/solr.ini
and restart apache
sudo /etc/init.d/apache2 restart
PHP-SOLR client is installed and ready to use.. :)
If you are working in Ubuntu Nginx and php-pfm then try this.
sudo apt-get install libcurl4-gnutls-dev libxml2 libxml2-dev
sudo apt-get install libpcre3-dev
sudo pecl install -n solr
Create solr.ini file
sudo echo "extension=solr.so" >/etc/php5/fpm/conf.d/solr.ini
sudo echo "extension=solr.so" >/etc/php5/cli/conf.d/solr.ini
Restart Nginx and php-fpm
sudo restart php5-fpm
sudo service nginx restart
in Debian Linux :
sudo apt-get install libcurl4-gnutls-dev libxml2 libxml2-dev libpcre3-dev php5-dev
sudo pecl install -n solr
sudo echo "extension=solr.so" >/etc/php5/fpm/conf.d/solr.ini
sudo echo "extension=solr.so" >/etc/php5/cli/conf.d/solr.ini
sudo echo "extension=solr.so" >/etc/php5/cgi/conf.d/solr.ini
sudo echo "extension=solr.so" >/etc/php5/apache2/conf.d/solr.ini
sudo /etc/init.d/php5-fpm restart
sudo /etc/init.d/apache2 restart
In CentOS, execute the following commands:
Install the dependencies:
yum install curl-devel libxml2-devel
Install solr module
pecl install solr
Add solr.so extension to php.ini
"extension=solr.so"
Restart Apache:
systemctl restart httpd.service