1.网页加密访问https
1.https定义
HTTPS(全称:Hyper Text Transfer Protocol over Secure Socket Layer 或 Hypertext Transfer Protocol Secure,超文本传输安全协议),是以安全为目标的HTTP通道,简单讲是HTTP的安全版。即HTTP下加入SSL层,HTTPS的安全基础是 SSL,因此加密的详细内容就需要SSL。 它是一个URI scheme(抽象标识符体系),句法类同http:体系。用于安全的HTTP数据传输。https:URL表明它使用了HTTP,但HTTPS存在不同于HTTP的默认端口及一个加密/身份验证层(在HTTP与TCP之间)。这个系统的最初研发由网景公司(Netscape)进行,并内置于其浏览器Netscape Navigator中,提供了身份验证与加密通讯方法。现在它被广泛用于万维网上安全敏感的通讯,例如交易支付方面。
2.配置
yum install mod_ssl -y
yum install crypto-utils -y
genkey www.westos.com
Next
1024 Next
读条不动,就在server打点字
这个地方一定要选NO
Next不输入任何东西
output will be written to /etc/pki/tls/certs/www.westos.com.crt
output key written to /etc/pki/tls/private/www.westos.com.key
/etc/pki/tls/private/www.westos.com.key
/etc/pki/tls/certs/www.westos.com.crt
怎样让网站强制走https(443端口)
vim /etc/httpd/conf.d/login.conf
<Virtualhost *:443>
ServerName "login.westos.com"
DocumentRoot "/var/www/virtual/login.westos.com/html"
CustomLog "logs/login.log" combined
SSLEngine on ##开始https功能
SSLCertificateFile /etc/pki/tls/certs/www.westos.com.crt #证书
SSLCertificateKeyFile /etc/pki/tls/private/www.westos.com.key ##密钥
</Virtualhost>
<Directory "/var/www/virtual/login.westos.com/html">
Require all granted
</Directory>
<Virtualhost *:80> ##网页重写实现自动访问https
ServerName login.westos.com
RewriteEngine on
RewriteRule ^(/.*)$ https://%{HTTP_HOST}$1 [redirect=301]
</Virtualhost>
解释:
- ^(/.*)$ https://%{HTTP_HOST}$1 [redirect=301]
- ^(/.*)$ 客户主机在地址栏中写入的所有字符,不包含换行符
- https:// 强制客户加密访问
- %{HTTP_HOST} 客户请求主机
- $1 $1的值就表示^(/.*)$的值
- [redirect=301] 301永久重定向,302临时重定向
mkdir /var/www/virtual/login.westos.com/html -p
vim /var/www/virtual/login.westos.com/html/index.html
systemctl restart httpd
测试:
在客户主机中添加解析
vim /etc/hosts
172.25.254.100 login.westos.com
访问http://login.westos.com 会自动跳转到
https://login.westos.com 实现网页数据加密传输
2.使网页支持python脚本
自己写一个python脚本webapp.wsgi
放在/var/www/cgi-bin下
chmod +x webapp.wsgi 加执行权限
yum install mod_wsgi.x86_64 安装需要的软件
vim /etc/httpd/conf.d/webapp.conf
<VirtualHost *:80>
ServerName webapp.westos.com
DocumentRoot /var/www/cgi-bin
Customlog logs/webapp.log combined
WSGIScriptAlias / /var/www/cgi-bin/webapp.wsgi
</VirtualHost>
systemctl restart httpd.service
测试:
如果403
setenforce 0
3.建立网页论坛
mkdir /var/www/virtual/bbs/html -p 建立网页论坛目录
配置文件
vim bbs.conf
<Virtualhost *:80>
ServerName "bbs.westos.com"
DocumentRoot "/var/www/virtual/bbs/html"
CustomLog "logs/bbs.log" combined
</Virtualhost>
<Directory "/var/www/virtual/bbs/html">
Require all granted
</Directory>
unzip Discuz_X3.2_SC_UTF8.zip 在网页论坛目录中解压文件(可以在百度中搜索)
*若不是在其中解压可能会造成安全上下文不同
配置环境:
安装php
cd upload/
chmod -R 777 config/
chmod -R 777 data/
chmod -R 777 uc_server/
chmod -R 777 uc_client/
yum install mariadb-server.x86_64 安装数据库
systemctl start mariadb
systemctl enable mariadb
mysql_secure_installation 安全初始化(参考数据库章节)
yum install php-mysql.x86_64 安装php-mysql
systemctl restart httpd.service 重启服务生效
访问:
vim /etc/hosts
添加bbs.westos.com
http://bbs.westos.com/upload/
开始安装,看需要什么就改什么
此为缺少php-mysql
下一步安装
安装完成后如图所示