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
2. Install PHP
Execute the following command to install PHP:
sudo yum -y install php
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-
For example, if you need to install the MySQL module:
sudo yum -y install php-mysql
3. Check PHP version
After the installation is complete, you can check the PHP version to ensure that PHP is installed correctly:
php -v
Output example:
PHP 7.2.10 (cli) (built: Aug 14 2018 21:39:14) ( NTS )
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
You can change the following settings as needed:
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
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
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!