
The hostname and port that the web server is using will be listed in the /etc/httpd/conf/httpd.conf file. In this example, the hostname is www.example.com and the port is 80. In this example, navigating to www.example.com will cause the web server to server it's default document.
ServerName www.example.com
Listen 192.168.0.22:80
If you need to configure HTTPD to listen for connections on a different port of than 80, in the /etc/httpd/conf/httpd.conf file, ensure you have the following configuration. In this example, port 12345 is used. Use your preferred IP address and port number. Also ensure the port number is not already associated with a service in the /etc/services file.
Listen 192.168.0.22:12345
Add the port number to the http_port_t context.
semanage port -a -t http_port_t -p tcp 12345
Ensure the port number is in the http_port_t context.
semanage port -l | grep -w http_port_t
. . .
http_port_t tcp 12345, 80, 443, 488, 8008, 8009, 8443
The ps command can be used to determine if your system is using init or systemd. If PID 1 is init, then you will use the service command. If PID 1 is systemd, then you will use the systemctl command.
If your system is using systemd, use the systemctl command to start and enable httpd.
systemctl restart httpd
systemctl status httpd
If your system is using init, use the service command to start and enable httpd.
service httpd restart
service httpd status
Use the apachectl configtest command can be used to verify the configuaration of HTTPD is OK.
[root@server1 ~]# apachectl configtest
. . .
Syntax OK
Update iptables to allow connections on port 12345.
Restart iptables, and ensure iptables is active and running.
[root@server1 ~]# systemctl restart iptables
[root@server1 ~]# systemctl status iptables
From a PC in the same subnet as the HTTPD web server, ensure you get the default HTTPD page when navigating to http://192.168.0.22:12345.
Did you find this article helpful?
If so, consider buying me a coffee over at