Current Location: Home> Latest Articles> Comprehensive Guide to Installing PHP 5.4 on Linux

Comprehensive Guide to Installing PHP 5.4 on Linux

gitbox 2025-08-04

Preparation for Installing PHP 5.4 on Linux

Many developers and system administrators need to install PHP 5.4 on Linux systems. This guide provides comprehensive steps to help you quickly set up a PHP environment that meets your requirements.

Update the System

Before starting, make sure your system package information is up to date. Open the terminal and run:

<span class="fun">sudo apt-get update</span>

Install Required Dependencies

PHP 5.4 depends on several libraries and extensions. Use the following command to install the necessary components:

<span class="fun">sudo apt-get install build-essential libxml2-dev libcurl4-openssl-dev pkg-config</span>

Download PHP 5.4 Source Code

Download the PHP 5.4 source package from the official PHP archive:

<span class="fun">wget http://museum.php.net/php5/php-5.4.48.tar.gz</span>

Extract the Source Package

After downloading, extract the files:

<span class="fun">tar -xzvf php-5.4.48.tar.gz</span>

Compile and Install PHP

Enter the extracted directory and run the configuration command:

cd php-5.4.48
./configure --with-config-file-path=/usr/local/lib --enable-mbstring --with-curl

Next, compile the source code:

<span class="fun">make</span>

After compilation, execute the installation:

<span class="fun">sudo make install</span>

Configure PHP Environment

Once installed, copy the development configuration file as the base:

<span class="fun">sudo cp php.ini-development /usr/local/lib/php.ini</span>

Edit the configuration file with a text editor to adjust settings such as timezone and error reporting as needed:

<span class="fun">sudo nano /usr/local/lib/php.ini</span>

Verify the Installation

Confirm the PHP 5.4 version by running:

<span class="fun">php -v</span>

If the version shows 5.4.x, the installation was successful.

Summary

This guide covers the entire process from environment preparation to final verification. Mastering these steps will help you successfully set up PHP 5.4 on Linux, providing a stable foundation for your development work.