How to use yum to install PHP environment

PHPz
Release: 2023-04-10 11:27:08
Original
2907 people have browsed it

On Linux servers, PHP is a very popular programming language used for web application development. This article will introduce how to use yum to install the PHP environment.

1. Update yum

Open the terminal and execute the following command to update yum:

sudo yum -y update
Copy after login

2. Install PHP

Execute the following command to install PHP:

sudo yum -y install php
Copy after login

If you need to install other PHP modules, you can execute the following command to search for the modules you need:

sudo yum search php-
Copy after login

For example, if you need to install the MySQL module:

sudo yum -y install php-mysql
Copy after login

3. Check PHP version

After the installation is complete, you can check the PHP version to ensure that PHP is installed correctly:

php -v
Copy after login

Output example:

PHP 7.2.10 (cli) (built: Aug 14 2018 21:39:14) ( NTS )
Copy after login

4. Configure PHP

By default, PHP uses the Apache server. If you are using a different server, additional configuration may be required.

To configure PHP, edit the php.ini file:

sudo vi /etc/php.ini
Copy after login

You can change the following settings as needed:

  • memory_limit - The maximum memory usage allowed by PHP
  • file_uploads - Maximum size of files allowed to be uploaded
  • upload_max_filesize - Maximum size of files allowed to be uploaded

When finished, save and close the file.

5. Restart the server

After completing all configurations, you must restart the server for the changes to take effect:

sudo systemctl restart httpd
Copy after login

6. Test PHP

In your Test your PHP installation by entering the following URL address in a web browser:

http://server-ip-address/info.php
Copy after login

where "server-ip-address" is the IP address of your server. After entering this URL address, information about your PHP installation and server configuration should be displayed.

Conclusion

Using yum to install the PHP environment is very simple and fast. Unlike manual installation, yum can handle dependencies and automatically install necessary packages and library files. This makes the installation and configuration of PHP on a Linux server very easy.

The above is the detailed content of How to use yum to install PHP environment. 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template