How to change Apache default port on Ubuntu 16.04

This quick tips will show you how to change the Apache webserver default port on Ubuntu. On this tutorial, I am using Ubuntu 16.04 server edition. As you know, the Apache default port is 80. For security or any other reasons, we can easily change this number to something else which is not easy to guess by unwanted people out there.


What we need

  • Apache web server is installed on Ubuntu. Read how to install LAMP on Ubuntu.
  • root access to Ubuntu Server
  • little knowledge of Terminal commands

Steps to change Apache Web Server Default port


You can either use the Terminal console on the Server directly or connect from other computer via SSH. And then follow these steps.

We are going to edit the following file : /etc/apache2/ports.conf

Now you should see the following line on the file:

Listed 80

Change it to port number you like such as

Listen 82

Now save and exit (Ctrl X)

Restart Apache

Now from other computer test the new port



Leave a Reply

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