Home > Database > Mysql Tutorial > How to install apache+php+mysql on centos

How to install apache+php+mysql on centos

PHPz
Release: 2023-05-31 10:16:48
forward
926 people have browsed it

1. Update your system

Before you begin, make sure to update your system on CentOS. To do this, open a terminal and run the following command:

sudo yum update
Copy after login

This command will list all the packages on your system that need to be updated. Press the Y key to update.

2. Install Apache

Many web applications run on one of the most popular web servers - Apache. To install Apache on CentOS, run the following command:

sudo yum install httpd
Copy after login

This command will install Apache on your system. After installation, run the following command to start the Apache service:

sudo systemctl start httpd
Copy after login

Enter the IP address or domain name of your server in your web browser, and you should be able to see the Apache default page.

3. Install MySQL

Providing data storage for many web applications is MySQL, a popular relational database. To install MySQL on CentOS, run the following command:

sudo yum install mysql-server mysql
Copy after login

With this command, you can install MySQL server and MySQL client on your system. After installation, please run the following command to start the MySQL service:

sudo systemctl start mysqld
Copy after login

To create a new user in MySQL, please run the following command:

sudo mysql_secure_installation
Copy after login

This command will prompt you to create the root user password, configure your MySQL server to improve its security. Just follow the prompts.

4. Install PHP

PHP is a server-side scripting language used to develop dynamic web applications. To install PHP on CentOS, run the following command:

sudo yum install php php-mysql
Copy after login

This command will install PHP and its extensions on your system. To ensure that PHP can communicate with the MySQL server, you need to install the php-mysql extension.

5. Test installation

To ensure that all components are installed successfully, you can create a test file to verify that they are functioning properly. Run the following command in the terminal to create a file:

sudo vi /var/www/html/info.php
Copy after login

Enter the following in the file:

<?php
phpinfo();
?>
Copy after login

Save and exit the file. Please enter the server's IP address or domain name into your web browser, followed by the file name of the desired file. Taking the file name as an example, if your file name is info.php, you can type in the browser:

http://your_server_ip/info.php
Copy after login

If you see PHP information, it means that you have successfully installed Apache, PHP and MySQL.

The above is the detailed content of How to install apache+php+mysql on centos. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
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