TechAid24

Your Technical Consultant

XAMPP Multi-Port Configuration: Host Multiple Websites on One Server Easily

Posted on by Selim Ahmed 4 minutes read

In this article, I would like to discuss XAMPP Multi-Port Configuration: Host Multiple Websites on One Server Easily. Setting up XAMPP with Multi-Port allows you to run multiple web applications or websites on a single server. XAMPP is a popular development environment that bundles Apache, MySQL, PHP, and other tools.

 

Xampp’s default port is 80 and 443. If you have many projects and want to set up those projects with a different port in xampp called “Virtual Hosts”. This is how to Setup XAMPP Multi-Port Setup: Run Multiple Websites on a Single Server. Here’s a step-by-step guide on how to set up XAMPP multi-ports:

 

Download and Install XAMPP

If you haven’t already, download and install XAMPP from the official website (https://www.apachefriends.org/index.html).

 

Launch XAMPP Control Panel

After installation, open the XAMPP Control Panel. On Windows, you can do this by searching for “XAMPP Control Panel” in the Start menu.

 

Configure XAMPP Multi-Port

By default, Apache runs on port 80. To run it on multiple ports, you need to configure Apache setup with multiple ports you want to use.

  1. In the XAMPP Control Panel, click on the “Config” button for Apache.
  2. Select “httpd.conf” from the dropdown menu. This will open the Apache configuration (“C:\xampp\apache\conf\httpd.conf”) file in your default text editor.
  3. In the configuration file, search for the line that says Listen 80 (this is the default port). To add more ports, you can copy this line and change the port number. For example:
    Listen 85 
    Listen 86 
    Listen 87 
    Listen 88

    d. Save the configuration file and close the text editor.

 

Configure Virtual Hosts (Optional)

If you want to set up multiple websites with different domain names or subdomains, you can configure virtual hosts.

  1. In the XAMPP Control Panel, click on the “Config” button for Apache again.
  2. Select “httpd-vhosts.conf” from the dropdown menu. This will open the virtual host configuration file in your default text editor.
  3. Add virtual host configurations for each port you’ve defined in the previous step. For example:
    # vhosts - my-profile:
    <VirtualHost *:85>
            DocumentRoot "C:/xampp/htdocs/my-profile"
            ServerName localhost:85
            <Directory "C:/xampp/htdocs/my-profile">
                Require all granted
                Options -Indexes +FollowSymLinks +MultiViews
                AllowOverride All
                Order allow,deny
                Allow from all
            </Directory>
    	LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined 
    	SetEnvIf Request_URI "(\/assets\/)" dontlog 
    	CustomLog C:\xampp\Apache24\logs\myweb-access.log combined env=!dontlog 
    	ErrorLog C:\xampp\Apache24\logs\myweb-error.log
    </VirtualHost>
    
    # vhosts - website:
    <VirtualHost *:86>
            DocumentRoot "C:/xampp/htdocs/academia/website/dist"
            ServerName localhost:86
            <Directory "C:/xampp/htdocs/academia/website/dist">
                Require all granted
                Options Indexes FollowSymLinks
                AllowOverride All
                Order allow,deny
                Allow from all
            </Directory>
    </VirtualHost>
    
    # vhosts - api:
    <VirtualHost *:87>
            DocumentRoot "C:/xampp/htdocs/academia/api/public"
            ServerName localhost:87
            <Directory "C:/xampp/htdocs/academia/api/public">
                Require all granted
                Options Indexes FollowSymLinks
                AllowOverride All
                Order allow,deny
                Allow from all
            </Directory>
    </VirtualHost>
    
    # vhosts - admin:
    <VirtualHost *:88>
            DocumentRoot "C:/xampp/htdocs/academia/admin/public"
            ServerName localhost:88
            <Directory "C:/xampp/htdocs/academia/admin/public">
                Require all granted
                Options Indexes FollowSymLinks
                AllowOverride All
                Order allow,deny
                Allow from all
            </Directory>
    </VirtualHost>

    Make sure to replace the paths and domain names with your own.

  4. Save the virtual host configuration file and close the text editor.

 

Edit Hosts File (Windows Only)

On Windows, you’ll need to edit the hosts file to map domain names to IP addresses.

  1. Open Notepad as an administrator.
  2. Open the hosts file located at C:\Windows\System32\drivers\etc\hosts.
  3. Add entries for your domain names and map them to 127.0.0.1. For example:
    # 127.0.0.1       localhost
    # ::1             localhost
    127.0.0.1      127.0.0.1:85 // host with new port.
    127.0.0.1      127.0.0.1:86 // host with new port.
    127.0.0.1      127.0.0.1:87 // host with new port.
    127.0.0.1      127.0.0.1:88 // host with new port.
    
  4. Save the hosts file.

 

Restart Xampp

In the XAMPP Control Panel, stop and then start the Apache server to apply the changes.

 

Access Your Websites

You can now access your websites by entering the domain names or IP addresses with the corresponding ports in your web browser. For example:

  1. http://localhost:85
  2. http://localhost:86
  3. http://localhost:87
  4. http://localhost:88

That’s it! You’ve set up XAMPP with multiple ports, allowing you to run multiple web applications or websites on your local server for development and testing.

Xampp Server Setup With Multiple Ports

Tags:

Selim Ahmed

Thank you for visiting my personal blog. I’m Selim Ahmed, a tech-savvy who loves to learn a new technology every day. Innovation, research, and development is my daily activities. I love to work in a place where I can learn, innovate, and develop new things.Please feel free to reach me on any comments and feedback you have. I would be more than glad to listen and reply.

Leave a Reply

Your email address will not be published. Required fields are marked *