php设置监听9000外的端口失败unable to bind listening socket for address ‘127.0.0.1:9003‘: Permission denied

报错信息入如下:

-bash-4.2# systemctl status php73-php-fpm.service -l
● php73-php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php73-php-fpm.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 三 2020-08-12 11:21:55 CST; 55s ago
  Process: 11626 ExecStart=/opt/remi/php73/root/usr/sbin/php-fpm --nodaemonize (code=exited, status=78)
 Main PID: 11626 (code=exited, status=78)

8月 12 11:21:55 localhost.localdomain systemd[1]: Starting The PHP FastCGI Process Manager...
8月 12 11:21:55 localhost.localdomain php-fpm[11626]: [12-Aug-2020 11:21:55] ERROR: unable to bind listening socket for address '127.0.0.1:9003': Permission denied (13)
8月 12 11:21:55 localhost.localdomain php-fpm[11626]: [12-Aug-2020 11:21:55] ERROR: FPM initialization failed
8月 12 11:21:55 localhost.localdomain systemd[1]: php73-php-fpm.service: main process exited, code=exited, status=78/n/a
8月 12 11:21:55 localhost.localdomain systemd[1]: Failed to start The PHP FastCGI Process Manager.
8月 12 11:21:55 localhost.localdomain systemd[1]: Unit php73-php-fpm.service entered failed state.
8月 12 11:21:55 localhost.localdomain systemd[1]: php73-php-fpm.service failed.

原因是默认情况下,除了root外的用户只能使用一些指定的端口。
解决办法,扩大可适用范围,我这是在本地,所以可以范围大一点:

semanage port -a -t http_port_t -p tcp 9000-9999

再次启动php即可。

SELinux的默认设置

默认情况下,最小化安装的CentOS,SELinux是开启的。
SELinux默认情况下,只允许非root权限用户,使用几个固定端口,(包括http端口和其他协议的端口)

被默认可以使用的http端口如下:可使用命令semanage port -l | grep http_port_t查看

结果如下:

  http_port_t                    tcp      80, 81, 443, 488, 8008, 8009, 8443, 9000
  pegasus_http_port_t            tcp      5988

你可能感兴趣的:(php)