KOSUNI KOREA
Korean News in English
Technology

Building a Dynamic Web Server with PHP-FPM on Ubuntu

Published October 17, 2026 · 1 views
Building a Dynamic Web Server with PHP-FPM on Ubuntu

The Real Web Development Begins

Hello.

In our previous session, we installed Nginx on Ubuntu Server and operated our first static webpage directly.

However, up until now, we've only been displaying HTML files—static webpages.

Real blogs, online stores, or bulletin boards can't be built with simple HTML alone.

Features like user registration, login, posting content, and comments are required for interaction with users.

This is where PHP comes in.

In this session, we'll install PHP and PHP-FPM on Ubuntu Server and connect it with Nginx to create a dynamic website.


What Is PHP?

PHP is a programming language that dynamically creates web pages.

For example, the following features can all be implemented using PHP:

  • Login

  • User registration

  • Bulletin board

  • Online store

  • Blog

  • Admin panel

  • Comment system

  • Search functionality

In short, while HTML creates the visual layout of a page, PHP handles the actual functionality.

Many websites today run on PHP, including WordPress as a prominent example.


What Is PHP-FPM?

Previously, web servers often executed PHP directly.

However, nowadays most use PHP-FPM (PHP FastCGI Process Manager).

PHP-FPM is a program that executes PHP more quickly and efficiently.

Nginx doesn't execute PHP code directly; instead, it requests the work from PHP-FPM and delivers the results to users.

This setup offers superior performance and stability, making it the most commonly used method today.


Installing PHP

First, update your package list to the latest version.

sudo apt update

Now install PHP and PHP-FPM.

sudo apt install php php-fpm -y

The installation will complete in a few minutes.

Once done, your PHP execution environment is ready.


Verifying PHP Installation

Let's check the PHP version.

php -v

If installed correctly, you'll see version information like this:

PHP 8.x.x

If the version appears, installation was successful.


Checking PHP-FPM Service Status

PHP-FPM runs as a service.

To check its current status, run this command:

sudo systemctl status php8.3-fpm

The version may vary depending on your Ubuntu environment.

For example, it could be listed as:

  • php8.2-fpm

  • php8.3-fpm

  • php8.4-fpm

If everything is working correctly, you'll see the status active (running).


Enabling PHP-FPM to Start Automatically

Configure PHP-FPM to start automatically after server reboot.

sudo systemctl enable php8.3-fpm

Note that the service name may vary slightly depending on your version.


Connecting Nginx with PHP

So far, Nginx has only displayed HTML files.

To enable it to execute PHP files as well, we need to modify the configuration settings.

Open Nginx's site configuration file:

sudo nano /etc/nginx/sites-available/default

The PHP-related settings in this file are commented out by default.

To enable them, remove the comments and specify the PHP-FPM socket path used by Ubuntu.

Typically, Ubuntu uses a socket like this:

fastcgi_pass unix:/run/php/php8.3-fpm.sock;

After saving the configuration, run a syntax check.

sudo nginx -t

If no errors are found, apply the new settings:

sudo systemctl reload nginx

Now Nginx and PHP are connected.


Creating a PHP Test Page

To confirm everything is working, let's create a test file.

Navigate to the default web directory:

cd /var/www/html

Create a new test file:

sudo nano info.php

Add this content to the file:

<?php
phpinfo();
?>

Save and open in a browser at:

http://serverIP/info.php

If you see the PHP information screen, the connection was successful.


Understanding the phpinfo() Screen

The phpinfo() function displays current PHP environment details.

You can view:

  • PHP version

  • Installed extensions

  • Memory settings

  • Upload limits

  • Server information

This is very useful during development but should be removed from production servers for security reasons.


Delete the Test File After Testing

Once testing is complete, delete the info.php file to maintain security.

sudo rm /var/www/html/info.php

The phpinfo() page contains sensitive server information, so it's best not to leave it exposed in a live environment.


What Are PHP Extension Modules?

PHP provides various features through extension modules.

Examples include:

  • MySQL connection

  • Image processing

  • ZIP compression

  • XML processing

  • Multi-language support

In future sessions, when we install MySQL, we'll also install the PHP module for MySQL.


PHP and HTML Can Be Used Together

You can write both HTML and PHP within a single file.

For example:

<h1>Hello</h1>

<?php
echo "Ubuntu Server";
?>

<p>Website test.</p>

HTML and PHP can be freely combined, which is the standard structure used in most PHP websites.


What If PHP Doesn't Execute?

Sometimes browsers display raw PHP code instead of executing it.

If this happens, check these items:

  • Whether PHP is installed

  • Whether PHP-FPM is running

  • Whether Nginx configuration is correct

  • Whether you reloaded the configuration after changes

  • Whether the file has a .php extension

Checking these five points usually resolves the issue.


What We Learned Today

In this session, we installed PHP and PHP-FPM on Ubuntu Server and connected it with Nginx.

We've now moved beyond a simple HTML-only web server to one that can run actual programs.

In the next session, we'll install MySQL database to store data for features like bulletin boards or blogs.


Key Takeaways

  • PHP is a programming language used to create dynamic web pages.

  • PHP-FPM executes PHP more efficiently and quickly.

  • Nginx connects with PHP-FPM to execute PHP code.

  • You can verify installation using php -v.

  • The phpinfo() function shows the current PHP environment details.

  • Delete the test file info.php after testing for security reasons.

  • Your Ubuntu Server is now ready to host dynamic websites.


Next Session Preview

6th Lesson: Installing MySQL and Building a Database for Web Services

In the next session, we'll install MySQL and learn how to create databases and tables. We'll connect PHP with MySQL to build a data storage environment that forms the foundation of real web services.

FAQ

Why use PHP-FPM instead of direct PHP execution?

PHP-FPM improves performance and stability by managing PHP processes more efficiently, making it the standard choice for modern web servers.

What does phpinfo() do?

phpinfo() displays detailed information about your PHP environment, including version, extensions, memory settings, and server details. It's useful for development but should be removed from production sites.

Korean Source

This article is an English localization of a Korean-language report from BlogScore. Original: [Ubuntu 서버 구축] 5강. PHP-FPM 설치와 PHP 웹사이트 연동하기