Recently, I wrote a monitoring interface for the southern base platform, using the BS architecture, which has a function to monitor whether the virtual machine is down.
The process is: the monitoring machine issues an access request --> interface analysis request --> starts the socket to detect whether the target virtual machine is down.
Because it is detected through the ICMP protocol, the socket type SOCK_RAW is used.
The server uses apache + php + mysql, and a program error was found, prompting that there is no permission to create a socket. Later, I checked the resources and learned that this type of socket requires root permissions or running php in cgi mode combined with setuid() to create a socket.
Solution: Use nginx+php-cgi+mysql instead.
When compiling php, the following modifications must be made to start the service as the root user.
1. Find the source code of php $src_path/sapi/cgi/fpm/fpm_unix.c (the versions are different, it is best to use 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. Reconfigure make make install
4.php-fpm.conf Modify user and group to root