Home > php教程 > php手册 > body text

nginx使用sock方式调用php

WBOY
Release: 2016-06-06 19:54:22
Original
1533 people have browsed it

通常我们配置nginx默认连接php-fpm的方式,是监听127.0.0.1:9000端口,然而还有一种更高效的连接方式,用sock的方式连接。配置如下: 第一步,nginx端配置方法: location ~ .*\.(php|php5)?$ { fastcgi_pass unix:/dev/shm/php-fpm.sock; fastcgi_index ind

通常我们配置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生效。

nginx使用sock方式调用php

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!