1、安装mod_headers.c模块[root@localhost ~]# cd /usr/local/src/httpd-2.2.16/modules
[root@localhost modules]# ls
aaa database experimental ldap mappers README
arch dav filters loggers metadata ssl
cache debug generators Makefile NWGNUmakefile test
config5.m4 echo http Makefile.in proxy
[root@localhost modules]# cd metadata/
[root@localhost metadata]# /usr/local/apache2/bin/apxs -i -a -c -n headers mod_headers.c
//用apxs工具添加模块
2、修改Apache配置文件[root@localhost htdocs]# vim /usr/local/apache2/conf/httpd.conf
Header add MyHeader "hello"
3、测试[root@localhost htdocs]# curl -I 192.168.0.104/1.php
HTTP/1.1 200 OK
Date: Sat, 19 Apr 2014 02:45:13 GMT
Server: Apache/2.2.16 (Unix) PHP/5.3.27
X-Powered-By: PHP/5.3.27
MyHeader: hello //定义的header
Content-Type: text/html