The reason why Php-fpm.sock was not found when configuring Nginx and php-fpm to connect with sock sockets

Source: Internet
Author: User

Reprint: http://www.cnblogs.com/zzyyxxjc/p/4361282.html

After the php5.3 version, php-fpm.conf in the Listen default configuration is 127.0.0.1:9000, will not generate php-fpm.sock, so if you need Nginx configuration has links tmp/ Php-fpm.sock, you need to configure the address of the listen to be consistent with the Nginx configuration file, and ensure that the path already exists, so that when you start the./PHP-FPM, the Php-fpm.sock is automatically generated on the corresponding path, for example:

Let php-fpm use UNIX sockets

By default, port 9000 is listening . In addition, you can make php-fpm use UNIX sockets, which avoids the overhead of TCP. To do this, open the /etc/php-fpm.d/www.conf ...

Vi/etc/php-fpm.d/www.conf

... The following changes are followed:

[...]; Listen = 127.0.0.1:9000listen =/var/run/php-fpm/php5-fpm.sock[...]

Then reload PHP-FPM:

Systemctl Restart Php-fpm.service

Next through your nginx configuration and all the virtual hosts and reroute Fastcgi_pass 127.0.0.1:9000; to Fastcgi_pass unix:/tmp/php5-fpm.sock;, like this:

Vi/etc/nginx/conf.d/default.conf

[...]    Location ~. php$ {        root           /usr/share/nginx/html;        Try_files $uri =404;        Fastcgi_pass   Unix:/var/run/php-fpm/php5-fpm.sock;        Fastcgi_index  index.php;        Fastcgi_param  script_filename  $document _root$fastcgi_script_name;        Include        fastcgi_params;    } [...]

Finally reload Nginx:

Systemctl Restart Nginx.service

Once this is configured, a Php5-fpm.sock file is automatically generated in the/var/run/php-fpm/directory, and then everything is OK.

The reason why Php-fpm.sock was not found when configuring Nginx and php-fpm to connect with sock sockets

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.