apache添加fastcgi支持
A,安装apache服务器和fastcgi模块支持(ubuntu测试)
sudo apt-get install apache2
sudo apt-get install libapache2-mod-fastcgi
apache2的配置文件目录如下:
ciaos@ubuntu:/etc/apache2$ ll
total 80
drwxr-xr-x 7 root root 4096 May 28 21:33 ./
drwxr-xr-x 93 root root 4096 May 28 21:44 ../
-rw-r--r-- 1 root root 8346 Feb 7 2012 apache2.conf
drwxr-xr-x 2 root root 4096 May 28 21:32 conf.d/
-rw-r--r-- 1 root root 1322 Feb 7 2012 envvars
-rw-r--r-- 1 root root 0 May 28 21:32 httpd.conf
-rw-r--r-- 1 root root 31063 Feb 7 2012 magic
drwxr-xr-x 2 root root 4096 May 28 21:36 mods-available/
drwxr-xr-x 2 root root 4096 May 28 21:36 mods-enabled/
-rw-r--r-- 1 root root 750 Feb 7 2012 ports.conf
drwxr-xr-x 2 root root 4096 May 28 21:58 sites-available/
drwxr-xr-x 2 root root 4096 May 28 21:58 sites-enabled/
配置fastcgi目录,只需要修改sites-enabled/000-default文件添加fastcgi的目录结构
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory> ScriptAlias /fcgi-bin/ /var/lib/apache2/fastcgi/
<Directory "/var/lib/apache2/fastcgi">
AllowOverride None
Options FollowSymLinks
Order allow,deny
Allow from all
SetHandler fastcgi-script
</Directory>
重启apache服务器如下:
sudo apachectl -k restart
B,接下来写fastcgi程序测试(用C来测试)
1,安装fastcgi库
make的时候如果出现“error: 'EOF' was not declared in this scope”错误,则在出错文件加上#include <stdio.h>
2,编辑个简单的fastcgi程序
#include <fcgi_stdio.h> int main()
{
int count = ;
while(FCGI_Accept() >= ) {
printf("Content-type: text/html\r\n");
printf("\r\n");
printf("Hello world!<br>\r\n");
printf("Request number %d.", count++);
}
return ;
}
3,编译并放到apache的cgi和fcgi目录下测试
gcc sim.c -lfcgi -o test.cgi
cp test.cgi /usr/lib/cgi-bin/
访问 http://192.168.1.108/cgi-bin/test.cgi , 每次打印Request number都是0 gcc sim.c -lfcgi -o test.fcgi
cp test.fcgi /var/lib/apache2/fastcgi/
访问 http://192.168.1.108/cgi-bin/test.fcgi , 每次打印Request number都会递增
附:如果ldd找不到依赖库,三种方法如下
1,export LD_LIBRARY_PATH=/usr/local/lib/
2,直接把so文件拷贝到/lib/目录下,这个目录一般都是
3,/etc/ld.so.conf添加响应目录, /sbin/ldconfig –v更新
apache添加fastcgi支持的更多相关文章
- apache添加php支持
在php编译安装好后,需要在apache中添加对php的支持,方法:找到“#AddType application/x-gzip .gz .tgz”并在后面加入AddType application/ ...
- Apache添加ssl支持
安装证书文件说明:1. 证书文件xxx.pem,包含两段内容,请不要删除任何一段内容.2. 如果是证书系统创建的CSR,还包含:证书私钥文件xxx.key.证书公钥文件public.pem.证书链文件 ...
- ubuntu下apache添加https支持
http是无状态,不安全的连接.而https是通过ssl加密的http连接,可靠性更强. 确保openssl安装完成,用openssl来产生和签署证书,可以自己签署,但是不安全,建议用证书机构颁发的证 ...
- linux后台server开发环境的部署配置和验证(nginx+apache+php-fpm+FASTCGI(C/C++))
linux后台server开发环境部署配置 引言 背景 随着互联网业务的不断增多.开发环境变得越来越复杂,为了便于统一server端的开发部署环境,特制定本配置文档. 使用软件 CentOS 6.3( ...
- Spring Boot 添加Shiro支持
前言: Shiro是一个权限.会话管理的开源Java安全框架:Spring Boot集成Shiro后可以方便的使用Session: 工程概述: (工程结构图) 一.建立Spring Boot工程 参照 ...
- 配置apache以fastcgi运行php
apache默认是用自带的mod_php模块运行php,现在我们介绍使用fastcgi来执行php脚本.先说下fastcgi的优点: Fastcgi的优点: 从稳定性上看, fastcgi是以独立的进 ...
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持
上篇博客使用Spring Boot开发Web项目我们简单介绍了使用如何使用Spring Boot创建一个使用了Thymeleaf模板引擎的Web项目,当然这还远远不够.今天我们再来看看如何给我们的We ...
- 手动添加SSH支持、使用c3p0
之前做的笔记,现在整理一下:大家有耐心的跟着做就能成功: SSH(struts2.spring.hibernate) * struts2 * 充当mvc的角色 * hibernate ...
- Spring Boot 添加JSP支持【转】
Spring Boot 添加JSP支持 大体步骤: (1) 创建Maven web project: (2) 在pom.xml文件添加依赖: (3) ...
随机推荐
- C++_知识点_namespace
#include <iostream> #include <string> using namespace std; void name() { cout << & ...
- PHPEXCEL导入小技巧
在导入excel的时候,单元格格式和公式经常让导入不顺畅.注意phpexcel文档说明,基本上就可以很顺利的导入. 1.忽略单元格格格式,并导入xls.xlsx两种格式 $objReader = PH ...
- Spring jdbcTemplate + EasyUI 物理分页
前文说到,新项目中,用到的是SpringMVC + jdbcTemplate,前台是EasyUI,发现同事以前封装分页是逻辑分页,于是,自己动手封装了下物理分页. 这个是核心分页实体: import ...
- 浅谈 non-blocking I/O Multiplexing + poll/epoll 的正确使用
在前面的文章中曾经粗略讲过poll,那时是用阻塞IO实现,在发送和接收数据量都较小情况下和网络状况良好的情况下是基本没有问题的,read 不会只接收部分数据,write 也不会一直阻塞.但实际上pol ...
- R与数据分析旧笔记(四)画地图练习
> library(maps) > library(geosphere) 载入需要的程辑包:sp > map("state")#画美国地图 > map(&q ...
- 单例模式java实现
package Counter; public class Counter { private int counter; private static Counter instance ...
- 决策树ID3算法[分类算法]
ID3分类算法的编码实现 <?php /* *决策树ID3算法(分类算法的实现) */ /* *求信息增益Grain(S1,S2) */ //-------------------------- ...
- 安卓里面JSON处理和JAVA SE里面的JSON包
今天编译安卓项目遇到这个问题 com.android.dex.DexException: Multiple dex files define的解决办法 大致意思就是引用了 相同的包 在JAVA SE里 ...
- Garbage
垃圾回收 http://journal.stuffwithstuff.com/2013/12/08/babys-first-garbage-collector/ http://blog.jobbole ...
- issues about Facebook Login
在学习The complete iOS 9 Developer Course - Build 18 Apps 中的Letture134-Facebook Login,需要整合(integrate)Pa ...