实现 FastCGI
CGI的由来:
为什么会有FastCGI?
FastCGI实战案例 : Nginx与php-fpm在同一服务器
源码编译php
首先保持一纯净的NGINX服务,之前操作过的删掉,重新建立一个NGINX服务。



[root@fastcgi nginx-1.26.1]# make install

建立完成后,添加PHP模块


中途会报错,有一个解释软件包中没有,要在阿里云找个rpm包的下载地址,
[root@nginx ~]# wget https://repo.almalinux.org/almalinux/9/CRB/x86_64/os/Packages/oniguruma-devel-6.9.6-1.el9.5.x86_64.rpm

[root@nginx ~]# dnf install oniguruma-devel-6.9.6-1.el9.5.x86_64.rpm


[root@nginx php-8.3.9]# make install


原码安装成功。
#利用yum解决php依赖
[root@Nginx ~]# yum install -y bzip2 systemd-devel libxml2-devel sqlite-devel
libpng-devel libcurl-devel oniguruma-devel
#解压源码并安装
[root@Nginx ~]# ./configure \
--prefix=/usr/local/php \ #安装路径
--with-config-file-path=/usr/local/php/etc \ #指定配置路径
--enable-fpm \ #用cgi方式启动程序
--with-fpm-user=nginx \ #指定运行用户身份
--with-fpm-group=nginx \
--with-curl \ #打开curl浏览器支持
--with-iconv \ #启用iconv函数,转换字符编码
--with-mhash \ #mhash加密方式扩展库
--with-zlib \ #支持zlib库,用于压缩http压缩传输
--with-openssl \ #支持ssl加密
--enable-mysqlnd \ #mysql数据库
--with-mysqli \
--with-pdo-mysql \
--disable-debug \ #关闭debug功能
--enable-sockets \ #支持套接字访问
--enable-soap \ #支持soap扩展协议
--enable-xml \ #支持xml
--enable-ftp \ #支持ftp
--enable-gd \ #支持gd库
--enable-exif \ #支持图片元数据
--enable-mbstring \ #支持多字节字符串
--enable-bcmath \ #打开图片大小调整,用到zabbix监控的时候用到了这个模块
--with-fpm-systemd #支持systemctl 管理cgiPHP添加模块[root@Nginx ~]#./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-curl --with-iconv --with-mhash --with-zlib --with-openssl --enable-mysqlnd --with-mysqli --with-pdo-mysql --disable-debug --enable-sockets --enable-soap --enable-xml --enable-ftp --enable-gd --enable-exif --enable-mbstring --enable-bcmath --with-fpm-systemdNGINX1.26 添加模块[root@Nginx ~]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --add-module=/root/echo-nginx-module-0.63 --add-module=/root/memc-nginx-module-0.20 --add-module=/root/srcache-nginx-module-0.33 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module
php相关配置优化
[root@Nginx ~]# cd /usr/local/php/etc
[root@Nginx etc]# cp php-fpm.conf.default php-fpm.conf
[root@Nginx etc]# vim php-fpm.conf
去掉注释
pid = run/php-fpm.pid #指定pid文件存放位置
[root@Nginx etc]# cd php-fpm.d/
[root@Nginx php-fpm.d]# cp www.conf.default www.conf
#生成主配置文件
[root@Nginx php-fpm.d]# cd /root/php-8.3.9/
[root@Nginx php-8.3.9]# cp php.ini-production /usr/local/php/etc/php.ini
[root@Nginx ~]# vim /usr/local/php/etc/php.ini
[Date]
; Defines the default timezone used by the date functions
; https://php.net/date.timezone
date.timezone = Asia/Shanghai #修改时区
#生成启动文件
[root@Nginx ~]# cd /root/php-8.3.9/
[root@Nginx php-8.3.9]# cp sapi/fpm/php-fpm.service /lib/systemd/system/
# Mounts the /usr, /boot, and /etc directories read-only for processes invoked by
this unit.
#ProtectSystem=full #注释该内容
[root@Nginx php-8.3.9]# systemctl start php-fpm.service
[root@Nginx php-8.3.9]# netstat -antlupe | grep php
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 0
820758 176202/php-fpm: mas 


