Configuring Apache to use an alternative port on Ubuntu

To change from the default port 80 to another port, say 14000 – you need to change the configuration in two places.

First, change the default virtual host (000-default):

vim /etc/apache2/sites-enabled/000-default

Change the first line as below and save the file.

<VirtualHost *:14000>

Changing the default Virtual host isn’t enough though. When you start apache you might see this error:

service apache2 restart
* Restarting web server apache2
... [warn] NameVirtualHost *:80 has no VirtualHosts

That is because you also need to change the ports configuration file:

vim /etc/apache2/ports.conf

Change the config so it looks like this:

NameVirtualHost *:14000
Listen 14000

Restart apache and you’re all set!

service apache2 restart

Leave a Reply

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

Markdown is allowed in comments.