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. As an avid promoter/user of the Linux OS, Jack tries to convert as many users to open source as possible. His current favorite flavor of Linux is Bodhi Linux (a melding of Ubuntu and Enlightenment). When Jack isn't writing about Linux he is hard at work on his other writing career -- writing about zombies, various killers, super heroes, and just about everything else he can manipulate between the folds of reality. You can find Jack's books on Amazon, Barnes & Noble, and Smashwords. Outnumbered in his house one male to two females and three humans to six felines, Jack maintains his sanity by riding his mountain bike and working on his next books. For more news about Jack Wallen, visit his website Get Jack'd.