准备php测试页面
[root@Nginx ~]# mkdir /data/php -p
[root@centos8 ~]# cat /data/php/index.php #php测试页面
<?php
phpinfo();
?> 
Nginx配置转发
NGINX主配文件添加子配置文件发布路径。



添加php环境变量
[root@Nginx ~]# vim .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programsPATH=$PATH:$HOME/bin:/apps/nginx/sbin:/usr/local/php/bin
export PATH
[root@Nginx ~]# source .bash_profile 3 php的动态扩展模块(php的缓存模块)
安装memcache模块
[root@Nginx ~]# tar zxf memcache-8.2.tgz
[root@Nginx ~]# cd memcache-8.2/
[root@Nginx memcache-8.2]# yum install autoconf
[root@Nginx memcache-8.2]# phpize
[root@Nginx memcache-8.2]# ./configure && make && make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-nonzts-20230831/
[root@Nginx memcache-8.2]# ls /usr/local/php/lib/php/extensions/no-debug-non-zts-
20230831/
memcache.so opcache.so 








[root@nginx etc]# dnf install memcached -y
复制测试文件到nginx发布目录中
[root@Nginx ~]# cd memcache-8.2/
[root@Nginx memcache-8.2]# ls
autom4te.cache config.log configure.ac example.php Makefile.fragments
README
build config.m4 config.w32 include Makefile.objects runtests.php
config9.m4 config.nice CREDITS libtool memcache.la src
config.h config.status docker LICENSE memcache.php
tests
config.h.in configure Dockerfile Makefile modules
[root@Nginx memcache-8.2]# cp example.php memcache.php /data/php/
[root@Nginx ~]# vim /data/php/memcache.php
define('ADMIN_USERNAME','admin'); // Admin Username
define('ADMIN_PASSWORD','lee'); // Admin Password
define('DATE_FORMAT','Y/m/d H:i:s');
define('GRAPH_SIZE',200);
define('MAX_ITEM_DUMP',50);
$MEMCACHE_SERVERS[] = 'localhost:11211'; // add more as an array
#$MEMCACHE_SERVERS[] = 'mymemcache-server2:11211'; // add more as an array 



测试:


