Home > Article > Backend Development > How to install apache+php+mysql on centos
CentOS is a popular Linux distribution that many web developers choose to use to deploy web applications or websites. A common deployment method is to use the Apache, PHP and MySQL technology stack. In this article, we will discuss how to install these technologies on CentOS so that you can quickly build your website.
1. Update 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
This command will list all the packages on your system that need to be updated. Press the Y key to update.
2. Install Apache
Apache is one of the most popular web servers, and many web applications run on this server. To install Apache on CentOS, run the following command:
sudo yum install httpd
This command will install Apache on your system. After installation, run the following command to start the Apache service:
sudo systemctl start httpd
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
MySQL is a popular relational database that many web applications require to store data. To install MySQL on CentOS, run the following command:
sudo yum install mysql-server mysql
This command will install the MySQL server and MySQL client on your system. After installation, please run the following command to start the MySQL service:
sudo systemctl start mysqld
To create a new user in MySQL, please run the following command:
sudo mysql_secure_installation
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
This command will install PHP and its extensions on your system. Make sure PHP can communicate with the MySQL server by installing 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
Enter the following in the file:
<?php phpinfo(); ?>
Save and exit the file. Enter your server's IP address or domain name into your web browser and append the file name of this file. For example, if your file is called info.php, enter in the browser:
http://your_server_ip/info.php
If you see PHP information, you have successfully installed Apache, PHP and MySQL.
Summary
It is very easy to install Apache, PHP and MySQL on CentOS. By following the steps above, you can quickly run a PHP website and start developing web applications. If you need more configuration, check out the industry standard documentation and official documentation for help.
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!