Home  >  Article  >  Backend Development  >  Let’s talk about the installation tutorial of PHP and MySQL

Let’s talk about the installation tutorial of PHP and MySQL

PHPz
PHPzOriginal
2023-04-25 15:55:54760browse

With the continuous development of Internet technology, website development has become a very popular industry. In website development, PHP and MySQL are the two most commonly used technologies. This article will tell you about the installation tutorial of PHP and MySQL.

PHP Installation

1. Download PHP

First, we need to download PHP from the official website of PHP (http://www.php.net/downloads.php) latest version. Once the download is complete, we need to unzip the file.

2. Configure PHP

After decompression, we need to find the "php.ini-development" file in the decompressed directory and rename it to "php.ini". Then we need to edit the file, find the "extension_dir" item, and change its value to the absolute path of "ext".

3. Configure PHP and Apache

After installing PHP, we also need to configure PHP and the Apache server. Before doing this, we need to confirm whether the Apache server has been installed. If it is not installed, we need to download and install it from the Apache official website (http://httpd.apache.org/download.cgi). After installing Apache, we need to find the Apache configuration file httpd.conf and add the following content to it:

PHPIniDir points to the directory where the php.ini file is located

PHPIniDir “/path/to/ php”

Add the following code to associate PHP with Apache

LoadModule php5_module “/path/to/php/php5apache2_2.dll”
AddHandler application/x-httpd-php. php
PHPIniDir “/path/to/php”

4. Restart Apache

After the above configuration is completed, we need to restart the Apache server to ensure that the configuration takes effect. After commenting out the sentence "LoadModule php5_module", remove the first comment and save the file. After that, we can try to create a new php file in the root directory of localhost and enter the following code in it:

phpinfo();
?>

Save and open the file. If you see information that matches your PHP version, it proves that the PHP installation is successful.

MySQL installation

1. Download MySQL

Next we need to download from the official website of MySQL (https://dev.mysql.com/downloads/mysql/) The latest version of MySQL. After the download is complete, we need to unzip its installation package first.

2. Configure MySQL

After decompression is completed, we need to add the MySQL bin directory to the system environment variables. Then we need to enter the directory, find the my-default.ini file, and rename it to my.ini. After that, we need to make the following configurations in the my.ini file:

Add the MySQL installation directory to the PATH environment variable

PATH="%PATH%;C:\path -to\MySQL\bin”

MySQL startup method

basedir=C:\path-to\MySQL
datadir=C:\path-to\MySQL\data

Set the default encoding of MySQL to utf-8

character-set-server=utf8
collation-server=utf8_general_ci

The maximum number of connections allowed

max_connections=200

3. Start MySQL

After the above configuration is completed, we need to start MySQL. Open the command line, enter the bin directory where mysql is stored, and enter the "mysql_install_db" command. Then enter "mysqld –initialize" to initialize MySQL. Finally, we can enter "net start mysql" to start the MySQL service.

4. Set MySQL password

When starting MySQL for the first time, we need to set its password. Enter the following command:

mysqladmin -u root password password

If the prompt fails, we can try to reset the password from the following method:

Stop the MySQL service

Enter the "mysqld -nt --init-file=C:\mysql-init.txt" command. The file contains the SQL statements that need to be executed, such as "ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password'; ”

Restart the MySQL service

Finally, we can test whether MySQL can be used normally through the MySQL command line client.

Conclusion

PHP and MySQL are indispensable technologies in website development, and their installation and configuration are also an important part of website development work. The installation tutorial described in this article is for reference only. The specific installation and configuration steps may vary depending on the operating system and software version. If there is a problem, we can get more detailed installation instructions by reading the official documentation of the software.

The above is the detailed content of Let’s talk about the installation tutorial of PHP and MySQL. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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