Most PHP programmers are very familiar with XAMPP – a web server program widely used on operating systems like Linux, MacOS, Windows, Cross-platform, and Solaris. It is incredibly easy to install, requiring just a download and run. However, during the working process, many of you may have encountered error messages indicating that the port is already occupied, preventing Apache from starting.
Today, I would like to share with you some common causes and solutions I have encountered while working with XAMPP.
1. Check which program is occupying port 80
First, to check the simplest way to see which program is using port 80, you can open XAMPP and go to Netstat. Here, you can see the processes occupying port 80. Some common ones include Skype, Microsoft SQL Server for those programming in C#, VB.NET, ASP.NET, or VMWare for virtual machine software.
2. Fixing errors related to Skype, IIS, and VMWare
For versions of Skype prior to 2018, simply close the Skype application. However, versions from 2019 onwards are no longer affected by this issue.
To fix errors related to these applications, follow these steps:
Press Ctrl + Shift + Esc key combination to open Task Manager.
Switch to the Details tab.
Look for processes that may be using port 80 in list (2). Check if it matches the process causing the problem.
If so, select the process and click End Task to end the process.
Note that terminating a process can have side effects. So be careful and make sure to kill the right processes that are causing the error.
3. Another case
Step 1: Open the Start menu and type “RegEdit”.
Step 2: Enter the path HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP in the Registry Editor.
Step 3: Double-click on the “Start” entry.
Step 4: Set the value to 4 and click “OK”.
Step 5: Restart your computer to apply the changes.
Please note that modifying the Windows Registry can have serious consequences if not done correctly. Ensure that you follow the instructions carefully and consider creating a backup of your registry before making any changes.
4. Changing the port
If you have followed all the previous steps and still cannot change the port or if you want to run multiple programs with port 80 simultaneously, there is another option to change the port for Xampp.
Step 1: Open Xampp and go to the “config” folder.
Step 2: Locate the “apache” folder and open the “httpd.conf” file.
Step 3: Press Ctrl + H or Ctrl + F to find all instances of port 80 and replace them with port 8000 or 8800.
Step 4: Select the “Config” button in the top-right corner and go to “Service and Port Settings.”
Step 5: Change the main port from 80 to 8000 or 8800, matching the port you just changed in the file.
Step 6: Restart Apache. Step 7: Congratulations! You have successfully changed the port.
Note: After changing the port, you will need to access your applications using the new port number. For example, if you changed the port to 8000, you would access your application by typing “localhost:8000” in your web browser.