Home  >  Article  >  Backend Development  >  How to install php on Red Hat Linux (tutorial)

How to install php on Red Hat Linux (tutorial)

PHPz
PHPzOriginal
2023-04-12 13:58:01857browse

When we need to develop PHP or run PHP applications on the Red Hat operating system, we first need to install PHP in the system. Before installing PHP, you need to know the currently running operating system version, the running architecture, the required version of PHP and other information.

The following are simple steps to install php on Red Hat operating system.

  1. Confirm the system version and architecture

Run the following command in the command line to view the current system version and architecture information:

$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.6 (Maipo)

$ uname -r
3.10.0-957.el7.x86_64

From the above output you can It can be seen that the current system is Red Hat Enterprise Linux version 7.6, running the x86_64 architecture.

  1. Install warehouse

Installing PHP requires the use of warehouse sources, so we need to install the corresponding epel warehouse sources. Run the following command in the command line:

$ sudo yum install epel-release

After the installation is completed, we can use the command to query the published epel warehouse source information.

$ sudo yum repolist | grep epel
  1. Install php

Before installing php, you need to install some dependency packages. You can use the following command to install:

$ sudo yum -y install httpd httpd-devel
$ sudo yum -y install php php-cli php-common php-devel php-mysql php-pdo php-pear php-xml php-xmlrpc
  1. Verify PHP installation

After the installation is complete, we can use the following command to verify whether PHP is installed successfully:

$ php -v
PHP 7.2.18 (cli) (built: Apr  2 2019 13:08:50) ( NTS )
Copyright (c) 1997-2018 The PHP Group

If the version information can be printed out, it means PHP has been installed successfully.

  1. Configuring php

By default, php is automatically enabled in Red Hat Enterprise Linux Servers systems. But we still need to make some configurations in the configuration file /etc/php.ini.

For example, if we want to change the maximum upload file size requested by php, we can use a text editor edit to modify the following lines in the /etc/php.ini file :

; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 2M

After completing the above configuration, we need to restart the server to make the configuration take effect:

$ sudo systemctl restart httpd

At this point, we have successfully installed and configured php on the Red Hat operating system.

Summary

This article shows the steps to install and configure PHP on Red Hat operating system. In actual development and operation, more configuration and details are required. But through this article, you can learn how to install and configure PHP on the Red Hat operating system, providing reference and guidance for subsequent development and operation.

The above is the detailed content of How to install php on Red Hat Linux (tutorial). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn