To totally unlock this section you need to Log-in
Login
On almost every web server based on Linux there will be, probably, the need to change the listening port for security reason (when exposed on internal LANs or externally on internet) on Apache (for Debian distributions) or on httpd (RedHat based distributions). Following the common locations of configuration files and the change needed to modify the listening port of the web server daemon.
Redhat/Centos
Edit the /etc/httpd/conf/httpd.conf file and change:
Listen 80
To:
Listen <your new port>
Ubuntu/Debian
Edit the /etc/apache2/ports.conf file and change:
Listen 80
To:
Listen <your new port>
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
or
# service httpd restart
A note about SELinux
If you are using SELinux, make sure port 81 (or whatever you have added as port) 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, 8443
Finally, reload or restart the HTTPD server, enter:
# /sbin/service httpd reload
or
# service httpd restart