Caching Server – TecAdmin https://tecadmin.net How to guide for System Administrator's and Developers Wed, 21 Dec 2022 09:25:29 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 How to Change Redis Max Memory https://tecadmin.net/limit-redis-max-memory/ https://tecadmin.net/limit-redis-max-memory/#respond Wed, 21 Dec 2022 01:38:10 +0000 https://tecadmin.net/?p=22957 To configure the maximum amount of memory that Redis will use, you can use the `maxmemory` directive in the Redis configuration file (`redis.conf`). This directive takes an integer value, representing the maximum number of bytes that Redis will use to store data in memory. For example, to set the maximum memory to `1GB`, (or 1024*1024*1024 [...]

The post How to Change Redis Max Memory appeared first on TecAdmin.

]]>
To configure the maximum amount of memory that Redis will use, you can use the `maxmemory` directive in the Redis configuration file (`redis.conf`). This directive takes an integer value, representing the maximum number of bytes that Redis will use to store data in memory.

For example, to set the maximum memory to `1GB`, (or 1024*1024*1024 bytes) you can use the following configuration:

maxmemory 1073741824

You can also specify a policy for how Redis should handle the situation when the maximum memory limit is reached. This is done using the `maxmemory-policy` directive, which can take one of the following values:

  • noeviction: Redis will return an error when the maximum memory limit is reached and a new key needs to be added.
  • allkeys-lru: Redis will remove the least recently used keys in order to make space for new keys.
  • volatile-lru: Redis will remove the least recently used keys among keys with an expire set in order to make space for new keys.
  • allkeys-random: Redis will randomly select keys to remove in order to make space for new keys.
  • volatile-random: Redis will randomly select keys with an expire set to remove in order to make space for new keys.
  • volatile-ttl: Redis will remove keys with the shortest time to live in order to make space for new keys.

For example, to set the `maxmemory-policy` to `allkeys-lru`, you can use the following configuration:

maxmemory-policy allkeys-lru

Note that the maxmemory and maxmemory-policy directives must be set in the Redis configuration file (redis.conf) and cannot be set using the CONFIG SET command at runtime. You will need to restart Redis for the changes to take effect.

It’s also worth noting that Redis will automatically try to free memory when it is running out of available memory, by releasing memory used by the least recently used keys. However, this process is limited by the maxmemory-samples directive, which determines the number of keys that Redis will sample in order to determine the keys to be removed. By default, this value is set to 3, so Redis will only sample 3 keys in order to determine the keys to be removed. You can adjust this value if needed by using the maxmemory-samples directive in the Redis configuration file.

The post How to Change Redis Max Memory appeared first on TecAdmin.

]]>
https://tecadmin.net/limit-redis-max-memory/feed/ 0
How To Install Memcached on Ubuntu 20.04 https://tecadmin.net/how-to-install-memcached-on-ubuntu-20-04/ https://tecadmin.net/how-to-install-memcached-on-ubuntu-20-04/#respond Tue, 18 Aug 2020 12:19:10 +0000 https://tecadmin.net/?p=21825 Memcached is a distributed memory object caching system which stored data in memory on key-value basis. It is very useful for optimizing dynamic websites and enabled speed by caching objects in memory. This article will help you to install Memcached with PHP Memcache PECL extension on Ubuntu 20.04 systems. Prerequisites You must have shell access [...]

The post How To Install Memcached on Ubuntu 20.04 appeared first on TecAdmin.

]]>
Memcached is a distributed memory object caching system which stored data in memory on key-value basis. It is very useful for optimizing dynamic websites and enabled speed by caching objects in memory.

This article will help you to install Memcached with PHP Memcache PECL extension on Ubuntu 20.04 systems.

Prerequisites

You must have shell access to your Ubuntu 20.04 system with sudo privileged account.

Login to your system and complete this tutorial.

Step 1 – Installing Memcached on Ubuntu

First of all, update Apt package cache on your system then install Memcached service on your system. Execute below commands from command prompt.

sudo apt update 
sudo apt install memcached 

Step 2 – Configure Memcached

You can find the details information about Memcache configuration here. For initial level configuration check for the following settings under Memcache configuration file /etc/memcached.conf.

  • -d => Run Memcached in deamon mode. You can use this option to configure your Memcached server to run as service.
  • -m => Define the maximum number of Memory can be used by Memcached deamon. (default: 64 MB)
  • -p => Defind port for Memcached to listen on. (default: 11211)
  • -l => Define the IP address to Memcached listen on. Set 0.0.0.0 to listen on all IPs(enterfaces) configured on system.

