Apache2 with PHP and Memcached support allows for improved websites and web applications performance. Memcached is a free open source high-performance object caching program… it allows repeated PHP object / database calls to be cached in system memory to help speed up dynamic web applications.
Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.
Using Memcached with Apache2, PHP on your WordPress or other CMS websites or blogs is a great way to improve their performance. Memcached is a simple yet powerful caching program that webmasters and website owners should use if possible.
This brief tutorial is going to show students and new users how to install Apache2, PHP and Memcached on Ubuntu 17.04 | 17.10.
To get started follow the steps below:
Step 1: Install Apache2
Run the commands below to install Apache2 webserver on Ubuntu
sudo apt update sudo apt install apache2
After installing Apache2, the commands below can be used to stop, start and enable Apache2 to always start up when the system boots
sudo systemctl stop apache2.service sudo systemctl start apache2.service sudo systemctl enable apache2.service
Step 2: Install Memcached
After installing Apache2 above, run the commands below to install Memcached.
sudo apt install memcached
After installing Memcached, the commands below can be used to stop, start and enable Memcached.
sudo systemctl stop memcached.service sudo systemctl start memcached.service sudo systemctl enable memcached.service
Step 3: Install PHP with Related Apache2 Memcached Modules
Now that Apache2 is installed, run the commands below to install PHP with Apache2 and Memcached modules.
sudo apt-get install php libapache2-mod-php php-memcached php-cli
The commands above will install the necessary PHP modules to enable Memcached to function and be accessible.
This is how to get Apache2 with PHP and Memcached support. Now to see if Memcached is installed, run the commands below to create a test php file.
sudo nano /var/www/html/phpinfo.php
Then copy and paste the content below into the file and save.
<?php phpinfo(); ?>
Save the file. After saving, open your browser and browse to the server hostname or IP address followed buy phpinfo.php
You should see all the PHP related modules as well as memcached information. When you see the screenshot below, then you’ll Memcached is installed and enabled.
Congratulations! You’ve successfully installed Apache2, PHP and Memcached on Ubuntu 17.04 | 17.10 systems.
Memcached configuration file is located at /etc/memcached.conf
Run the commands below to open it… there you can change some parameter values to suit your environment
sudo nano /etc/memcached.conf
PHP can be configured at /etc/php/7.x/apache2/php.ini
sudo nano /etc/php/7.x/apache2/php.ini
Change settings there also to suit your environments
You may also like the post below: