Contents
How To Install Memcached with PHP on Ubuntu
1. About Memcached :
memcached is a high-performance, distributed memory object caching system, generic in nature, but originally intended for use in speeding up dynamic web applications by alleviating database load.
2. Install memcached:
Step 1. First of all make sure that all packages are up to date.
1 |
apt-get update && apt-get upgrade |
Step 2. Install Memcached.
Execute the following commands to install memcached:
1 |
apt-get install memcached |
Step 3. Configuration Memcached.
The default configuration file can be found at:
1 |
nano /etc/memcached.conf |
When started, Memcached will start on port 11211 by default per the default configuration file:
# Default connection port is 11211
-p 11211
Exit and save the configuration file, and then restart Memcached:
1 |
service memcached restart |
3. Installing Memcached extension for PHP :
You can install memcached extension by typing:
1 |
apt-get install php-memcached |
Now, we can restart Apache so that the changes take place:
1 |
service apache2 restart |
To test PHP, create a test file named info.php with he content below. Save the file, then browse to it to see if PHP is working:
1 |
nano /var/www/html/info.php |
<?php
phpinfo();
?>
Now access info.php on web interface at http://localhost/info.php and search for Memcache, You will get result like below.
4 Conclusion
In this post, i have explained How To Install Memcached with PHP on Ubuntu
If you have any questions or feedback, feel free to leave a comment.
As always, if you found this post useful, then click like and share it 🙂