After making changes, restart the Memcached service.

sudo systemctl restart memcached 

Step 3 – Verify Memcache Setup

Use the following command to check and verify that Memcached service is running properly on your system. This will show you the current statstics of your Memcached server. So the values may be differ that below results.

echo "stats settings" | nc localhost 11211 

Output:

STAT maxbytes 134217728
STAT maxconns 1024
STAT tcpport 11211
STAT udpport 11211
STAT inter 127.0.0.1
STAT verbosity 0
STAT oldest 0
STAT evictions on
STAT domain_socket NULL
STAT umask 700
STAT growth_factor 1.25
STAT chunk_size 48
STAT num_threads 4
STAT num_threads_per_udp 4
STAT stat_key_prefix :
STAT detail_enabled no
STAT reqs_per_event 20
STAT cas_enabled yes
STAT tcp_backlog 1024
STAT binding_protocol auto-negotiate
STAT auth_enabled_sasl no
STAT item_size_max 1048576
STAT maxconns_fast no
STAT hashpower_init 0
STAT slab_reassign no
STAT slab_automove 0
STAT lru_crawler no
STAT lru_crawler_sleep 100
STAT lru_crawler_tocrawl 0
STAT tail_repair_time 0
STAT flush_enabled yes
STAT hash_algorithm jenkins
STAT lru_maintainer_thread no
STAT hot_lru_pct 32
STAT warm_lru_pct 32
STAT expirezero_does_not_evict no
END

Step 4 – Installing Memcache/Memcached PHP Module

Now install latest PHP from ppa:ondrej/php PPA on your Ubuntu system. If you have already installed PHP on your system, just skip PHP installation commands below.

sudo add-apt-repository ppa:ondrej/php 
sudo apt update 
sudo apt install -y php php-dev php-pear libapache2-mod-php 

Now install PHP Memcached module on your system. The below command will also do the required configuration.

sudo apt install -y php-memcached php-memcache 

After completing the installation, you must restart the Apache service.

sudo systemctl restart apache2 

Check if Memcache php extension is enabled and working properly. Create a info.php file under the document root of your domain with following code:

/var/www/html/info.php

<?php
  phpinfo();
?>

Now access info.php on the web interface and search for Memcache, You will get the result like below.

https://server-ip/info.php

How to Install Memcached on Ubuntu 20.04

Conclusion

In this tutorial, you have learned to install Memcached service along with PHP extension on your Ubuntu 20.04 system.

The post How To Install Memcached on Ubuntu 20.04 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-memcached-on-ubuntu-20-04/feed/ 0
How To Install Redis on Debian 10 https://tecadmin.net/how-to-install-redis-on-debian-10/ https://tecadmin.net/how-to-install-redis-on-debian-10/#respond Tue, 07 Jul 2020 14:04:56 +0000 https://tecadmin.net/?p=21829 Redis is an in-memory data structure store, used as a database server, cache, and message broker. Redis is written in C programming language. It also provides a PHP module for communication between PHP script with the Redis server.This tutorial will help you to install Redis server on Debian 10 Linux system. This will also help [...]

The post How To Install Redis on Debian 10 appeared first on TecAdmin.

]]>
Redis is an in-memory data structure store, used as a database server, cache, and message broker. Redis is written in C programming language. It also provides a PHP module for communication between PHP script with the Redis server.This tutorial will help you to install Redis server on Debian 10 Linux system. This will also help you to install Redis PHP extensions on your system.

Prerequisites

You must have shell access with sudo privileged account access to Debian 10 system. First of all, Login to your system and upgrade the current packages.

sudo apt update && sudo apt upgrade

Step 1 – Install Redis on Debian 10

Redis packages are available under the default apt repository. You can directly install Redis on Debian 10 system without adding any PPA. Run the following command to install Redis on Debian:

sudo apt install redis-server

After installation, enable Redis service to start on system boot.

sudo systemctl enable redis-server

Step 2 – Configure Memory for Redis

Redis can be started without a configuration file using a built-in default configuration. But to make any extra parameter changes you can use its configuration file that is: /etc/redis/redis.conf. Edit the Redis configuration file in a text editor to make changes

