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) ...
随机推荐
- SGU 310. Hippopotamus( 状压dp )
题目大意:给N块板, 有A,B2种类型的板, 要求任意M块连续的板中至少有K块B板.1≤n≤60,1≤m≤15,0≤k≤m≤n. dp(x, s)表示第x块板, x前M块板的状态为s, 然后合法状态转 ...
- div模拟滚动条
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="html.aspx.cs&q ...
- [Java]利用栈判断括号是否完整配对
利用栈实现判断字符串中的括号是否都是配对的. 主要算法是依次读取字符串中的每一个字符,如果是左括号则将左括号压入栈中,如果是右括号则从栈中弹出最上面的字符,若两者不是同种括号或栈内已经没有字符就返回f ...
- Linux内核和驱动编译常见问题
1.获取内核源码应为 git clone depth=1 不然编译时会报错 2.有些RTL188CUS网卡与wpa_supplicant兼容有问题 更新wpasupplicant或许能解决 这里用i ...
- 由Mifare 1卡破解带来的危险以及应对方法
今年年初以来,一个消息的传出震惊了整个IC卡行业.最近,德国和美国的研究人员成功地破解了NXP的Mifare1芯片的安全算法.Mifare1芯片主要用于门禁系统访问控制卡,以及一些小额支付卡,应用范围 ...
- php 前端获取数据
<pre name="code" class="python"><!doctype html> <html lang=" ...
- VS2010/MFC对话框:字体对话框
字体对话框) 在上一节为大家讲解了文件对话框的使用,本节则主要介绍字体对话框如何应用. 字体对话框的作用是用来选择字体.我们也经常能够见到.MFC使用CFontDialog类封装了字体对话框的所有操作 ...
- 关于oracle spfile配置文件问题
$ORACLE_SID决定spfile dbs 默认 在启动Oracle数据库时报错,如下: [oracle@localhost ~]$ sqlplus / as sysdba SQL*Plus: R ...
- CATransition类动画
- (void)leftClick { [UIView beginAnimations:nil context:nil]; //display mode, slow at beginning and ...
- What Is Your Grade?(水,排序)
What Is Your Grade? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Othe ...