找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 924|回复: 0

Nginx和PHP-FPM结合

[复制链接]

304

主题

42

回帖

1338

积分

管理员

积分
1338
发表于 2021-4-16 03:08:32 | 显示全部楼层 |阅读模式
PHP-FPM运行模式:
1.socket
listen = /usr/local/php/var/run/www.sock

2.tcp
listen = 127.0.0.1:9000

Nginx结合PHP-FPM的两种模式:
1.socket
fastcgi_pass unix:/usr/local/php/var/run/www.sock;

2.tcp
fastcgi_pass  127.0.0.1:9000;

Nginx支持PHP程序:
location ~ \.php$ {      
        fastcgi_index index.php;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;
}

测试php动态脚本:
1.配置文件语法检测
nginx -t

2.配置index.php默认首页的优选级
location / {
        index index.php index.html
}

3.nginx结合php
vi /etc/nginx/default.d/php.conf
location ~ \.php$ {      
        fastcgi_index index.php;
        #fastcgi_pass unix:/run/php-fpm/www.sock;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;
}

4.重启nginx或重载nginx
/usr/local/nginx/sbin/nginx -s reload
pkill -HUP nginx

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|外汇论坛 ( 粤ICP备16021788号 )

GMT+8, 2024-10-23 07:18 , Processed in 0.068049 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表