XAMPP, using port:81, cannot run localhost:81/mywebsite

Hieu Do picture Hieu Do · May 31, 2015 · Viewed 30.2k times · Source

XAMPP's default port:80 is occupied by System.exe, so I have to switch to port:81, as this question suggested XAMPP PORT 80 is Busy / EasyPHP error in Apache configuration file:

After this change, I can access localhost:81/xampp and localhost:81/phpMyAdmin , as well as local files, like localhost:81/wordpress/Readme.html

However, I can not load other local directories in htdocs, can not install new wordpress site on my computer, and localhost:81/wordpress is auto referred back to localhost/wordpress , which is NOT FOUND

Here's a list of what I tried and failed

  1. Change all localhost options to locahost:81, in C:\xampp\apache\conf\http.conf , in C:\xampp\xampp-control.ini , in MySQL Database, Database Tables, root User, in wordpress wp-config-sample.php , wp-config.php

  2. I load localhost:81\wordpress in Chrome and it is auto referred back to localhost\wordpress , the result is NOT FOUND.

So I can not access to localhost:81/mywebsite because it is auto referred to the old localhost , and can not stop System.exe from using port:80. I searched almost every where, but the only solution I found is a mistyped mistake in wp-config.php - that is NOT my problem.

Plese help.

Answer

Harikrishnan picture Harikrishnan · May 31, 2015

Try specifying port number in virtual host configuration. Hence you can avoid typing port number in url. Add these lines to C:/xampp/apache/config/extra/httpd-vhosts.conf

NameVirtualHost *:81
    <VirtualHost *:81>
        ServerName test.com
        DocumentRoot "C:/xampp/htdocs"

        <Directory "C:/xampp/htdocs">
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>

Edit C:\Windows\System32\drivers\etc\hosts and Add

127.0.0.1    test.com

at the end of file. Restart apache. clear browser cache and just point to test.com.