In this tutorial, we’ll show you how to install and configure Memcached on an Ubuntu 16.04 LTS server. For those of you who didn’t know, Memcached is a system daemon that allows you to cache information in RAM, this gives you an increase in application speed and avoids performance degradation on your dedicated or VPS server. This is very useful for optimizing dynamic websites and maintaining speed by caching objects in memory.
This article assumes that you at least have basic Linux knowledge, know how to use the shell, and most importantly, you can host the site on your VPS. The installation is very simple and assumes that you are running under the root account, if not, you may have to add ‘sudo’ to the commands to gain superuser privileges. We will show you step by step how to install Memcached on a 16.04 Ubuntu server (Xenial Xerus).
Installing Memcached on Ubuntu 16.04 LTS
Step 1. First of all, make sure all your system packages are up to date by running this following apt-get command in terminal.
sudo apt-get update sudo apt-get upgrade
Step 2. Install Memcached.
Now use the following command to install the service Memcached on your system:
sudo apt-get -y install memcached
Step 3. Configuration Memcached…
The default configuration file can be found at:
At startup, Memcached uses port 11211 in default config file:
# Default connection port is 11211 -p 11211
Close and save the configuration file and then restart Memcached:
systemctl restart memcached
Installing the PHP Memcached Extension
You will also need to install the required Memcached PHP extension:
apt-get install php-memcached
Now we can restart Apache to apply the changes:
systemctl restart apache2
To test PHP, create a test file named info.php with the content shown below. Save the file and then navigate to it to see PHP working:
<?php phpinfo(); ?>
Try to access it at: //your_server_ip/info.php. If the PHP info page displays in your browser, then everything looks good and you are ready to move on.
Congratulations! You have successfully installed Memcached. Thank you for using this tutorial to install Memcached on an Ubuntu 16.04 LTS (Xenial Xerus) system. For more help or useful information, we recommend that you check Memcached official website…