本文讲述http的CGI、HTTPS、压缩等选项的配置。本文所用环境还是上一次编译安装后的环境,编译安装的博文http://wangfeng7399.blog.51cto.com/3518031/1379373
一、CGI的配置
我们假设在wangfeng7399的目录有一个cgi-bin目录,在目录中有一个可执行的脚本3,内容如下
#!/bin/bash cat << EOF Content-Type: text/html <pre> echo "hello" echo "new Time is : `date`" </pre> EOF ~
我们希望能在访问脚本3的时候,能够将date显示出来
1)、先启动cgi和alias模块
LoadModule alias_module modules/mod_alias.so LoadModule alias_module modules/mod_alias.so
2)、修改主配置文件
<IfModule alias_module> ScriptAlias /cgi-bin/ "/www/html/wangfeng7399/cgi-bin/" </IfModule> <Directory "/www/html/wangfeng7399/cgi-bin/"> AllowOverride None Options None Require all granted </Directory>
3)为全局配置文件添加二进制可执行选项
<Directory "/www/html"> Options Indexes FollowSymLinks ExecCGI </Directory>
4)测试
二、文件的压缩
1)、启动压缩模块
LoadModule deflate_module modules/mod_deflate.so
2)、书写压缩模块的格式
验证
我们可以看到在返回的报文中gzip的压缩了
三、基于https登陆服务器
1)、生成证书
关于如何生成自签证书和为客户端签署证书,请移步我的相关博文http://wangfeng7399.blog.51cto.com/3518031/1370098
2)、开启ssl功能,修改主配置文件
LoadModule ssl_module modules/mod_ssl.so
3)、修改配置文件
<VirtualHost _default_:443> # General setup for the virtual host DocumentRoot "/www/html/wangfeng7399" ServerName www.wangfeng7399.com:443 SSLCertificateFile "/etc/httpd24/ssl/http.crt" //证书的位置 SSLCertificateKeyFile "/etc/httpd24/ssl/http.key" //密钥的位置
4)、初步测试
没有可信的证书,我们点继续浏览
将CA证书和网站的证书导入到我们的测试机里面,其中要加CA的证书安装在可信任的根证书里面
访问成功,大功告成!!
由于本人水平有限,可能会有错误,欢迎大家批评指正!