HowTo: Change the default Port for apache2

Why Run apache2 on a different port?

At times, it might be necessary to have multiple http servers running, either on the same computer, or on different computers on the same network, with only one outside IP address.

In my case, I would like to build a web client for my home automation, and would like this accessible, but not on the standard port 80 used for http traffic.


In the end of this tutorial, you should have apache2 running on port 8080. For the purpose of this demonstration, the server is running on a Raspberry Pi. I would like this in addition to the normal listening port of 80.

Things to keep in mind

Once you have everything working correct, you will need modify your router to forward port 8080 to the IP address of your Raspberry Pi, so that incoming requests are directed to the right computer.

The configuration file for apache is located at (at least the configuration file for the ports to be listed to):

Edit the configuration file using the command:

Add the line:


Restart the server:

You should now be able to access your web server by going to:

One thought on “HowTo: Change the default Port for apache2

  • January 13, 2016 at 7:00 pm

    I’ve found that all the set-ups I made a year ago when I first bought my pi no longer work with the latest (Nov 2015) release of Raspbian. That means most of the posts on this subject on the web are now obsolete. Thanks for posting up to date instructions that work!


Leave a Reply

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