- 搭建静态网站——基于https协议的静态网站
1 安装ssl
切记:一定要先关防火墙 关selinux 不然会浪费你很长时间你都找不出你哪里错了
# yum install mod_ssl -y
#cd /etc/pki/tls/certs/
2.创建加密认证
3.编辑配置文件(这里的安全配置在/etc/httpd/conf.d/ssl文件下,需复制如下SSLEngine5行,并修改.crt与.key为创建时的名字)
4.重启httpd服务使生效
5.测试
- 动态网站搭建
1、安装包mod_wsgi //web server Gateway Interface// alt 属性是一个必需的属性,它规定在图像无法显示时的替代文本
# yum install mod_wsgi -y
2、编辑配置文件
3、创建目录
# mkdir www/alt
配置python脚本内容
(此处可直接复制粘贴)
def application(environ, start_response):
status = '200 OK'
output = 'Hello World'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
application 是一个接受接受两个参数environ, start_response的标准 wsgi app:
environ: 一个包含请求信息及环境信息的字典, server 端会详细说明
start_response: 一个接受两个参数`status, response_headers`的方法:
status: 返回状态码,如 http 200 、 404 等
response_headers: 返回信息头部列表
测试
编辑配置文件
创建目录并编辑页面内容
# mkdir /www/haha
# echo this is https > /www/haha/index.html
加入访问权限
测试