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++输出中文字符(转)
C++输出中文字符 1. cout 场景1: 在源文件中定义 const char* str = "中文" 在 VC++ 编译器上,由于Windows环境用 GBK编码,所以字符串 ...
- CF 599D Spongebob and Squares(数学)
题目链接:http://codeforces.com/problemset/problem/599/D 题意:定义F(n,m)为n行m列的矩阵中方阵的个数,比如3行5列的矩阵,3x3的方阵有3个.2x ...
- day2_python学习笔记_chapter4_标准类型和内建函数
1. 标准类型 Integer,Boolean, Long integer, Floating point real number, Complex number, String, List, Tup ...
- Ie浏览器TextBox文本未居中
Ie浏览器TextBox文本未居中,而其他浏览器无问题时,可能原因是未设置垂直居中 vertical-align:middle
- ImageView 各种工具类
package imageUtil; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOut ...
- javascript--时钟
<head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" ...
- label 和 legend标签的用法
label 和 legend标签的用法 label标准用法: 一般浏览器都支持 一般而言,label标签位于表单元素的前面或者后面,为控件提供说明文字 <label for="user ...
- bootstrap 更改container 的width
参考:http://stackoverflow.com/questions/15884102/bootstrap-how-do-i-change-the-width-of-the-container ...
- Java的接口及实例
一.定义 Java接口(Interface),是一系列方法的声明,是一些方法特征的集合,一个接口只有方法的特征没有方法的实现,因此这些方法可以在不同的地方被不同的类实现,而这些实现可以具有不同的行为( ...
- uva 10763 Foreign Exchange(排序比较)
题目连接:10763 Foreign Exchange 题目大意:给出交换学生的原先国家和所去的国家,交换成功的条件是如果A国给B国一个学生,对应的B国也必须给A国一个学生,否则就是交换失败. 解题思 ...