In centos, apache uses the default port 80. Now we want to change the port to 9191, for example, an error will be reported,
The error message is as follows:
(13) Permissiondenied: make_sock: couldnotbindtoaddress [:]: 9191
(13) Permissiondenied: make_sock: couldnotbindtoaddress0.0.0.0: 9191
This is because the PORT command we want has not been opened, so we need to perform the following two steps.
1. Install the semanage management tool. skip this step if you have installed the tool.
First use: semanageport-l | grephttp to see if there is no 9191 results, if not, use the following sentence plus: semanageport-a-thttp_port_t-ptcp9191
2. Copy the line "vi/etc/sysconfig/iptables" 80 "and change" 80 "to" 9191.
Then restart the firewall: serviceiptablesrestart
Restart apache again. servicehttpdrestart
Note: Some friends do not know where semanage is installed. I will attach it below:
Appendix: semanage1. install semanage. By default, CentOS does not have this command. You need to check who provided this command.
Yumprovides/usr/sbin/semanage and then install the yum-yinstallpolicycoreutils-python2.semanage to use the protcontext, for example, to view the ssh port status semanageport-l | grepssh should be possible to the following results: ssh_port_ttcp2345, 22