Net2Secure: A Leading Data Center Service Provider in India

Category: Plesk /

How to Enable Nginx with PHP-FPM on Plesk?


Reading time: 4 minutes

Running PHP applications is made more solid by pairing Nginx with PHP-FPM, FastCGI Process Manager. It has a smaller environmental impact and is faster and more effective. In this post, you will learn how to enable Nginx with PHP-FPM to run on a Plesk server, allowing your websites to reap the benefits of this combination.

Here are the prerequisites:

Step-by-Step Guide to Enable Nginx with PHP-FPM on Plesk

Step: 1: Update Plesk

Before doing any modifications, make sure to check whether your Plesk installation is up to date or not.

1. First, log in to your Plesk control panel
2. Navigate to tools & settings > updates>update components
3. If updates are available, apply them and restart Plesk

Step 2: Enable Nginx Support

Plesk supports Nginx in two modes: As a reverse proxy for Apache ( Apache & Nginx) or as an individual web server (Nginx only). We will concentrate on using Nginx as a reverse proxy:

1. In Plesk, go to Tools & Settings>Server Settings>Web Server
2. Under “Web server mode, “select” Apache & Nginx reverse proxy mode.”
3. Now, click Apply to save the changes.

Step 3: Configure PHP-FPM

Now, set up PHP-FPM

1. Go to the Tools & Settings > PHP Settings
2. Click on the PHP versions tab
3. For each PHP version you want to use with FPM

Step 4: Enable Nginx and PHP-FPM for Certain Domains

To use Nginx with PHP-FPM for individual domains:

1. Visit the websites & domains and choose the desired domain
2. Click on “Hosting Settings.”
3. Set the web server to Nginx and Apache
4. For “PHP support, pick the PHP-FPM application server
5. Consider the desired PHP version
6. Now, click OK to apply the changes.

Step 5: Optimize Nginx and PHP-FPM Configuration

For optimal performance, do the following adjustments:

  1. Nginx Configuration:
    Go to Tools & Settings > Server Settings > Web Server Settings
    Click on the Additional nginx directives tab
    Add performance-increasing directives, such as

    Client_max_body_size 50M;
    Client_body_buffer_size 128k
  2. PHP-FPM Configuration:
    Go to Tools & Settings > PHP Settings
    Click on the “Additional directives” tab for the desired PHP version
    Add optimisations like

    pm=dynamic
    pm.max_children=50
    pm.start_servers=5
    pm.max_spare_server=35

    Manage these values based on your server’s resources and traffic patterns.

Step 6: Restart Services

After making configuration changes:

1. Go to Tools & Settings > Server Management > Services Management.
2. Restart the following services:
- Nginx
- Apache
- PHP-FPM (for each version you've modified)

Step 7: Verify the Configuration

To ensure Nginx and PHP-FPM are working correctly:

1. Create a test PHP file (e.g., info.php) in your domain's document root with the following content:

<?php
// Show all information, defaults to INFO_ALL
phpinfo();


// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_MODULES);


?>

2. Access this file through your browser
3. Check that the "Server API" field shows "FPM/FastCGI."

Now Troubleshooting:

In case you face any issues, try the following:

1. Check Plesk logs:
- Go to Tools & Settings > Server Management > Logs.
- Review Nginx, Apache, and PHP-FPM logs for errors.

2. Verify PHP-FPM processes:
- Connect to your server via SSH.
- Run: `ps aux | grep php-fpm` to ensure PHP-FPM processes are running.

3. Test Nginx configuration:
- In SSH, run: `nginx -t`
- This will check for syntax errors in the Nginx configuration.

4. Restart services:
- If you've made manual changes, restart Nginx, Apache, and PHP-FPM services as described in Step 6.

Thus, shifting to Nginx with PHP-FPM on Plesk can improve website performance along with sparing server resources. This guide will assist you in building a solid web-serving stack, created for effectively handling heavy traffic. Be mindful of your setup, adjust as required, and regularly update your system for maximum performance and safety.

Contact Us


We use cookies

By continuing to browse this site, you are agreeing to the use of cookies to enhance your experience.