Solution to creating socket with php in BS mode with no permission

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.