Home  >  Article  >  Backend Development  >  How to modify php and mysql ports

How to modify php and mysql ports

zbt
zbtOriginal
2023-08-23 14:54:351622browse

Modify the php and mysql ports by modifying the configuration files of PHP and MySQL. Detailed introduction: 1. Modify the PHP port, open the PHP configuration file php.ini, and search for "; Listen for TCP/IP connections on port" in the php.ini file ; http://php.net/soap.wsdl-cache-dir ; soap.wsdl_cache_dir=”Wait.

How to modify php and mysql ports

The operating environment of this tutorial: windows10 system, php8.1.3 version, DELL G3 computer.

PHP and MySQL are two commonly used technology components when developing and deploying web applications. PHP is a server-side scripting language, while MySQL is a popular relational database management system. By default, PHP uses port 80 , MySQL uses port 3306. However, sometimes it is necessary to modify these default ports to suit specific needs. This article will introduce how to modify the ports of PHP and MySQL.

1. Modify the PHP port:

The default port of PHP is 80, which is the default port of the HTTP protocol. If you need to change the port of PHP to another port, you can follow the steps below:

a. Open PHP Configuration file php.ini. This file is usually located in the "conf" folder under the PHP installation directory.

b. Find the following lines in the php.ini file:

; Listen for TCP/IP connections on port
; http://php.net/soap.wsdl-cache-dir
; soap.wsdl_cache_dir=

Replace "; Listen for TCP/IP connections on Remove the comment from the "port" line and specify the port number to be used afterwards. For example, change the port number to 8080:

Listen for TCP/IP connections on port
http://php.net/soap.wsdl-cache-dir
; soap.wsdl_cache_dir=

c. Save and close the php.ini file.

d . Restart the web server for the modification to take effect.

2. Modify the MySQL port:

The default port of MySQL is 3306. If you need to modify the MySQL port to another port , you can follow the following steps:

a. Open the MySQL configuration file my.cnf. This file is usually located in the "etc" folder under the MySQL installation directory.

b. In my Find the following line in the .cnf file:

# The MySQL server
[mysqld]
port = 3306

Change the port number in the "port" line to the port number you want to use. For example, change the port number to 8888:

# The MySQL server
[mysqld]
port = 8888

c. Save And close the my.cnf file.

d. Restart the MySQL server to make the modifications effective.

It should be noted that after modifying the ports of PHP and MySQL, the configuration of the Web server needs to be modified accordingly file so that requests are correctly forwarded to the modified port. For example, if you use Apache as a web server, you need to modify the configuration in the httpd.conf file.

Summary:

This article introduces how to modify the ports of PHP and MySQL. By modifying the configuration files of PHP and MySQL, the default port can be modified to other ports to meet specific needs. After modifying the port, you also need to modify the Web server accordingly Configuration file to ensure that requests are correctly forwarded to the modified port .

The above is the detailed content of How to modify php and mysql ports. 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