How to Install FrankenPHP App Server in Ubuntu 24.04

FrankenPHP is a modern application server for PHP that enhances the performance and capabilities of PHP applications. It is built on top of another server called Caddy web server, which helps developers to run PHP applications efficiently without the need for traditional web servers like Apache or Nginx.

FrankenPHP can make your PHP applications run faster by keeping your application in memory after the first load, so it doesn’t have to start from scratch with every request, which can lead to significant speed improvements.

With FrankenPHP, you don’t need to set up separate processes like PHP-FPM (FastCGI Process Manager) and a web server like Nginx or Apache. Everything runs in one place, making it easier to manage.

This guide walks you through the process of installing FrankenPHP on Ubuntu 24.04 in simple steps.

Step 1: Install PHP in Ubuntu 24.04

First, start by updating your system packages to ensure you have the latest software.

sudo apt update
sudo apt upgrade -y

Next, you need to install some essential packages, including PHP and other required libraries.

sudo apt install zip unzip curl -y

Once the required dependencies are installed, you can install PHP 8.4 from Ondrej’s PPA, which provides the latest versions of PHP.

sudo add-apt-repository ppa:ondrej/php -y
sudo apt update
sudo apt install php8.4 php8.4-cli php8.4-fpm php8.4-{bz2,curl,mbstring,intl,xml} -y
php -v

Step 2: Install FrankenPHP in Ubuntu 24.04

Now that PHP is installed, you can proceed with installing FrankenPHP using the following curl command.

curl https://frankenphp.dev/install.sh | sh
sudo mv frankenphp /usr/local/bin/
Install FrankenPHP in Ubuntu
Install FrankenPHP in Ubuntu

Step 3: Running Your PHP Application

To serve your PHP application using FrankenPHP, create a directory and a simple php script for your web application.

mkdir -p ~/my-app && cd ~/my-app
echo '<?php echo "Hello, FrankenPHP!"; ?>' > index.php

To serve the content of the current directory, run:

sudo frankenphp php-server

Open your browser and navigate to the following address to see the message “Hello, FrankenPHP!“.

http://localhost/
Or
http://ip-address/
Verify FrankenPHP in Ubuntu
Verify FrankenPHP in Ubuntu

Step 4: Setting Up Nginx as a Reverse Proxy

Using a reverse proxy like Nginx improves request handling, adds an additional security layer, and simplifies SSL/TLS configuration.

sudo apt install -y nginx

Create a new configuration file.

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

Add the following configuration:

server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;

    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Replace yourdomain.com with your actual domain name.

Next, enable the configuration and reload nginx.

sudo ln -s /etc/nginx/sites-available/frankenphp /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Step 5: Configure SSL/TLS for Secure Connections

To ensure FrankenPHP performs efficiently and securely in a production environment, you need to install Certbot, which is a popular tool for obtaining and renewing free SSL certificates from Let’s Encrypt.

sudo apt install -y certbot
sudo apt install -y python3-certbot-nginx
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
sudo certbot renew --dry-run
Conclusion

FrankenPHP is now installed and running on your Ubuntu 24.04 system. By following these steps, you’ve set up a high-performance PHP runtime suitable for modern web applications.

For advanced configurations, refer to the FrankenPHP documentation.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Ravi Saive
I am an experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.