Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
Google Cloud Platform icon
Labs

Installing and Configuring PHP-FPM on Ubuntu Linux

Before we can start building our world-changing website or application on LEMP, we have to lay the foundation for the stack. In this hands-on lab, we will walk through installing and configuring PHP-FPM on Ubuntu Linux. When the lab is complete, we will have a configured PHP-FPM installation on Ubuntu Linux.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Intermediate
Last updated
Sep 09, 2025
Duration
30m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Validate That the NGINX Server Is Installed, Enabled and Running

    Become root:

    sudo su -
    

    Check the status of the nginx service:

    systemctl status nginx
    

    The service should be enabled and running.

    Verify that we can load the default NGINX web page using curl:

    By Public IP:

    curl http://`cat /tmp/public_ip.txt`
    

    By Public DNS:

    curl http://`cat /tmp/public_dns.txt`
    
  2. Challenge

    Install PHP-FPM

    Install PHP-FPM using apt-get:

    apt-get -y install php-fpm
    

    Validate that the php7.2-fpm service is running, using systemctl:

    systemctl status php7.2-fpm.service
    

    The service should be enabled and running.

  3. Challenge

    Test Access PHP Pages Using NGINX

    We have two pre-configured PHP pages in /usr/share/nginx/html/. Let's take a look at them:

    more /usr/share/nginx/html/*.php
    

    Now, try accessing the PHP files via NGINX:

    curl http://`cat /tmp/public_dns.txt`/info.php
    
    curl http://`cat /tmp/public_dns.txt`/hello.php
    

    We can see the contents, but the PHP code is not being executed. Try accessing the PHP files at http://PUBLIC_DNS/info.php and http://PUBLIC_DNS/hello.php with a web browser.

  4. Challenge

    Configure NGINX to use php-fpm to Process PHP Pages

    We need to add a configuration block to the /etc/nginx/conf.d/default.conf file, so that NGINX uses php-fpm to process PHP pages:

    vi /etc/nginx/conf.d/default.conf
    

    After the location / block, add the following:

     location ~ \.php$ {
         fastcgi_pass unix:/run/php/php7.2-fpm.sock;
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
         include fastcgi_params;
         include snippets/fastcgi-php.conf;
     }
    
  5. Challenge

    Validate and Activate PHP Configuration

    Before we reload NGINX, we need to validate the configuration:

    nginx -t
    

    Once everything checks out, reload the configuration:

    systemctl reload nginx
    

    Make sure NGINX is running:

    systemctl status nginx
    
  6. Challenge

    Test Access PHP Pages Using NGINX with PHP-FPM

    Now, let's try accessing the PHP files via NGINX:

    curl http://`cat /tmp/public_dns.txt`/info.php
    
    curl http://`cat /tmp/public_dns.txt`/hello.php
    

    Now the PHP code is not being executed. You can try accessing the PHP files at http://PUBLIC_DNS/info.php and http://PUBLIC_DNS/hello.php with your web browser.

About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight