解决公司jboss集群的问题,开始学习apache模块开发,开发的平台采用windows平台,是希望大家更加容易能够进入开发阶段,公司大部分都有vs2008.
1.安装apache 安装包 httpd-2.2.21-win32-x86-no_ssl.msi
一定要custom全部安装,否则就不会有include和lib目录
2.配置apxs
1)安装apxs 安装包apxs_win32
2)安装Strawberry Perl 安装包strawberry-perl-5.16.3.1-32bit.msi
3)进入dos命令提示符,转到apxs安装目录下,输入perl Configure.pl,按要求填写apache的安装目录...\apache2.2和命令名称“httpd.exe”
4)通过上一步,就会在apache2.2\bin下生成apxs命令,并且在apache2.2目录下生成了build目录
5)修改在apache2.2下build目录中的config_vars.mk文件
将CC = gcc 的gcc改为cl.exe ,LD = g++的g++改为link.exe,CPP = gcc-E的gcc-E删掉
6)设置apache下的bin的命令apxs的路径为环境变量,以放便在不进入具体安装目录下运行apxs
3.编译apache模块
1)运行Visual Studio 2008 命令提示(在开始的Microsoft Visual Studio 2008下可以找到)
2)运行apxs -g -n helloworld(helloworld为模块名),会生成一个叫helloworld的目录和模板代码
3)进入helloworld目录,编辑mod_helloworld.c
4)运行apxs -c -i -a mod_helloworld.c libapr-1.lib libaprutil-1.lib libapriconv-1.lib libhttpd.lib,生成mod_helloworld.so
5)将mod_helloworld.so拷贝到Apache2.2\modules下
6)修改Apache2.2\conf\httpd.conf,在末尾加上
LoadModule helloworld_module \modules\mod_helloworld.so
<Location /helloworld>
setHandler helloworld
</Location>
7)启动apache,在IE里输入http://loacalhost/helloworld
/* ** mod_helloworld.c -- Apache sample helloworld module ** [Autogenerated via ``apxs -n helloworld -g''] ** ** To play with this sample module first compile it into a ** DSO file and install it into Apache's modules directory ** by running: ** ** $ apxs -c -i mod_helloworld.c ** ** Then activate it in Apache's httpd.conf file for instance ** for the URL /helloworld in as follows: ** ** # httpd.conf ** LoadModule helloworld_module modules/mod_helloworld.so ** <Location /helloworld> ** SetHandler helloworld ** </Location> ** ** Then after restarting Apache via ** ** $ apachectl restart ** ** you immediately can request the URL /helloworld and watch for the ** output of this module. This can be achieved for instance via: ** ** $ lynx -mime_header http://localhost/helloworld ** ** The output should be similar to the following one: ** ** HTTP/1.1 200 OK ** Date: Tue, 31 Mar 1998 14:42:22 GMT ** Server: Apache/1.3.4 (Unix) ** Connection: close ** Content-Type: text/html ** ** The sample page from mod_helloworld.c */ #include "httpd.h" #include "http_config.h" #include "http_protocol.h" #include "ap_config.h" static int printitem(void *rec,const char *key,const char *value) { request_rec *r = rec; ap_rprintf(r,"<tr><th scope=\"row\">%s</th><td>%s</td></tr>\n",ap_escape_html(r->pool,key),ap_escape_html(r->pool,value)); return 1; } static void printtable(request_rec *r,apr_table_t *t,const char *caption,const char *keyhead,const char *valhead) { ap_rprintf(r,"<table><caption>%s</caption></table><thead><tr><th scope=\"col\">%s</th><th scope=\"col\">%s</th></tr></thead><tbody>",caption,keyhead,valhead); apr_table_do(printitem,r,t,NULL); ap_rputs("</tbody></table>\n",r); } /* The sample content handler */ static int helloworld_handler(request_rec *r) { ap_set_content_type(r,"text/html;charset=ascii"); ap_rputs("<!DOCUMENT HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n" "<html><head><title>Apache module devlop</title></head><body><h1>apache is back</h1>",r); printtable(r,r->headers_in,"request headers","header","value"); printtable(r,r->headers_out,"response headers","header","value"); ap_rputs("apache module develop from ibyoung.c\n", r); if (strcmp(r->handler, "helloworld")) { return DECLINED; } r->content_type = "text/html"; if (!r->header_only) ap_rputs("run success.c\n", r); ap_rputs("</body></html>",r); return OK; } static void helloworld_register_hooks(apr_pool_t *p) { ap_hook_handler(helloworld_handler, NULL, NULL, APR_HOOK_MIDDLE); } /* Dispatch list for API hooks */ module AP_MODULE_DECLARE_DATA helloworld_module = { STANDARD20_MODULE_STUFF, NULL, /* create per-dir config structures */ NULL, /* merge per-dir config structures */ NULL, /* create per-server config structures */ NULL, /* merge per-server config structures */ NULL, /* table of config file commands */ helloworld_register_hooks /* register hooks */ };
相关推荐
Apache模块开发指南
apache可以通过扩展它的模块来实现自定义功能,apache 模块开发的例子,欢迎交流。
apache模块开发指南,汉语版,很辛苦找到的。
自己在项目开发中用到的apache模块开发工具apxs,重要的是这个工具在windows环境下的安装方法和使用方法,非常珍贵,泣血推荐
《LAMP技术精品书廊•Apache模块开发指南》主要介绍了Apache模块开发的全过程。全面细致、深入浅出,主要内容包括Apache相关背景、APR的基础知识,以及利用Apache模块开发的全过程,适合广大在Apache环境下的模块...
Apache的开发人员认识到Apache 最初的架构具有局限性,比较粗糙,于是在2000年开始建立新的代码仓库(codebase)主分支,并在此代码仓库的基础上于2002年4月创建了Apache2.0的第一个发布版本。Apache 2包括以下优良...
学习apache模块开发的基础学习文档,非常好用。
apache模块开发资料,由于项目需要,都是入门级读物。
记得刚开始的时候想进行apache模块开发的时候找了好多资料,不过大都是英文文档,几乎没有做系统讲解的。国内的图书更是没有这方面的,在Amozon搜索了下,找到了《Writing Apache Modules with Perl and C》和《The ...
apache扩展模块开发工具,可以在Windows平台下生成并编译模块文件(*.so)。将文件放在apache的bin目录下。 生成一个模块文件命令语法: apxs -g -n helloworld。 该命令会自动生成一个文件夹helloworld,并含有mod_...
写一个APACHE2.0的MOD模块,读取配置,并对所有后缀为.hello的请求进行处理。
C语言-apache mod(模块开发)-采用VS2017开发范例
php 开发指南pdf
mod_wsgi 是一个 Apache 模块,实现了 Python WSGI 接口服务
C语言-apache mod(模块开发)-采用centos7.2 apxs的开发范例
我在改造APACHE服务器授权访问时,需要对不合法的客户端请求进行过滤。对不合法请求需要立即发送一个错误提示页面给客户端。 发送错误提示页面的程序片断如下: //非法请求作错误跳转 char *location...
安装apache mysql php 手册 开发apache扩展模块方法, php扩展模块方法