How To Change Apache and MySQL Ports in XAMPP
For certain purposes such as installing two versions of PHP or Install XAMPP More Than One on One Computer, we need to change apache and MySQL port, which for some people it is complicated and difficult to do, therefore, today we’ll discuss how to do that.
How To Change Apache Port in XAMPP
Changing the apache port can’t be done through XAMPP Control Panel, maybe you want to open the config menu located on the upper right corner, but the notice that appears tell us that we have to change the apache port through the configuration file.
In apache, there are two important ports: HTTP port with 80 as the default value and the SSL port at the default value of 443. When the apache module is starting, it will automatically activate both ports, so to change the HTTP port, we also have to change the SSL port, otherwise, it will trigger an error message.
How To Change HTTP Port
To change the HTTP port, open the http.conf file (apache config file) located in the
apache/conf directory, find words like “Listen 80” and “ServerName localhost: 80” then change number 80 to the desired port number, eg 7777, the number must be greater than 1024.
If you install apache from other packages such as WAMPP or the install the apache software directly, you can find the configuration through find files and folder features provided by Windows.
How to Change SSL Port
To change the SSL port, open the httpd-ssl.conf in the
apache\conf\extra directory, then find words that contain number 443 (eg: Listen 443 and ServerName localhost: 443), change 443 with other numbers eg: 444, then save the file.
How to Change MySQL Port
MySQL uses 3306 as it’s default port.
As Apache port, we also can NOT change the MySQL port through the XAMPP Control Panel, to change it we have to edit MySQL configuration file.
To edit the configuration file, open my.ini file located in the XAMPP/mysql/bin/ directory, find words that contain number 3306, eq: port = 3306, then replace it with your own, such as 3307.
Congratulation, now you successfully change the Apache and MySQL ports in XAMPP.