Recently, we have compiled monitoring interfaces for the platform of the southern base, using the BS architecture. One of them is to monitor whether a virtual machine is down.
The process is as follows: The invigilator sends an access request --> interface analysis request --> starts the socket to check whether the target virtual machine is down.
Because the ICMP protocol is used for detection, the socket type of SOCK_RAW is used.
When the server uses apache + php + mysql and finds a program error, it prompts that you do not have the permission to create a socket. Later, I checked the resource and learned that this type of socket requires the root permission or runs php in cgi Mode and uses setuid () to create the socket.
Solution: Use nginx + php-cgi + mysql.
When compiling php, you must make the following changes to start the service as the root user.
1. find the php source code $ src_path/sapi/cgi/fpm/fpm_unix.c (the version is different, preferably through find $ src_path-name fpm_unix.c)
2. Add a macro definition at the top of the file: # define I _REALLY_WANT_ROOT_PHP
3. Re-configure make install
4. The php-fpm.conf changes both user and group to root
Author: penguim