How To Change Apache Http & SSL Ports in XAMPP

Changing default apache http & https ports including virtual hosts

Why change Apache Port

By Default, Apache runs HTTP on port 80 and SSL on port 443 in XAMPP. Generally, you may need to change the port number for the following reasons :

  • For customized network design.
  • For security purposes.
  • For resolving port conflicts with other applications.

For example, users commonly report a conflict between Skype and Apache both using port 80.

Checking port availability

Before you proceed, you should make sure that you have an available port and that the port you are choosing is free and not already occupied. Here is a list of a couple of tools you can use to find the status of ports on your localhost.

NetStat command on windows

On windows, you can use ‘netstat’ command to list active networks (incoming and outgoing) connections and listening ports. You can use the command with the following switches to print port status for your localhost:

netstat -ano
  • “a” will display all connections and listening ports.
  • “o” will show the owning process ID that is related to each of the connections.
  • “n” will show the addresses and port numbers as numerals.
blank

XAMPP’s in-built NetStat tool

If you prefer, you can use the ‘NetStat’ tool built inside the XAMPP itself. Behind the scene, it probably uses the same windows command and the output is almost the same as the native ‘NetStat’ command in windows.

blank

Windows Resource Monitor

The third option if you prefer is the windows ‘Resource Monitor’. You can launch the ‘Resource Monitor’ via the ‘Task Manager’ as shown in the below screenshot. Once you have launched ‘Resource Monitor’, you can view the port availability status under the ‘Listening Ports’ tab.

blank
blank

Changing Apache HTTP port

Edit the ‘httpd.conf’ file usually located inside “XAMPP\apache\conf\” on windows and make the following changes.

HTTP Listen Port

Current configuration
Listen 80
New configuration
Listen 8081
blank

HTTP ServerName and Port

Current configuration
ServerName localhost:80
New configuration
ServerName localhost:8081
blank

Changing Apache HTTPS (SSL) Port

Edit the ‘http-ssl.conf’ file usually located inside “XAMPP\apache\conf\extra” on windows and make the following changes

HTTPS Listen Port

Current configuration
Listen 443
New configuration
Listen 8082
blank

HTTPS ServerName and Port

Current configuration
ServerName www.example.com:443
New configuration
ServerName www.example.com:8082
blank

VirtualHost Directive for httpd-ssl

Current configuration
VirtualHost default:443
New configuration
VirtualHost default:8082
blank

Changing Ports for VirtualHosts

Edit the ‘httpd-vhosts.conf’ file usually located inside “XAMPP\apache\conf\extra” on windows and make the following changes:

HTTP Virtual Host URL

Current configuration
VirtualHost *: 80
New configuration
VirtualHost *: 8081
blank

HTTPS (SSL) Virtual Host URL

Current configuration
VirtualHost *: 443
New configuration
VirtualHost *: 8082
blank

Changing HTTP/HTTPS in XAMPP Panel

Now, we need to also update the above port numbers in XAMPP configuration, so that both XAMPP and Apache are able to communicate over the right port numbers. For this, do the following:

Launch XAMPP Configuration from XAMPP Control Panel

blank

From the ‘Configuration of Control Panel’ window click ‘Service and Port Settings to launch ‘Service Setting’

blank

On the ‘Service Settings’ window, enter Main Port and SSL Port number as set in previous steps. In our example here these would be Main Port: 8081 and SSL Port 8082.

blank

Make HTTP and HTTPS port changes Click Save to save service settings

blank

RESTART THE APACHE SERVICE! DONE!

Tushar Sharma
Tushar Sharmahttps://www.automationdojos.com
Hi! This is Tushar, the author of 'Automation Dojos'. A passionate IT professional with a big appetite for learning, I enjoy technical content creation and curation. Hope you are having a good time! Don't forget to subscribe and stay in touch. Wishing you happy learning!

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

RELATED POSTS

Why WordPress Installation Ends Up with latest version?

1. Why You Need Older WordPress Versions Of course, running the latest version of WordPress is the best option for any website, but at times,...

How To Configure Virtual Hosts in XAMPP

Apache has made it very easy to have multiple websites or web applications running on the same physical server, and access each using a...

How To Install XAMPP on Windows

What is XAMPP The full form of XAMPP stands for Cross-platform, Apache, MariaDB (MySQL), PHP and Perl. It is one of the simplest and lightweight...

How To Install WordPress Locally using XAMPP

1. Introduction Installing WordPress on your computer helps you try out WordPress, test themes and plugins, and learn WordPress development.  It lets you operate a...

Â

RECENT 'HOW-TO'

How To Install Oh-My-Posh On Windows PowerShell

Oh-My-Posh is a powerful custom prompt engine for any shell that has the ability to adjust the prompt string with a function or variable. It does not...

MORE ON CODEX

MORE IN THIS CATEGORY

Why WordPress Installation Ends Up with latest version?

1. Why You Need Older WordPress Versions Of course, running the latest version of WordPress is the best option for any website, but at times,...

How To Setup Automatic SSH-Agent for GitBash

Using below procedure, you shall be able to setup SSH-Agent to run automatically whenever GitBash is launched on Windows. The ssh-agent process will continue...

How To Do Database Testing with JMeter

Introduction In this 'How-To', You will be guided to perform a database load test using JMeter. We will be installing Apache JMeter to perform the...

How To Install WordPress Locally using XAMPP

1. Introduction Installing WordPress on your computer helps you try out WordPress, test themes and plugins, and learn WordPress development.  It lets you operate a...

CHECKOUT TUTORIALS

Java Tutorial #3 – Java Arrays

Table of Contents One Dimensional Array Declaring Array Allocting Memory to Array Accessing Array Elements Initializing Array Length of Array Multi Dimensional Array Creating 3...
- Advertisement -spot_img