Use the systemctl command to restart the httpd service.
This command fails to restart the service.
[root@serverb ~]# systemctl restart httpd.service
Job for httpd.service failed because the control process exited with error code.
See "systemctl status httpd.service" and "journalctl -xe" for details.
Use the systemctl status command to investigate the reason for the failure of the httpd service.
[root@serverb ~]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2019-04-15 06:42:41 EDT; 5min ago
Docs: man:httpd.service(8)
Process: 27313 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 27313 (code=exited, status=1/FAILURE)
Status: "Reading configuration..."
Apr 15 06:42:41 serverb.lab.example.com systemd[1]: Starting The Apache HTTP Server...
Apr 15 06:42:41 serverb.lab.example.com httpd[27313]: (13)Permission denied: AH00072: make_sock: could not bind to address [::]:30080
Apr 15 06:42:41 serverb.lab.example.com httpd[27313]: (13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:30080
Apr 15 06:42:41 serverb.lab.example.com httpd[27313]: no listening sockets available, shutting down
Apr 15 06:42:41 serverb.lab.example.com httpd[27313]: AH00015: Unable to open logs
Apr 15 06:42:41 serverb.lab.example.com systemd[1]: httpd.service: Main process exited, code=exited, status=1/FAILURE
Apr 15 06:42:41 serverb.lab.example.com systemd[1]: httpd.service: Failed with result 'exit-code'.
Apr 15 06:42:41 serverb.lab.example.com systemd[1]: Failed to start The Apache HTTP Server.
Notice the permission error in the preceding output, which signifies that the httpd daemon failed to bind to port 30080/TCP.
The SELinux policy can be a potential restriction for an application to bind to a port.
Press q to quit the preceding systemctl command.
Use the sealert command to determine if an SELinux policy is preventing httpd from binding to port 30080/TCP.
[root@serverb ~]# sealert -a /var/log/audit/audit.log
100% done
found 1 alerts in /var/log/audit/audit.log
--------------------------------------------------------------------------------
SELinux is preventing /usr/sbin/httpd from name_bind access on the tcp_socket port 30080.
***** Plugin bind_ports (92.2 confidence) suggests ************************
If you want to allow /usr/sbin/httpd to bind to network port 30080
Then you need to modify the port type.
Do
# semanage port -a -t PORT_TYPE -p tcp 30080
where PORT_TYPE is one of the following: http_cache_port_t, http_port_t, jboss_management_port_t, jboss_messaging_port_t, ntop_port_t, puppet_port_t.
...output omitted...
The preceding log message reveals that the port 30080/TCP does not have the appropriate SELinux context http_port_t, causing SELinux to prevent httpd to bind to this port.
The log message also produces the syntax of the semanage port command so that you can easily fix the issue.
Use the semanage port command to set the appropriate SELinux context on the port 30080/TCP for httpd to bind to it.
[root@serverb ~]# semanage port -a -t http_port_t -p tcp 30080
Use the systemctl command to restart httpd.
This command should successfully restart the service.
[root@serverb ~]# systemctl restart httpd
Add the port 30080/TCP to the default firewalld zone called public.
[root@serverb ~]# firewall-cmd --add-port=30080/tcp --permanent
success
[root@serverb ~]# firewall-cmd --reload
success
Exit the root user's shell.
[root@serverb ~]# exit
logout
Log off from serverb.
[student@serverb ~]$ exit
logout
Connection to serverb closed.