Current Location: Home> Latest Articles> Complete Guide to Installing and Configuring PHP Environment with YUM on Linux

Complete Guide to Installing and Configuring PHP Environment with YUM on Linux

gitbox 2025-06-16

This article will provide a detailed guide on how to install and configure a PHP environment on Linux using the YUM tool. Whether you're a beginner developer or an experienced system administrator, this guide will walk you through the steps to quickly set up your PHP development environment.

What is YUM?

YUM (Yellowdog Updater Modified) is a package management tool used in RPM-based Linux distributions (such as CentOS, Red Hat, etc.). It helps users easily install, update, and remove software packages. In this tutorial, we will use YUM to install PHP and its related extensions.

Preparation

Before starting the installation, make sure you have administrator privileges and your system is up to date. Use the following command to update your system:

sudo yum update

Installing PHP and Related Extensions

Next, we will proceed with installing PHP and its related extensions. You can follow these steps:

Step 1: Install the EPEL Repository

In many cases, you will need to install the EPEL (Extra Packages for Enterprise Linux) repository, which contains additional software packages. Use the following command to install EPEL:

sudo yum install epel-release

Step 2: Install PHP

After installing the EPEL repository, you can proceed to install PHP and its core modules by running the following command:

sudo yum install php php-cli php-common

If you need additional PHP extensions, such as MySQL support, image processing, etc., you can install other PHP modules using the following command:

sudo yum install php-mysql php-gd php-xml

Step 3: Verify Installation

Once the installation is complete, you can verify PHP installation by running the following command:

php -v

This command will display the version of PHP, ensuring that everything was installed correctly.

Configuring PHP

After installing PHP, you may need to configure it for your specific needs. The PHP configuration file is usually located at:

/etc/php.ini

You can edit this file to adjust settings such as memory limits, file upload size, etc. Use the following command to open the file:

sudo vi /etc/php.ini

Restarting the Web Server

After making the necessary configurations, restart your web server to apply the changes. If you're using Apache, use the following command:

sudo systemctl restart httpd

Conclusion

Following these steps, you should be able to successfully install and configure the PHP environment on your Linux system using YUM. This provides a stable and easy-to-maintain foundation for developing and managing PHP applications. If you run into any issues during the process, feel free to seek help.

With proper management and configuration, your PHP environment will be more efficient. We hope this guide helps you set up your PHP environment with ease!