Linux Standalone PHP

Table of contents

  1. Overview
  2. Install System Dependencies
  3. Install PHP 8.4
  4. Install Composer
  5. Install Node.js & NPM
  6. Project Setup


1. Overview Table of Contents

This guide walks through setting up your the Chappy.php framework on Ubuntu (22.04 LTS), Debian (LMDE), and RHEL (Rocky Linux 9) based distributions without requiring XAMPP, Nginx, or Apache. The framework is self-hosted using PHP’s built-in development server (php console serve).

Requirements

  • PHP 8.4
  • Composer
  • Node.js & NPM
  • Git (for cloning the repository)


2. Install System Dependencies Table of Contents

First, update your system and install essential dependencies:

Debian (LMDE)

sudo apt update && sudo apt upgrade -y
sudo apt install -y curl wget git unzip

RHEL

sudo dnf update -y
sudo dnf install -y curl wget git unzip

Ubuntu

sudo apt update && sudo apt upgrade -y
sudo apt install -y curl wget git unzip software-properties-common


3. Install PHP 8.4 Table of Contents

A. Debian (LMDE)**

1. Add the SURY repository (trusted PHP repo for Debian)

sudo apt install -y lsb-release apt-transport-https ca-certificates wget gnupg2

Then import the GPG key:

wget -qO - https://packages.sury.org/php/apt.gpg | sudo tee /etc/apt/trusted.gpg.d/php.gpg >/dev/null

Now add the repo to your sources list:

echo "deb https://packages.sury.org/php/ bookworm main" | sudo tee /etc/apt/sources.list.d/php.list


Configure upload size For profile image upload support. Edit the file:

Ubuntu & Debian

sudo vi /etc/php/8.4/cli/php.ini

Rocky Linux (RHEL-based)

sudo vi /etc/php.ini

Then modify the following settings:

Setting What it controls Safe recommended value
upload_max_filesize Max size of a single uploaded file 5M (or 10M if high-res image uploads)
post_max_size Max size of total POST body (form fields + files) 8M (or 15M if upload_max_filesize is 10M)
max_execution_time Max script run time (seconds) 30 to 60
memory_limit Max memory a script can use 128M (or 256M for image-heavy apps)

These value should be set depending on what type of files being uploaded. Files such as videos should be much higher. post_max_size should be greater than upload_max_filesize. Otherwise, you will get a corrupted token error instead.


2. Update and install PHP 8.4

sudo apt update && sudo apt upgrade -y
sudo apt install -y php8.4 php8.4-cli php8.4-mbstring php8.4-xml php8.4-curl php8.4-zip php8.4-sqlite3 php8.4-bcmath


B. RHEL

sudo dnf install -y epel-release
sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-9.rpm
sudo dnf module list php                    # List available PHP modules
sudo dnf module enable php:remi-8.4 -y      # Enabled PHP 8.3 from Remi repo
sudo dnf install -y php php-cli php-mbstring php-xml php-curl php-zip php-sqlite3 php-bcmath


C. Ubuntu

sudo add-apt-repository ppa:ondrej/php -y
sudo apt update && sudo apt upgrade -y
sudo apt install -y php8.4 php8.4-cli php8.4-mbstring php8.4-xml php8.4-curl php8.4-zip php8.4-sqlite3 php8.4-bcmath


Verify installation:

php -v


4. Install Composer Table of Contents

Composer is required to manage PHP dependencies.

1: Download and Install Composer

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

2: Verify Installation

composer -v


5. Install Node.js & NPM Table of Contents

Use NodeSource to install the latest stable Node.js version.

1: Add Node.js Repository

Debian (LMDE) and Ubuntu

curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -

RHEL

curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash -


2: Install Node.js & NPM

Debian (LMDE) and Ubuntu

sudo apt install -y nodejs

RHEL

sudo dnf install -y nodejs


3: Verify Installation

node -v
npm -v


6. Project Setup Table of Contents

Navigate to your preferred development directory and clone the project:

1. Cloning The Project

Run the following commands (replace my-app with the name of your project):

mkdir repos
cd repos/
composer create-project chappy-php/chappy-php my-app


2. Open Project

Open project with your favorite IDE (We use VSCode)

3. Vite

Run:

npm run dev

4. Run Project

Open new terminal tab and run:

php console serve
  • B. Navigate to http://localhost:8000