Using PHP to create socket-free solutions in BS mode _php tutorial

Source: Internet
Author: User
Tags php source code root access
Recently, a monitoring interface has been written for the South base platform, with a BS framework, which has a capability to monitor virtual machines for downtime.
The process is: The monitor makes an access request--an interface analysis request--starts the socket to detect if the target virtual machine is down.
Because of the ICMP protocol detection, the SOCK_RAW socket type is used.
Server using Apache + PHP + MySQL, found that the program error, prompted that there is no permission to create a socket. Later, the resource learned that such sockets require root access or CGI to run PHP combined with setuid () to create a socket.
Workaround: Use Nginx+php-cgi+mysql to resolve.
When compiling PHP, the following modifications are required to start the service with the root user.

1. Find PHP Source code $src_path/sapi/cgi/fpm/fpm_unix.c (the version is not the same, 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 make install

4.php-fpm.conf change user, group to root


Author: Penguim

http://www.bkjia.com/PHPjc/478048.html www.bkjia.com true http://www.bkjia.com/PHPjc/478048.html techarticle recently, a monitoring interface has been written for the South base platform, with a BS framework, which has a capability to monitor virtual machines for downtime. The process is: the monitoring machine makes the access request--Interface analysis Request ...

  • 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.