6.3.4 php高速缓存
[root@Nginx ~]# tar zxf srcache-nginx-module-0.33.tar.gz
[root@Nginx ~]# tar zxf memc-nginx-module-0.20.tar.gz
[root@Nginx ~]# cd nginx-1.26.1/
[root@Nginx nginx-1.26.1]# ./configure --prefix=/apps/nginx --user=nginx --
group=nginx --with-http_ssl_module --with-http_v2_module --withhttp_realip_module --with-http_stub_status_module --with-http_gzip_static_module
--with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module --
add-module=/root/memc-nginx-module-0.20 --add-module=/root/srcache-nginx-module-
0.33
[root@Nginx nginx-1.26.1]# make && make install
[root@Nginx ~]# vim /apps/nginx/conf.d/php.conf
upstream memcache {
server 127.0.0.1:11211;
keepalive 512;
}
server {
listen 80;
server_name php.timinglee.org;
root /data/php;
location /memc {
internal;
memc_connect_timeout 100ms;
memc_send_timeout 100ms;
memc_read_timeout 100ms;
set $memc_key $query_string; #使用内置变量$query_string来作为key
set $memc_exptime 300; #缓存失效时间300秒
memc_pass memcache;
}
location ~ \.php$ {
set $key $uri$args; #设定key的值
srcache_fetch GET /memc $key; #检测mem中是否有要访问的php
srcache_store PUT /memc $key; #缓存为加载的php数据
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
[root@Nginx ~]# systemctl start nginx.service 
[root@nginx conf.d]# cat php.conf
upstream memcache {
server 127.0.0.1:11211;
keepalive 512;
}server {listen 80;server_name www.timinglee.org;root /data/web/html;index index.html;location /memc {internal;memc_connect_timeout 100ms;memc_send_timeout 100ms;memc_read_timeout 100ms;set $memc_key $query_string;set $memc_exptime 300;memc_pass memcache;}location ~ \.php$ {set $key $uri$args;srcache_fetch GET /memc $key;srcache_store PUT /memc $key;root /data/web/php;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;include fastcgi.conf;}
}

[root@nginx conf.d]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@nginx conf.d]# nginx -s reload
测试结果:
[root@nginx conf.d]# ab -n500 -c10 http://php.timinglee.org/index.php
This is ApacheBench, Version 2.3 <$Revision: 1903618 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking php.timinglee.org (be patient)
apr_sockaddr_info_get() for php.timinglee.org: Name or service not known (670002)
[root@nginx conf.d]# cd
[root@nginx ~]# cd php-8.3.9/
[root@nginx php-8.3.9]# ab -n500 -c10 http://www.timinglee.org/index.php
This is ApacheBench, Version 2.3 <$Revision: 1903618 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking www.timinglee.org (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Finished 500 requestsServer Software: nginx/1.26.1
Server Hostname: www.timinglee.org
Server Port: 80Document Path: /index.php
Document Length: 74915 bytesConcurrency Level: 10
Time taken for tests: 0.042 seconds
Complete requests: 500
Failed requests: 0
Total transferred: 37549977 bytes
HTML transferred: 37457500 bytes
Requests per second: 11990.12 [#/sec] (mean)
Time per request: 0.834 [ms] (mean)
Time per request: 0.083 [ms] (mean, across all concurrent requests)
Transfer rate: 879353.00 [Kbytes/sec] receivedConnection Times (ms)min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 0 1 0.3 1 3
Waiting: 0 1 0.3 1 3
Total: 0 1 0.3 1 3Percentage of the requests served within a certain time (ms)50% 166% 175% 180% 190% 195% 198% 299% 2100% 3 (longest request)
相关文章:
实现 FastCGI
CGI的由来: 最早的 Web 服务器只能简单地响应浏览器发来的 HTTP 请求,并将存储在服务器上的 HTML 文件返回给浏 览器,也就是静态 html 文件,但是后期随着网站功能增多网站开发也越来越复杂,以至于出现动态技 术&…...
0x01 GlassFish 任意文件读取漏洞复现
参考文章: 应用服务器glassfish任意文件读取漏洞 - SecPulse.COM | 安全脉搏 fofa 搜索使用该服务器的网站 网络空间测绘,网络空间安全搜索引擎,网络空间搜索引擎,安全态势感知 - FOFA网络空间测绘系统 "glassfish"&…...
RLOC_ORIGIN
RLOC_ORIGIN属性为相对放置的对象提供绝对位置或LOC RTL设计中的宏(RPM)。有关定义RPM和使用 RLOC_ORIGIN属性,请参阅《Vivado Design Suite用户指南:使用约束》 (UG903)[参考文献19]。 RPM是通过使用H_set…...
【Python】成功解决 NameError: name ‘reload‘ is not defined
【Python】成功解决 NameError: name ‘reload’ is not defined 下滑即可查看博客内容 🌈 欢迎莅临我的个人主页 👈这里是我静心耕耘深度学习领域、真诚分享知识与智慧的小天地!🎇 🎓 博主简介:985高校…...
Android.bp和Android.mk文件有的区别
文章目录 1. 构建系统2. 语法和格式3. 可维护性和扩展性4. 编译效率5. 未来趋势 在Android的构建系统中, Android.mk和 android.bp是用于定义如何编译项目文件的两种文件类型,它们有一些显著的区别。 1. 构建系统 Android.mk:使用于基于GN…...
思科设备静态路由实验
拓扑及需求 网络拓扑及 IP 编址如图所示;PC1 及 PC2 使用路由器模拟;在 R1、R2、R3 上配置静态路由,保证全网可达;在 R1、R3 上删掉上一步配置的静态路由,改用默认路由,仍然要求全网可达。 各设备具体配置…...
学习笔记第二十九天
IPC 进程间通信方式:共享内存 原理 共享内存是最高效的进程间通信方式之一,因为它允许两个或多个进程直接访问同一块物理内存区域。这种机制避免了数据在用户空间和内核空间之间的频繁拷贝,从而显著提高了数据传输的效率。 在Linux系统中&…...
Apache Paimon走在正确的道路上|一些使用体验和未来判断
Apache Paimon这个框架大家应该都不陌生了。 在实际工作中大家应该多多少少都用到,这个文章是一个简单的使用体会。不涉及湖框架的拉踩,我们的着眼点是解决实际问题。 我来结合自身体会跟大家说说Paimon这个框架和对未来的一些判断。大家可以参考&#x…...
安装MySQL入门基础指令
一.安装MySQL(以5.7版本为例) 1.一路默认安装,截图供大家参考 修改自己window安装名字即可 2.配置环境变量 C:\Program Files\MySQL\MySQL Server 5.7\bin 写入系统环境变量即可在window窗口使用其服务了 3.登录MySQL服务 进入控制台输入命令 mysql -u root …...
搜维尔科技:【研究】Haption Virtuose外科手术触觉视觉学习系统的开发和评估
Haption面临挑战 除此之外,外科医生有时会对骨组织进行非常复杂的手术,其中一个例子是人工耳蜗的手术植入。重要的是要避免神经或血管等危险结构受伤,并尽可能轻柔地进行手术。在外科医生能够安全、无差错地进行此类手术之前,需要…...
达梦表字段、字段类型,精度比对及更改字段SQL生成
达梦表字段、字段类型,精度比对及更改字段SQL生成: 依赖 <!-- 达梦 Connector --><dependency><groupId>com.dameng</groupId><artifactId>DmJdbcDriver18</artifactId><version>8.1.3.62</version>&l…...
2.pandas--读取文件夹中所有excel文件进行合并
文章目录 代码对应的本地文件文件夹目录三个文件夹中的内容test01.xlsxtest02.xlsxtest03.xlsx 三个文件合并后得到merge.xlsx文件文件内容 生成result.xlsx文件内容 代码 import glob import pandas as pddf_merge pd.DataFrame() # 创建一个空的DataFramefolder_path &qu…...
WPS Office两个严重漏洞曝光,已被武器化且在野利用
WPS Office作为一款用户基数超过2亿的广泛使用的办公套件,被发现存在两个关键漏洞(CVE-2024-7262和CVE-2024-7263),这些漏洞可能导致用户遭受远程代码执行攻击。这两个漏洞的CVSS评分为9.3,表明它们的严重性很高&#…...
基于Java爬取微博数据(五) 补充微博正文列表图片 or 视频 内容
基于Java爬取微博数据五 补充微博正文列表图片 or 视频 内容 数据分析补充图片 or 视频执行结果 在通过对微博正文内容中的图片 or 视频内容进行分析后,图片 or 视频 链接是可以直接通过 Java 代码下载或者转存的,那么这样就可以补充我们在 【基于Java爬…...
反射异常捕获 | InvocationTargetException 要用e.getCause()打印才能看到具体异常
背景:线上某段和反射相关的代码报错了,但是异常信息打印只看到了 InvocationTargetException,没打印具体的异常。就像这样:java.lang.reflect.InvocationTargetException: null 查阅资料后发现要用e.getCause()才能打印具体异常&a…...
【计算机网络】网络版本计算器
此前我们关于TCP协议一直写的都是直接recv或者read,有了字节流的概念后,我们知道这样直接读可能会出错,所以我们如何进行分割完整报文?这就需要报头来解决了! 但当前我们先不谈这个话题,先从头开始。 将会…...
使用 Python 爬虫进行网站流量分析:Referer 头的利用
在互联网时代,网站流量分析是了解用户行为、优化网站结构和提升用户体验的重要手段。本文将介绍如何使用 Python 爬虫技术结合 HTTP Referer 头进行网站流量分析,以及如何实现这一过程。 什么是 HTTP Referer 头? HTTP Referer 头是一个请求…...
梧桐数据库(WuTongDB):数据库技术中LL算法详解
LL 算法是一种自顶向下的语法分析算法,广泛用于构建解析器。LL 分析器逐个读取输入符号,从左到右分析(Left-to-Right),并使用最左推导(Leftmost Derivation)来生成语法树。因此,LL 分…...
【秋招笔试】8.18大疆秋招(第一套)-后端岗
🍭 大家好这里是 春秋招笔试突围,一起备战大厂笔试 💻 ACM金牌团队🏅️ | 多次AK大厂笔试 | 编程一对一辅导 ✨ 本系列打算持续跟新 春秋招笔试题 👏 感谢大家的订阅➕ 和 喜欢💗 和 手里的小花花🌸 ✨ 笔试合集传送们 -> 🧷春秋招笔试合集 🍒 本专栏已收…...
CSS 的text-size-adjust属性
text-size-adjust 属性在CSS中用于控制用户是否可以调整网页中文字的字体大小。这个属性主要针对移动设备上的浏览器,尤其是那些允许用户通过捏合(pinch)手势来缩放整个页面的浏览器。 语法 text-size-adjust: none; text-size-adjust: aut…...
IDEA运行Tomcat出现乱码问题解决汇总
最近正值期末周,有很多同学在写期末Java web作业时,运行tomcat出现乱码问题,经过多次解决与研究,我做了如下整理: 原因: IDEA本身编码与tomcat的编码与Windows编码不同导致,Windows 系统控制台…...
利用ngx_stream_return_module构建简易 TCP/UDP 响应网关
一、模块概述 ngx_stream_return_module 提供了一个极简的指令: return <value>;在收到客户端连接后,立即将 <value> 写回并关闭连接。<value> 支持内嵌文本和内置变量(如 $time_iso8601、$remote_addr 等)&a…...
屋顶变身“发电站” ,中天合创屋面分布式光伏发电项目顺利并网!
5月28日,中天合创屋面分布式光伏发电项目顺利并网发电,该项目位于内蒙古自治区鄂尔多斯市乌审旗,项目利用中天合创聚乙烯、聚丙烯仓库屋面作为场地建设光伏电站,总装机容量为9.96MWp。 项目投运后,每年可节约标煤3670…...
【Go】3、Go语言进阶与依赖管理
前言 本系列文章参考自稀土掘金上的 【字节内部课】公开课,做自我学习总结整理。 Go语言并发编程 Go语言原生支持并发编程,它的核心机制是 Goroutine 协程、Channel 通道,并基于CSP(Communicating Sequential Processes࿰…...
OpenLayers 分屏对比(地图联动)
注:当前使用的是 ol 5.3.0 版本,天地图使用的key请到天地图官网申请,并替换为自己的key 地图分屏对比在WebGIS开发中是很常见的功能,和卷帘图层不一样的是,分屏对比是在各个地图中添加相同或者不同的图层进行对比查看。…...
大语言模型(LLM)中的KV缓存压缩与动态稀疏注意力机制设计
随着大语言模型(LLM)参数规模的增长,推理阶段的内存占用和计算复杂度成为核心挑战。传统注意力机制的计算复杂度随序列长度呈二次方增长,而KV缓存的内存消耗可能高达数十GB(例如Llama2-7B处理100K token时需50GB内存&a…...
ip子接口配置及删除
配置永久生效的子接口,2个IP 都可以登录你这一台服务器。重启不失效。 永久的 [应用] vi /etc/sysconfig/network-scripts/ifcfg-eth0修改文件内内容 TYPE"Ethernet" BOOTPROTO"none" NAME"eth0" DEVICE"eth0" ONBOOT&q…...
听写流程自动化实践,轻量级教育辅助
随着智能教育工具的发展,越来越多的传统学习方式正在被数字化、自动化所优化。听写作为语文、英语等学科中重要的基础训练形式,也迎来了更高效的解决方案。 这是一款轻量但功能强大的听写辅助工具。它是基于本地词库与可选在线语音引擎构建,…...
PostgreSQL——环境搭建
一、Linux # 安装 PostgreSQL 15 仓库 sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-$(rpm -E %{rhel})-x86_64/pgdg-redhat-repo-latest.noarch.rpm# 安装之前先确认是否已经存在PostgreSQL rpm -qa | grep postgres# 如果存在࿰…...
jdbc查询mysql数据库时,出现id顺序错误的情况
我在repository中的查询语句如下所示,即传入一个List<intager>的数据,返回这些id的问题列表。但是由于数据库查询时ID列表的顺序与预期不一致,会导致返回的id是从小到大排列的,但我不希望这样。 Query("SELECT NEW com…...
