How to correctly install PHP and MySQL in Red Hat?

PHPz
Release: 2024-03-06 16:16:01
Original
700 people have browsed it

Red Hat中如何正确安装PHP和MySQL?

Red Hat is a commonly used Linux operating system, and many websites and applications run on Red Hat systems. It is very important to install PHP and MySQL correctly in a Red Hat system because they are the basis of many web applications. This article will introduce how to correctly install PHP and MySQL in Red Hat systems and provide detailed code examples.

Step one: Install PHP

  1. Log in to the system as root user:
sudo su
Copy after login
  1. Update the system:
yum update
Copy after login
  1. Install PHP and related extensions:
yum install php php-mysql php-common php-gd php-xml php-mbstring
Copy after login
  1. Check the PHP version:
php -v
Copy after login
  1. Start PHP:
systemctl start php-fpm
Copy after login
  1. Set PHP to start automatically at boot:
systemctl enable php-fpm
Copy after login

Step 2: Install MySQL

  1. Install MySQL database server:
yum install mysql-server
Copy after login
  1. Start MySQL:
service mysqld start
Copy after login
  1. Set MySQL to start automatically at boot:
chkconfig mysqld on
Copy after login
  1. Use the MySQL security script to set up MySQL Security:
mysql_secure_installation
Copy after login

Next, some setting options will appear, which can be selected according to your needs.

Step 3: Test PHP and MySQL connections

  1. Create a test file test.php:
vim /var/www/html/test.php
Copy after login

Write the following content in the file:

Copy after login
  1. Enter the address of the test PHP file in the browser, such as http://yourdomain/test.php. If "Connected successfully" is displayed, it means that the connection between PHP and MySQL is normal.

Summary:
Through the above steps, we successfully installed PHP and MySQL in the Red Hat system and tested their connections. During the installation process, pay attention to the output of the monitoring console to ensure that there are no errors during the installation process. Proper installation and configuration of PHP and MySQL can provide powerful database support for websites and applications so that they can run normally.

The above is the detailed content of How to correctly install PHP and MySQL in Red Hat?. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!