A number of TechRepublic readers have emailed me this question: How can Apache 2 be configured to run on a port other than port 80? The answer depends on the version of Apache that is running, so I will explain how to do this for Apache and Apache 2. My explanation covers Apache 2 on Ubuntu and Apache on Windows (WAMP).
Configuring Apache 2 to use a non-standard portTo configure Apache 2, you need to edit the file /etc/apache2/ports.conf. In this file, you will see a line that reads Listen 80 (Figure A). Figure A
This is the ports.conf file showing configuration for regular and VirtualHost ports.
Say you want Apache 2 to listen on port 8010. To do that, the configuration option would change to:
It is also possible to have Apache listen on both ports 80 and 8010 with the following:
You could, effectively, have Apache 2 listening on as many ports as you like.
Once you have this configured, restart Apache with the command:
sudo /etc/init.d/apache2 restart
and your web server will now be listening on the newly configured ports.
Configuring Apache to use a non-standard port
It's just as easy to configure Apache on a WAMP server. You should open the httpd.conf file and do a Find for the string '80' (no quotes). The line you are looking for is the same as configured in the Apache 2 ports.conf file:
Change that to the port you want, save the file, and restart Apache. Like Apache 2, you can configure Apache to listen to more than one port.
That's it! Anyone who has ever said Apache is a challenge to configure more than likely never bothered trying it. This doesn't cover the <VirtualHost> directive, but we'll tackle that in another edition of Ask Jack.Ask Jack: If you have a DIY question, email it to me, and I'll do my best to answer it. (Read guidelines about submitting DIY questions.)
Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website getjackd.net.