sudo vim /etc/redis/redis.conf

Update the following values in Redis configuration file according to your requirement. You can increase max memory limit as per available on your server.

maxmemory 256mb
maxmemory-policy allkeys-lru

The above configuration tells Redis to remove any key using the LRU algorithm when the max memory of 256mb is reached. Save the configuration file and restart the Redis service:

sudo systemctl restart redis-server

Step 3 – Install Redis PHP Extension

This is an optional step. If you need to connect Redis from PHP application, You need to install Redis PHP extension on your Debian system. To install Redis PHP extension, simply type:

sudo apt install php-redis

The installer will automatically enable redis extension for all the pre installed PHP versions. If you installer new PHP version after this, you can use below command to enable redis module. For example to enable extension for PHP 7.4, type:

sudo phpenmod -v 7.4 -s ALL redis

Step 4 – Connect to Redis Server

Use redis-cli tool to verify the connection between the Redis server.

redis-cli

127.0.0.1:6379> ping
PONG

Few more examples of redis-cli command line tool. You can find more details about redis-cli here.

redis-cli info
redis-cli info stats
redis-cli info server

How to Install Redis on Debian 10

Conclusion

This tutorial helps you with the installation of Redis server on Debian 10 system.

The post How To Install Redis on Debian 10 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-redis-on-debian-10/feed/ 0
How to Install Redis on Ubuntu 20.04 https://tecadmin.net/install-redis-ubuntu-20-04/ https://tecadmin.net/install-redis-ubuntu-20-04/#respond Sun, 10 May 2020 11:57:51 +0000 https://tecadmin.net/?p=21306 Redis is an in-memory data structure store, used as a database server, cache, and message broker. Redis is written in C programming language. It also provides a PHP module for communication between PHP script with the Redis server. This tutorial will help you to install Redis server along with PHP extensions on an Ubuntu 20.04 [...]

The post How to Install Redis on Ubuntu 20.04 appeared first on TecAdmin.

]]>
Redis is an in-memory data structure store, used as a database server, cache, and message broker. Redis is written in C programming language. It also provides a PHP module for communication between PHP script with the Redis server.

This tutorial will help you to install Redis server along with PHP extensions on an Ubuntu 20.04 LTS system.

Prerequisites

