1、安装mod_headers.c模块
[root@localhost ~]# cd /usr/local/src/httpd-2.2.16/modules[root@localhost modules]# lsaaa database experimental ldap mappers READMEarch dav filters loggers metadata sslcache debug generators Makefile NWGNUmakefile testconfig5.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.confHeader add MyHeader "hello"
3、测试
[root@localhost htdocs]# curl -I 192.168.0.104/1.phpHTTP/1.1 200 OKDate: Sat, 19 Apr 2014 02:45:13 GMTServer: Apache/2.2.16 (Unix) PHP/5.3.27X-Powered-By: PHP/5.3.27MyHeader: hello //定义的headerContent-Type: text/html