Solving the problem that PHP cannot open other sockets (permission denied) under apache

WBOY
Release: 2016-08-08 09:31:03
Original
1008 people have browsed it

Today I plan to practice redis operation. When I run it on the command line, I find that the connection is smooth.

Later, I ran it with apache and found that it could not connect to the redis client (redis server went away).

By capturing packets on the reids server, I found that no connection request was received at all when using apache.

You can know that the problem is caused by apache.

It works under the command line, but not under apache. The first thing I thought of was whether the apache configuration file restricted a certain port, but I couldn't find it.

Finally found the answer on stackoverflow - selinux limits the ports that apache can open (more specifically, the ports that the http service can open).

Solution

/usr/sbin/setsebool httpd_can_network_connect=1

or

setenforce 0               ##Set SELinux into permissive mode

Remind me in the future, except for the firewall can stop you, selinux can also stop you , don’t forget.

The above introduces the solution to the problem that PHP cannot open other sockets (permission denied) under Apache, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template