Before beginning the Redis server installation on Ubuntu 20.04:

  • Login to Ubuntu as sudo privileged user
  • For the newly installed systems, required to complete initial server setup
  • Step 1 – Install Redis Server

    Redis packages are available under the default apt repository. For the installation of Redis on an Ubuntu VPS. Run below command from the terminal to install Redis on your machine:

    sudo apt update
    sudo apt install redis-server
    

    Next is to enable Redis to start on system boot. Also restart Redis service once.

    sudo systemctl enable redis-server
    

    Step 2 – Configure Redis

    Redis can be started without a configuration file using a built-in default configuration. But to make any extra parameter changes you can use its configuration file that is: /etc/redis/redis.conf. Edit the Redis configuration file in a text editor to make changes

    sudo vim /etc/redis/redis.conf
    

    Update the following values in Redis configuration file according to your requirement. You can increase max memory limit as per available on your server.

    maxmemory 256mb
    maxmemory-policy allkeys-lru
    

    The above configuration tells Redis to remove any key using the LRU algorithm when the max memory of 256mb is reached. Save the configuration file and restart the Redis service:

    sudo systemctl restart redis-server
    

    Step 3 – Install PHP Extension (Optional)

    Next, if you need to use Redis with PHP application, you need to install Redis PHP extension on your Ubuntu system. To install Redis PHP extension, type:

    sudo apt install php-redis
    

    The installer will automatically enable redis extension for all the pre installed PHP versions. If you installer new PHP version after this, you can use below command to enable redis module. For example to enable extension for PHP 7.4, type:

    sudo phpenmod -v 7.4 -s ALL redis
    

    Step 4 – Connect to Redis Server

    Use redis-cli tool to verify the connection between the Redis server.

    redis-cli
    
    127.0.0.1:6379> ping
    PONG
    
    

    Few more examples of redis-cli command line tool. You can find more details about redis-cli here.

    redis-cli info
    redis-cli info stats
    redis-cli info server
    

    Installing redis ubuntu 20.04

    Conclusion

    This tutorial helps you with the installation of Redis server on Ubuntu 20.04 LTS (Focal Fossa) system.

    The post How to Install Redis on Ubuntu 20.04 appeared first on TecAdmin.

    ]]> https://tecadmin.net/install-redis-ubuntu-20-04/feed/ 0 How To Install Memcached on Fedora 35/34/33 https://tecadmin.net/install-memcached-on-fedora/ https://tecadmin.net/install-memcached-on-fedora/#respond Thu, 30 May 2019 19:46:44 +0000 https://tecadmin.net/?p=18601 Memcached is a distributed memory object caching system which stored data in memory on key-value basis. It is very useful for optimizing dynamic websites and enabled speed by caching objects in memory. Read more about memcache. This article will help you to install Memcached on Fedora Linux systems. Install Memcached on Fedora Memcached is available [...]

    The post How To Install Memcached on Fedora 35/34/33 appeared first on TecAdmin.

    ]]>
    Memcached is a distributed memory object caching system which stored data in memory on key-value basis. It is very useful for optimizing dynamic websites and enabled speed by caching objects in memory. Read more about memcache.

    This article will help you to install Memcached on Fedora Linux systems.

    Install Memcached on Fedora

    Memcached is available under default Fedora repositories. You can install it by running the following command on your Fedora Linux system.

    sudo dnf install memcached -y
    

    Now start the Memcached service using the following commands.

    sudo systemctl enable memcached.service 
    sudo systemctl start memcached.service 
    

    Memcached Configuration

    Edit the Memcached default configuration file in your favorite text editor.

    sudo vim /etc/sysconfig/memcached
    

    and update the settings as per your system requirements. Here CACHESIZE is the max memory limit in Mb, which Memcached can use.

     PORT="11211"
     USER="memcached"
     MAXCONN="1024"
     CACHESIZE="64"
     OPTIONS=""
    

    The above configuration shows that Memcached can use up to 64 Mb memory on the system.

    After doing any changes, restart the Memcached server to apply changes.

    sudo systemctl restart memcached.service
    

    View Memcached Stats

    You can view the service status using the systemctl command

    sudo systemctl status memcached.service
    

    You can also view the statics of the running Memcached service using “stats settings” command. Below is the example to send this command to the Memcached server and see the results.

    echo "stats settings" | nc localhost 11211
    
    STAT maxbytes 67108864
    STAT maxconns 1024
    STAT tcpport 11211
    STAT udpport 11211
    STAT inter 127.0.0.1
    STAT verbosity 0
    STAT oldest 0
    STAT evictions on
    STAT domain_socket NULL
    STAT umask 700
    STAT growth_factor 1.25
    STAT chunk_size 48
    STAT num_threads 4
    STAT num_threads_per_udp 4
    STAT stat_key_prefix :
    STAT detail_enabled no
    STAT reqs_per_event 20
    STAT cas_enabled yes
    STAT tcp_backlog 1024
    STAT binding_protocol auto-negotiate
    STAT auth_enabled_sasl no
    STAT item_size_max 1048576
    STAT maxconns_fast no
    STAT hashpower_init 0
    STAT slab_reassign no
    STAT slab_automove 0
    END
    

    Install Memcache PHP Extension

    You need to enable Memcache/Memcached PHP extension on your server to connect PHP with the Memcached service. There are basically two Memcache PHP modules available to install. One is named Memcache and the other Memcached. So install the module as per your uses.

    sudo dnf install php-pecl-memcache 
    sudo dnf install php-pecl-memcached 
    

    After installation restarts the Apache service.

    sudo systemctl restart httpd.service 
    

    Now check if memcache php extension is enabled and working properly. Create a phpinfo.php file using following code

    <?php
      phpinfo();
    ?>

    Now access http://server-ip-addr/phpinfo.php on the web browser and search for Memcache, You will see the results below.

    install memcache fedora

    install memcached fedora

    The post How To Install Memcached on Fedora 35/34/33 appeared first on TecAdmin.

    ]]>
    https://tecadmin.net/install-memcached-on-fedora/feed/ 0
    Clearing the Redis Cache: A Step-by-Step Guide https://tecadmin.net/clear-redis-cache/ https://tecadmin.net/clear-redis-cache/#respond Sun, 18 Nov 2018 10:05:41 +0000 https://tecadmin.net/?p=17672 Redis is an in-memory data structure store that can be used as a database, cache, and message broker. It supports a wide range of data structures, such as strings, hashes, lists, sets, and sorted sets, and it provides high performance and scalability. To clear the Redis cache, you can use the `FLUSHALL` command. This command [...]

    The post Clearing the Redis Cache: A Step-by-Step Guide appeared first on TecAdmin.

    ]]>
    Redis is an in-memory data structure store that can be used as a database, cache, and message broker. It supports a wide range of data structures, such as strings, hashes, lists, sets, and sorted sets, and it provides high performance and scalability.

    To clear the Redis cache, you can use the `FLUSHALL` command. This command removes all keys from all databases in the Redis instance.

    Here’s a step-by-step guide on how to clear the Redis cache:

    1. Connect to Redis Server
    2. Connect to the Redis instance using the `redis-cli` command-line utility. You can specify the hostname and port of the Redis instance as arguments, or you can use the -h and -p options. For example:

      redis-cli -h 127.0.0.1 -p 6379 
      

      You can authenticate the connection using `-a ` when connecting to the server.

    3. Redis: Flush All Databases Cache
    4. Once connected, Use the `FLUSHALL` command to clear the entire cache. This command removes all keys from all databases in the Redis instance. It is an administrative command, and it is not recommended for use in production environments.

      FLUSHALL 
      

      The `FLUSHALL` command will return `OK` if the cache was successfully cleared. You can then exit the redis-cli utility by typing exit and pressing Enter.

      exit 
      

      That’s it! The Redis cache is now empty, and all keys have been removed from all databases in the Redis instance.

    5. Redis: Flush Single Database Cache
    6. Use the `FLUSHDB` command to clear a specific database. This command removes all keys from the currently selected database. You can specify the database number as an argument, or you can use the `SELECT` command to switch to the desired database before running FLUSHDB.

      FLUSHDB
      

      Select the database first and then flush it.

      SELECT 2 
      FLUSHDB
      

    7. Redis: Delete Specific Key Values
    8. Use the `DEL` command to delete specific keys. This command takes one or more keys as arguments, and it removes the specified keys from the current database.

      DEL key1 key2 key3
      

      Use the `KEYS` command to list all keys in the current database. This command takes a pattern as an argument, and it returns a list of keys that match the pattern. You can use this command to find and delete specific keys.

      KEYS *
      DEL $(KEYS pattern*)
      

    9. Redis: Set Expireation Time for Specific Key
    10. Use the `EXPIRE` command to set an expiration time on keys. This command takes a key and a number of seconds as arguments, and it causes the key to be deleted after the specified time has elapsed.

      EXPIRE key1 3600
      

    11. Redis: Remove Expireation Time for Specific Key
    12. Use the `PERSIST` command to remove the expiration time from a key. This command takes a key as an argument, and it removes the expiration time from the key if it has one.

      PERSIST key1
      

    Conclusion

    Note that the `FLUSHALL` command is an administrative command, and it is not recommended for use in production environments. If you want to clear only a specific database or a subset of keys, you can use the FLUSHDB or DEL commands instead. For more information, you can consult the Redis documentation or search online for tutorials and examples.

    I hope these tips and tricks are helpful! Let me know if you have any other questions.

    The post Clearing the Redis Cache: A Step-by-Step Guide appeared first on TecAdmin.

    ]]>
    https://tecadmin.net/clear-redis-cache/feed/ 0
    How to install and configure Squid Proxy on Debian 8 https://tecadmin.net/install-squid-debian8/ https://tecadmin.net/install-squid-debian8/#respond Sun, 21 Oct 2018 10:46:32 +0000 https://tecadmin.net/?p=17693 Squid is a popular Proxy server for Unix like operating systems. It also used for the web filtering. Its widely used for increasing web server speed by caching repeated data. This tutorial helps you to install Squid proxy server on your Debian 8 Jessie system. Also provide basic configuration details of Proxy server to allow [...]

    The post How to install and configure Squid Proxy on Debian 8 appeared first on TecAdmin.

    ]]>
    Squid is a popular Proxy server for Unix like operating systems. It also used for the web filtering. Its widely used for increasing web server speed by caching repeated data. This tutorial helps you to install Squid proxy server on your Debian 8 Jessie system. Also provide basic configuration details of Proxy server to allow traffic, restrict specific websites with keyword or domain names.

    Step 1 – Install Squid on Debian 8

    Login to your Debian 8 system using root or sudo privileges user. Then run the following commands on the console to install Squid on Debian 8 system from the default package repository.

    sudo apt update
    sudo apt install squid
    

    Step 2 – Configure Squid Port

    Squid default runs on port 3128. It is your choice to keep running squid on default port or change it to some different port. To change port edit squid configuration file and changehttp_port value.

    /etc/squid/squid.conf

    http_port 3128
    

    After making changing let’s restart Squid service to reload the configuration changes

    sudo service squid restart
    

    Step 3 – Allow All Traffic

    Assuming you need a proxy server open to all, Then you need to allow all traffic on your proxy server. Edit the Squid configuration file and Comment the http_access deny all line. Then add the http_access allow all entry this file.

     http_access allow all
     #http_access deny all
    

    Squid allow all

    Step 4 – Block Specific Website with Squid

    Here you want to block some specific websites through the proxy server. Then add the following rules to block specific website just before the allow all rule. Below example will block yahoo.com and www.rediff.com.

    acl blocksite1 dstdomain yahoo.com
    acl blocksite2 dstdomain www.rediff.com
    http_access deny blocksite1
    http_access deny blocksite2
    

    If you have a large number of domain names, then create a file /etc/squid/blockwebsites.lst and put domain names one per line and add below rule in the squid configuration file.

    acl blocksitelist dstdomain "/etc/squid/blockwebsites.lst"
    http_access deny blocksitelist
    

    blockwebsites.lst file content example:

    cat /etc/squid/blockwebsites.lst
    
    yahoo.com
    www.rediff.com
    

    Step 5 – Block Specific Keyword with Squid

    You can also block websites for specific keywords. Add the following rules just before the allow all rule. Below is the example of blocking all pages having keyword yahoo or Gmail.

    acl blockkeyword1 url_regex yahoo
    acl blockkeyword2 url_regex gmail
    http_access deny blockkeyword1
    http_access deny blockkeyword2
    

    If you have a large number of keywords to block then create a file /etc/squid/blockkeywords.lst and put keywords one per line and add below rule in the squid configuration file.

    acl blockkeywordlist url_regex "/etc/squid/blockkeywords.lst"
    http_access deny blockkeywordlist
    

    blockkeywords.lst file content example:

    cat /etc/squid/blockkeywords.lst 
    
    yahoo
    gmail
    facebook
    

    Congratulation’s you have successfully install and configured Squid proxy server. Read next article to Configure Squid for Mac Address Based Filtering.

    The post How to install and configure Squid Proxy on Debian 8 appeared first on TecAdmin.

    ]]>
    https://tecadmin.net/install-squid-debian8/feed/ 0
    How to Install Memcached on Debian 10/9/8 https://tecadmin.net/install-memcached-on-debian/ https://tecadmin.net/install-memcached-on-debian/#comments Wed, 23 May 2018 10:07:49 +0000 https://tecadmin.net/?p=16317 Memcached is a distributed memory object caching system, which stored data in memory on key-value basis. It is very useful for optimizing dynamic websites and enhanced speed by caching objects in memory. This article will help you to install Memcached with PHP Memcache extension on Debian 10, Debian 9 Stretch and Debian 8 Jessie systems. [...]

    The post How to Install Memcached on Debian 10/9/8 appeared first on TecAdmin.

    ]]>
    Memcached is a distributed memory object caching system, which stored data in memory on key-value basis. It is very useful for optimizing dynamic websites and enhanced speed by caching objects in memory. This article will help you to install Memcached with PHP Memcache extension on Debian 10, Debian 9 Stretch and Debian 8 Jessie systems.

    Step 1 – Install Memcached on Debian

    Update apt package cache on your system and then install Memcached on Debian system. Execute below commands on the terminal in your Debian system.

    sudo apt update
    sudo apt install memcached
    

    Step 2 – Memcached Configuration

    You can find the details information about Memcache configuration here. For inital level configuration check for the following settings under Memcache configuration file /etc/memcached.conf.

    • -d => Run Memcached in deamon mode.
    • -m => Maximum memory to be used by Memcached. (default: 64 MB)
    • -p => Define port for Memcached. (default: 11211)
    • -l => Define IP address to listen on. Use 0.0.0.0 to listen on all IPs(enterfaces).

    After making changes, restart the Memcached service.

    Step 3 – Test Memcached Setup

    Use nc command to check Memcached status. This will show you the current statistics of running Memcached server. So the values may differ per installation.

    echo "stats" | nc localhost 11211
    
    STAT maxbytes 67108864
    STAT maxconns 1024
    STAT tcpport 11211
    STAT udpport 0
    STAT inter 127.0.0.1
    STAT verbosity 0
    STAT oldest 0
    STAT evictions on
    STAT domain_socket NULL
    STAT umask 700
    STAT growth_factor 1.25
    STAT chunk_size 48
    STAT num_threads 4
    STAT num_threads_per_udp 4
    STAT stat_key_prefix :
    STAT detail_enabled no
    STAT reqs_per_event 20
    STAT cas_enabled yes
    STAT tcp_backlog 1024
    STAT binding_protocol auto-negotiate
    STAT auth_enabled_sasl no
    STAT item_size_max 1048576
    STAT maxconns_fast no
    STAT hashpower_init 0
    STAT slab_reassign no
    STAT slab_automove 0
    STAT slab_chunk_max 1048576
    STAT lru_crawler no
    STAT lru_crawler_sleep 100
    STAT lru_crawler_tocrawl 0
    STAT tail_repair_time 0
    STAT flush_enabled yes
    STAT hash_algorithm jenkins
    STAT lru_maintainer_thread no
    STAT hot_lru_pct 32
    STAT warm_lru_pct 32
    STAT expirezero_does_not_evict no
    STAT idle_timeout 0
    STAT watcher_logbuf_size 262144
    STAT worker_logbuf_size 65536
    STAT track_sizes no
    END
    

    Step 4 – Install Memcached PHP Extension

    Execute the following command to install PHP Memcached extension on your system.

    sudo apt install php-memcached 
    

    After completing the installation, you must restart the Apache service to reload all settings.

    phpenmod memcached
    sudo service apache2 restart
    

    All done, You can now test Memcache PHP extension is enabled and working properly by creating an info.php file using the following code.

    <?php
      phpinfo();
    ?>

    Now copy info.php file on Apache document root and access on the web interface. Search for the Memcache, You will get the result like below.

    Install memcached, PHP, Ubuntu

    The post How to Install Memcached on Debian 10/9/8 appeared first on TecAdmin.

    ]]>
    https://tecadmin.net/install-memcached-on-debian/feed/ 1
    How to Install Redis Cache Server on CentOS 7/6 https://tecadmin.net/install-redis-centos/ https://tecadmin.net/install-redis-centos/#comments Thu, 22 Mar 2018 15:52:01 +0000 https://tecadmin.net/?p=15527 Redis is an in-memory data structure store, used as a database server, cache, and message broker. It also provides a PHP module for communication between PHP script with the Redis server. Redis is written in C programming language. This tutorial will help you with the installation of the Redis server along with PHP Redis PHP [...]

    The post How to Install Redis Cache Server on CentOS 7/6 appeared first on TecAdmin.

    ]]>
    Redis is an in-memory data structure store, used as a database server, cache, and message broker. It also provides a PHP module for communication between PHP script with the Redis server. Redis is written in C programming language.

    This tutorial will help you with the installation of the Redis server along with PHP Redis PHP extensions on a CentOS 7/6 server.

    Step 1 – Prerequisites

    First of all, log in to your server using shell access with the root account.

    ssh root@remote
    

    Redis packages are not available under default yum repositories. You need to enable EPEL yum repository on your server first. Execute below command to enable:

    ### CentOS/RHEL 7 
    yum install epel-release
    
    ### CentOS/RHEL 6 
    rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
    

    Step 2 – Install Redis Server

    Now, You can use the yum package manager to install the Redis server on a VPS. Execute command to install Redis on your systems:

    yum install redis
    

    After successfully installation start Redis service and enable auto-start on system reboot.

    ### CentOS/RHEL 7 
    systemctl enable redis
    systemctl start redis
    
    ### CentOS/RHEL 6 
    chkconfig redis on
    service redis restart
    

    Redis server is up and running on your system.

    Step 3 – Install Redis PHP extension

    We assume you already have PHP installed on your system. You must have PHP pear package installed on your system.

    yum install php-pear php-devel
    

    Now, execute commands to enable Redis PHP extension on your CentOS server.

    pecl install igbinary igbinary-devel redis
    

    After that execute a command to verify Redis PHP extension is enabled:

    php -m | grep redis
    

    Redis server has been installed on your system along with the PHP extension.

    Step 4 – Configure Redis as a Cache Server

    Redis can be started without a configuration file using a built-in default configuration. But to make any extra parameter changes you can use its configuration file that is: /etc/redis/redis.conf. Edit the Redis configuration file in a text editor to make changes

    vim /etc/redis/redis.conf
    

    Update the following values in the Redis configuration file according to your requirement. You can increase the max memory limit as per available on your server.

    maxmemory 256mb
    maxmemory-policy allkeys-lru
    

    The above configuration tells Redis to remove any key using the LRU algorithm when the max memory of 256mb is reached. Save the configuration file and restart the Redis service:

    Step 5 – Test Connection to Redis Server

    Use redis-cli tool to verify the connection between the Redis server and redis-cli.

    redis-cli
    
    127.0.0.1:6379> ping
    PONG
    127.0.0.1:6379>
    

    The post How to Install Redis Cache Server on CentOS 7/6 appeared first on TecAdmin.

    ]]>
    https://tecadmin.net/install-redis-centos/feed/ 2
    How to Install Redis on Ubuntu 18.04 & 16.04 LTS https://tecadmin.net/install-redis-ubuntu/ https://tecadmin.net/install-redis-ubuntu/#comments Sun, 18 Mar 2018 15:46:05 +0000 https://tecadmin.net/?p=15529 Redis is an in-memory data structure store, used as a database server, cache, and message broker. Redis is written in C programming language. It also provides a PHP module for communication between PHP script with the Redis server. This tutorial will help you with the installation of Redis server along with PHP Redis PHP extensions [...]

    The post How to Install Redis on Ubuntu 18.04 & 16.04 LTS appeared first on TecAdmin.

    ]]>
    Redis is an in-memory data structure store, used as a database server, cache, and message broker. Redis is written in C programming language. It also provides a PHP module for communication between PHP script with the Redis server.

    This tutorial will help you with the installation of Redis server along with PHP Redis PHP extensions on an Ubuntu 19.04, 18.04 LTS, 16.04 LTS and 14.04.

    Step 1 – Prerequsities

    Log in to your system with sudo privilege account using shell access, to which you need to install Redis.

    ssh ubuntu@remote
    

    Update the apt-get packages index files and also update existing packages to the newest versions by using the following commands:

    sudo apt-get update
    sudo apt-get upgrade
    

    Step 2 – Installing Redis

    The Redis packages are available under the default apt repository. For the installation of Redis on an Ubuntu VPS. Run below command from the terminal to install Redis on your machine:

    sudo apt-get install redis-server
    

    Next is to enable Redis to start on system boot. Also restart Redis service once.

    sudo systemctl enable redis-server.service
    

    Step 3 – Configure Redis

    Redis can be started without a configuration file using a built-in default configuration. But to make any extra parameter changes you can use its configuration file that is: /etc/redis/redis.conf. Edit the Redis configuration file in a text editor to make changes

    sudo vim /etc/redis/redis.conf
    

    Update the following values in Redis configuration file according to your requirement. You can increase max memory limit as per available on your server.

    maxmemory 256mb
    maxmemory-policy allkeys-lru
    

    The above configuration tells Redis to remove any key using the LRU algorithm when the max memory of 256mb is reached. Save the configuration file and restart the Redis service:

    sudo systemctl restart redis-server.service
    

    Step 4 – Install Redis PHP Extension

    Now, if you need to use Redis from PHP application, you also need to install Redis PHP extension on your Ubuntu system. Run below command to install:

    sudo apt-get install php-redis
    

    Step 5 – Test Connection to Redis Server

    Use redis-cli tool to verify the connection between the Redis server.

    redis-cli
    
    127.0.0.1:6379> ping
    PONG
    127.0.0.1:6379>
    

    Few more examples of redis-cli command line tool. You can find more details about redis-cli here.

    redis-cli info
    redis-cli info stats
    redis-cli info server
    

    Install Redis on Ubuntu

    The post How to Install Redis on Ubuntu 18.04 & 16.04 LTS appeared first on TecAdmin.

    ]]>
    https://tecadmin.net/install-redis-ubuntu/feed/ 11