Home  >  Article  >  Backend Development  >  nginx使用sock形式调用php-fpm

nginx使用sock形式调用php-fpm

WBOY
WBOYOriginal
2016-06-13 12:11:26955browse

nginx使用sock方式调用php-fpm

 通常我们配置nginx默认连接php-fpm的方式,是监听127.0.0.1:9000端口,然而还有一种更高效的连接方式,用sock的方式连接。配置如下:

    

    第一步,nginx端配置方法:

    location ~ .*\.(php|php5)?$

        {

        fastcgi_pass unix:/dev/shm/php-fpm.sock;

        fastcgi_index index.php;

        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        include fastcgi_params;

        }

        

    第二步,php端配置方法:

        

    5.2以下版本php-fpm.conf配置:

        /dev/shm/php-fpm.sock


    5.3以上版本php-fpm.conf配置:

        listen = /dev/shm/php-fpm.sock


    重启nginx,php生效。

欢迎大家访问我的个人网站 萌萌的IT人
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn