wesupport

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.

What to do when your PHP sites running on PHP-FPM stop working

by | Jul 15, 2017

A single downtime or error can badly affect an online business. In our role as Outsourced hosting support specialists for web hosts, we encounter and resolve many web server issues in our customers’ servers.

Most webservers such as Apache, NginX etc. make use of additional tools and modules to improve their performance and speed up the sites. PHP FPM (FastCGI Process Manager) is one such tool that speeds up PHP sites.

See how we help web hosting companies

Recently, we were contacted by a web host who was worried that the PHP sites in his server had stopped working fine and was showing ‘503 temporarily unavailable’ error. Upon investigating the server, we could see that it was configured to use PHP-FPM.

The FastCGI Process Manager (PHP-FPM) was configured in the server to reduce the amount of system resources used by web server. The web server acts as a proxy and passes only files ending with the .php file extension to PHP-FPM.

Using PHP-FPM also allows each virtual host to be configured to run PHP code as individual users, similar to the feature provided by SuPHP. But any issue with the PHP-FPM can cause PHP sites to stop working.

To pin point that the issue is due to PHP-FPM and to get the sites back to working, we immediately switched the PHP handler to Fast-CGI and minimised the website downtime.

[ You don’t have to lose your sleep over server errors. Our expert hosting specialists are online 24/7/365 to help you fix all server errors. ]

How to resolve when PHP sites running on PHP-FPM stop working

PHP-FPM works with the concept of pools, using which we can control the amount of resources dedicated to each virtual host, and also run PHP scripts as different users.

The FCGI URL in the virtual host entry would have this pattern, and it must contain the exact path to the document root.

ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/mysite/$1

This given directive forwards all requests for “.php” files to FCGI server at 127.0.0.1:9000 as that is where the PHP FPM process manager would be running.

When a web server related issue happens, we first recreate the issue and then scan the error logs to detect the reason for the issue. We’ve come across different causes for the PHP FPM to mess up sites.

  1. Load the correct configuration file – Each domain has a virtual host file, which needs to be configured with the settings for its custom PHP-FPM pool. If this config file is not properly detected by the web server or settings are made in different file, it may not work fine.
  2. Permissions of socket file – FPM process manager can either listen to a socket in the server or a TCP port. If the socket doesn’t have adequate permissions or if the port is not accepting connections, FPM cannot work.
  3. Ensure that the settings in the config file are correct – The main settings in a virtual host are the ServerName (domain name) and the DocumentRoot (locations for domain files). For PHP-FPM, there is a directive called ‘ProxyPassMatch’, which helps it to act as a reverse proxy to handle web server requests coming to default web server port 80. If any of these directives are wrongly configured, it can cause PHP sites to stop working.

Upon detailed investigation in the server, we could see that the connections for the localhost to the FPM port was not working fine, which caused the sites to stop working.

After allowing the connectivity to the FPM port in the server firewall and updating the port correctly in the config file, the site started loading with PHP-FPM.

[ Use your time to build your business. We’ll take care of your customers. Hire our hosting support experts to maintain your servers secure and stable 24/7 . ]

At Bobcares, our 24/7 server specialists constantly monitor all the services in the server and proactively audit the server for any errors or corruption in them.

With our systematic debugging approach for service or other software errors, we have been able to provide an exciting support experience to the customers.

If you would like to know how to avoid downtime for your customers due to errors or other service failures, we would be happy to talk to you.

 

BOOST YOUR HOSTING BUSINESS!

Never again lose customers to server errors! Sign Up once. Enjoy Peace Of Mind For Ever!

CLICK HERE FOR WORLD-CLASS HOSTING SUPPORT

var google_conversion_label = "zWG9CLOojHIQ0aD71QM";

0 Comments

Submit a Comment

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

Categories

Tags