Need help?

Our experts have had an average response time of 13.14 minutes in February 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

How we enabled PHP FPM Memcached for faster websites

by | May 25, 2019

Have you ever thought what slows down your server? This may be due to a large number of request for a database in a single time.

Here’s PHP FPM Memcached’s role which is a distributed memory caching system. This can reduce database load and accelerates web applications.

At Bobcares, we often get requests from our customers set up PHP FPM Memcached as part of our Server Management Services.

Today, we’ll see how our Support Engineers set up PHP FPM with Memcached and fix the related errors.

What is PHP FPM Memcached?

PHP FPM Memcached can speed up the delivery of the website’s data by storing the most frequently used resources in the cache. Therefore, it amplifies the customer experience through a better response time of the websites.

In addition, Memcached minimizes the database loads by storing data objects in dynamic memory, resulting in faster Web applications. Also, Memcached stores data in key/value pairs in the form of large hash tables.

 

How we installed PHP FPM Memcached Module

Here’re the steps how our Support Engineers install Memcached with PHP-FPM on Nginx.

1. Firstly, we run the following command to install Memcached.

apt install memcached

2. After installing Memcached, we enable and start the Memcached service

systemctl enable memcached.service

systemctl start memcached.service

3. Then we run the following commands to install PHP with Nginx and Memcached modules.

apt-get install php-fpm php-memcached php-cli

4. Next, we enable Nginx PHP site support in default site configuration file and enable the PHP block. To enable PHP block, we uncomment to enable the PHP section.

nano /etc/nginx/sites-available/default

6. At last, we restart Nginx Web server.

systemctl reload nginx.service

 

Moreover, to test whether the Memcached is properly installed, we use info.php file to test it. The output looks like,

Related errors and how we fixed it

From our experience in managing server, we’ve seen that customers facing problems after installing Memcached. Let’s take a closer look at how our Support Engineers fixed the problems.

 

1. Wrong IP address settings

Recently, one of the customers reported problems with PHP FPM Memcached on their Amazon EC2 instances pool. But Memcache was not connecting on one of the servers.

On checking, our Support engineers found that Memcached was running on the server.

root@ip-172-xx-xx-125:~ # sockstat -4l | grep mem
nobody memcached 26445 17 tcp4 *:11211 *:*
nobody memcached 26445 22 udp4 *:11211 *:*
nobody memcached 26445 23 udp4 *:11211 *:*
nobody memcached 26445 24 udp4 *:11211 *:*
nobody memcached 26445 25 udp4 *:11211 *:*

However, Memcached service was configured to listen on server address and this was creating problems here.

It is always recommended to use private IP connections between servers in the same datacenter. This will ensure a faster network connection and maximum service security.

Therefore, we set the Memcached service to listen on the private IP-addresses on EC2 instances instead of the public IP addresses. And, the problem was fixed.

 

PHP FPM service down

Similarly, another customer had an issue after installing Memcached. He got an error “Fatal error: Class ‘Memcached’ not found” while enabling Memcached on the server.

Then our Support Engineers took the following steps to solve the error.

1. Firstly, we logged into the server as root user.

2. Then, we checked the status of service php5-fpm.

service php5-fpm status

3. So, we found that the php5-fpm service was down.

4. At last, we restarted the php5-fpm service.

service php5-fpm restart

This is how we fixed the error.

 

[Having trouble while setting up PHP FPM Memcached? We’ll fix it for you.]

 

Conclusion

In short, Memcached increases the delivery speed of the website’s data by storing the most frequently used resources in the cache. Today, we saw how our Support Engineers setup PHP FPM Memcached and fixed related errors.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Categories

Tags

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF