Although newer PHP versions are available, some projects still require PHP 5.4. This article provides a clear and detailed installation process to help you successfully set up the required PHP environment on your CentOS system.
Before starting the installation, it is recommended to update your CentOS system to ensure all packages are up-to-date and to avoid dependency conflicts. Run the following command to update the system:
<span class="fun">sudo yum update</span>
Before installing PHP 5.4, you need to install some required dependencies including the EPEL repository and development tools. Execute the following commands to install them:
sudo yum install epel-release
sudo yum install httpd gcc libxml2-devel bzip2-devel curl-devel \
readline-devel autoconf automake make
PHP 5.4 is not included in the default CentOS repositories, so we need to use a third-party repository, here we use the Remi repository. First, install the Remi repository RPM package:
<span class="fun">sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm</span>
After installing the Remi repository, enable the PHP 5.4 repository with the following command:
<span class="fun">sudo yum-config-manager --enable remi-php54</span>
Now, you can install PHP 5.4 and its basic modules:
<span class="fun">sudo yum install php</span>
After installation, verify the PHP version to confirm successful installation by running:
<span class="fun">php -v</span>
If you see PHP version 5.4.x information, the installation was successful.
Depending on your project needs, you may want to adjust the PHP configuration. The configuration file is usually located at /etc/php.ini. You can edit it with your preferred editor:
<span class="fun">sudo vi /etc/php.ini</span>
Following these steps, you have successfully installed and configured PHP 5.4 on your CentOS system. Although newer PHP versions offer more features and security, some projects still rely on this older version. Hopefully, this guide will help you set up your development environment effectively.