How do I configure Apache HTTPD to listen on multiple ports under RHEL / Fedora / CentOS Linux Server?
Multiple ports can be configured via Listen directive under Apache web server. By default httpd listens on TCP port 80.
How to configure httpd to listen multiple ports?
Open configure file /etc/httpd/conf/httpd.conf and modify the Listen directive tells the server to accept incoming requests on the specified port. Multiple Listen directives may be used to specify a number of ports to listen to.
# vi /etc/httpd/conf/httpd.conf
Find line that read as follows:
Listen 80
Force httpd to listen to port 81:
Listen 81
Force httpd to listen on both port 80 and 81:
Listen 80
Listen 81
Save and close the file. Restart httpd:
# /etc/init.d/httpd restart
A note about SELinux
If you are using SELinux, make sure port 81 is configured and not blocked by SELinux. By default SELinux only allows port number 80 and 443 for httpd service. To display current port contexts, enter:
# semanage port -l | grep http
# semanage port -l | grep -w '^http_port_t'
Sample outputs:
http_port_t tcp 80, 443, 488, 8008, 8009, 8443
To add port 81 to port contexts, enter:
# semanage port -a -t http_port_t -p tcp 81
You can verify new settings, enter:
# semanage port -l | grep http_port_t
Sample outputs:
http_port_t tcp 80, 81, 443, 488, 8008, 8009, 8443Finally, reload or restart the HTTPD server, enter:
# /sbin/service httpd reload
Page last updated at 5:57 AM, April 21, 2012.
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop













{ 5 comments… read them below or add one }
so what difference it makes? both port requires root privilege, how can we configure it as a non-root user.
say i want to listen it to port 8888 and a non-root user wants to start stop apache?
After adding Listen 8000 to /etc/httpd/conf/httpd.conf
and restart httpd service httpd restart
I had this error
Démarrage de httpd :(98)Address already in use: make_sock: could not bind to address 192.168.1.3:80
no listening sockets available, shutting down
Unable to open logs
can someone help me please.
You’ll need to configure SELinux to allow activity on that port.
See I want my apache daemon to listen on a different port but SELinux is preventing it, What do I do?.
@VIVEK GITE
Normally your site is the first place I turn to when I have a query, but shame on you for not mentioning how SELinux can intercept non-standard ports.
Thanks for the heads up!
if you dont have semanage install
yum -y install policycoreutils-python