安装和启动php-fpm
# 以下测试环境系统为CentOS Linux release 7.7.1908
# 安装php及相关模块
yum install php php-gd php-soap php-mbstring php-xmlrpc php-dom php-fpm -y
# 检查是否安装成功
php -v
# 修改监听 listen = 127.0.0.1:9000
vi /etc/php-fpm.d/php.conf
# 启动php-fpm
systemctl start php-fpm配置nginx
server {
listen 86;
server_name localhost;
location ~ \.php$ {
root html;
include snippets/fastcgi-php.conf;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}
}测试
# 准备两个测试文件
echo '<?php phpinfo();?>' >> /usr/local/nginx/html/index.php
echo '<?php echo "php-fpm is working...";?>' >> /usr/local/nginx/html/test.phphttp://xxx.xxx.xxx.xxx:86/index.php
http://xxx.xxx.xxx.xxx:86/test.php 相关知识点
CGI 即Common Gateway Interface。早期的web服务器只能处理静态请求,对于动态请求需要生新进程来处理,进程把处理完的数据返回给web服务器,进程退出,web服务器再返回给客户端。CGI是早期的http服务器与其它应用程序的通信接口,CGI程序运行在http服务器上。CGI可以使用多种语言编写。
FastCGI 当大量动态请求进入web服务器时,CGI每次都要生成新的进程效率低,资源占用高,因此出现了FastCGI。FastCGI常驻在系统中,不会每次都生成新的进程。nginx中http模块默认支持FastCGI模式,默认配置为:
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}php-fpm php-fpm是php的FastCGI管理进程,接收和处理web服务器的php请求。
查看已安装的php模块: php -m
检查php-fpm配置文件是否配置正确: php-fpm -t
,这里可以看到配置文件路径
推荐本站淘宝优惠价购买喜欢的宝贝:
本文链接:https://zblog.hqyman.cn/post/11261.html 非本站原创文章欢迎转载,原创文章需保留本站地址!
休息一下~~