nginx fastcgi C++ 开发框架配置说明
来源:互联网 发布:大数据 数据挖掘 编辑:程序博客网 时间:2024/06/05 16:07
前言
网上一搜罗一大堆相关文章,之所以写明是原创是因为绝大多数文章都有细节问题,再则关于php较多,C++较少。
只是比较粗地说一下安装步骤,例如nginx.conf 格式 以及每个命令参数 并不需要去深究~
关于开发框架
1. nginx服务器只是负责转发请求,请求转发给自己开发的fastcgi服务程序处理。
2. spawn-fcgi 用于管理fastcgi应用程序,他是lighttpd的一子项目。
3. fastcgi 服务程序接收请求,处理然后 nginx 服务器负责将fastcgi 服务返回结果转发给客户端。
一个url:http://10.1.144.142:8090/fcgi_test?a=1
nginx应用程序看到的是http://10.1.144.142:8090/fcgi_test,根据fcgi_test “location”字段将问号后面参数部分"a=1"转发给fastcgi服务处理。因此fastcgi服务程序看到的是”a=1“
nginx安装
1. nginx安装依赖于openssl,pcre两个库。
分别下载三个库:nginx-0.8.53 , openssl-1.0.1c , pcre-8.31 解压到相应位置,进入nginx文件夹,configure的时候需要指定两个依赖库的路径,blog1中的my_configure脚本:
./configure --prefix=/usr/local/nginx \ --with-pcre=/home/nginx_software/pcre-8.31 \ --with-openssl=/home/nginx_software/openssl-1.0.1c \ --with-http_stub_status_module \ --with-http_ssl_modulenginx的安装目录:/usr/local/nginx,pcre解压路径是/home/nginx_software/pcre-8.31
安装步骤如下:
sh my_configuremake && make install
nginx配置
进入nginx安装目录 /usr/local/nginx/ 进入conf目录,打开nginx.conf配置文件,conf文件结构是server 监听不同端口,server下面有分location,在server内部添加如下code:
location /fcgi_test { fastcgi_pass 127.0.0.1:9000; include fastcgi_params; }
表示接收到 /fcgi_test 类型的请求 即分配给 监听9000的fastcgi服务程序。
nginx 启动、重启
1. 启动直接 ./nginx 即可
2. 其他操作:
在usr/local/nginx/sbin/ 目录下 ./nginx -h 帮助有一行:
-s signal : send signal to a master process: stop, quit, reopen, reload
./nginx -s reopen 重启。
spawn-fcgi
拉起自己开发的fastcgi 服务程序,监听9000端口,然后处理请求。
blog1中
/usr/local/nginx/sbin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 25 -f /usr/local/nginx/myFastCGI/helloFastCGI -F 1000
-F 参数,实测不正确去掉即可。
fast-cgi服务程序开发
就是再简单不过的C++程序开发,使用第三方库fast-cgi,生成的时候需要在Makefile中指定include,lib目录。
参见blog2中的类似hello-fcgi的代码框架。
测试
本地调用curl "http:// 127.0.0.1:8090/fcgi_test?a=1"
在客户端浏览器中键入 http://10.1.144.142:8090/fcgi_test?a=1
测试成功:
本人写的nginx服务器监听8090端口,没有使用默认端口,如果80端口可以不写端口号。
blog2中给出的Makefile 实测make时有错误,可采用此处的通用Makefile框架:http://blog.csdn.net/dizuo/article/details/7989411
TARGET改下服务名字即可。
参考:
1. blog1: http://www.cnblogs.com/xiaouisme/archive/2012/08/01/2618398.html
2. blog2: http://blog.csdn.net/yonghengkxh/article/details/8084460
- nginx fastcgi C++ 开发框架配置说明
- nginx+fastcgi+c/c++源码安装配置
- linux后台服务器开发环境部署配置和验证(nginx+apache+php-fpm+FASTCGI(C/C++))
- Nginx+FastCgi配置过程
- Nginx+FastCGI配置
- Django+nginx+fastcgi 配置
- Nginx+FastCGI(配置等)
- Nginx+FastCGI配置
- nginx php fastCGI配置
- nginx FastCGI 安装配置
- nginx+django+fastcgi配置
- nginx+fastcgi+c/c++搭建高性能Web框架
- nginx+fastcgi+c/c++搭建高性能Web框架
- nginx+fastcgi+c/c++搭建高性能Web框架
- nginx+fastcgi+c/c++搭建高性能Web框架
- nginx FastCGI模块(FastCGI)配置
- NginX中FastCGI的配置
- Nginx fastcgi模式 配置 php
- Linux 下判断空白字符串
- C#实现web信息自动抓取
- CRichEditCtrl知识收集
- “Microsoft Office Word 遇到问题需要关闭”的解决办法
- 我所使用的Chrome扩展——WEB开发配备
- nginx fastcgi C++ 开发框架配置说明
- jsp自定义标签(taglib)编写的原理和实现
- 人生10难
- MyEclipse10.6 安装xfire 插件
- AJAX的与服务器之间的信息传递原理(初学)
- Cocos2d-x游戏开发之单击事件_锁定触摸区域外的界面
- error L NK2005
- Maven生命周期
- 最新版本FFMPEG编译方法(strcasecmp)