How to install php on Red Hat Linux (tutorial)

PHPz
Release: 2023-04-12 14:22:10
Original
810 people have browsed it

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
Copy after login

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
Copy after login

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

$ sudo yum repolist | grep epel
Copy after login
  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
Copy after login
  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
Copy after login

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 editoreditto modify the following lines in the/etc/php.inifile :

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

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

$ sudo systemctl restart httpd
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!