RHCE三--- HTTP、HTTPS搭建静态网页
目录
1、配置 /etc/httpd/conf.d/vhosts.conf(首先确保安装httpd)
3、写入相应内容到相应目录下的 index.hcml文件中(网页显示的内容)
4、配置缴费网站(www.openlab.com/money)基于https访问
(3)修改 /etc/httpd/conf.d/vhosts.conf 下的关于www.openlab.com/money部分
1、在缓存文件 /etc/hosts 中添加 IP 与域名信息
3、只有 song 和 tian 可以访问www.openlab.com/student,其他用户不能访问
一、http配置文件
1、httpd主配置文件在 /etc/httpd/conf/httpd.conf
2、额外的参数文件 /etc/httpd/conf.d/*.conf
3、设置默认访问apache欢迎界面的配置文件 /etc/httpd/conf.d/welcome.conf
4、apache欢迎界面的具体文件 /usr/share/httpd/noindex/index.html
5、默认的首页所在目录/var/www/html/,当输入网址时所显示的数据,就是放在这个目录当中的首页文件(默认为index.html)
6、自己定义的静态页面是在/var/www/html目录,因为主配置文件中DocumentRoot "/var/www/html" #网页文件存放的目录
7、静态网页的名字是index.html 是因为主配置文件中目录模块配置的目录索引,索引文件名为index.html
<IfModule dir_module> #加载一个目录模块
DirectoryIndex index.html
</IfModule>8、默认给一些可执行的CGI(网页程序)程序放置的目录/var/www/cgi-bin/,当输入网址/cgi-bin/时所显示的数据所在
9、默认的Apache日志文件都放在/var/log/httpd/
二、综合练习:请给openlab搭建web网站
1.基于域名[www.openlab.com](http://www.openlab.com)可以访问网站内容为 welcome to openlab!!!
2.给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站[www.openlab.com/student(http://www.openlab.com/student) 网站访问学生信息
[www.openlab.com/data](http://www.openlab.com/data)网站访问教学资料
[www.openlab.com/money](http://www.openlab.com/money网站访问缴费网站)3.要求(1)学生信息网站只有song和tian两人可以访问,其他用户不能访问
(2)访问缴费网站实现数据加密基于https访问
1、配置 /etc/httpd/conf.d/vhosts.conf(首先确保安装httpd)
-
[]
-
-
-
<Virtualhost 192.168.225.140:80>
-
DocumentRoot /www/openlab
-
ServerName www.openlab.com
-
</Virtualhost>
-
-
<Virtualhost 192.168.225.140:80>
-
DocumentRoot /www/openlab/student
-
ServerName www.openlab.com/student
-
</Virtualhost>
-
-
<Virtualhost 192.168.225.140:80>
-
DocumentRoot /www/openlab/data
-
ServerName www.openlab.com/data
-
</Virtualhost>
-
-
<Virtualhost 192.168.225.140:80>
-
DocumentRoot /www/openlab/money
-
ServerName www.openlab.com/money
-
</Virtualhost>
-
-
<Directory /www/openlab>
-
AllowOverride none
-
Require all granted
-
</Directory>
-
-
//用户认证
-
<Directory /www/openlab/student>
-
AuthType Basic //基本认证类型
-
AuthName "Please login:" //提示信息
-
AuthUserFile /etc/httpd/userfile //用户认证文件的用户名和密码指定的文件所在位置
-
Require user song //指定哪个用户可以访问服务器
-
Require user tian
-
</Directory>
-
2、创建对应目录和用户
-
[]
-
mkdir: created directory '/www'
-
mkdir: created directory '/www/openlab'
-
mkdir: created directory '/www/openlab/student'
-
mkdir: created directory '/www/openlab/data'
-
mkdir: created directory '/www/openlab/money'
-
-
[]
-
New password:
-
Re-type new password:
-
Adding password for user song
-
[]
-
New password:
-
Re-type new password:
-
Adding password for user tian
-
[]
-
New password:
-
Re-type new password:
-
Adding password for user wu
3、写入相应内容到相应目录下的 index.hcml文件中(网页显示的内容)
-
[]
-
[]
-
[]
-
[]
4、配置缴费网站(www.openlab.com/money)基于https访问
(1)安装mod_ssl 加密模块
[root@server ~]# yum install mod_ssl -y
-
[]
-
-
<VirtualHost _default_:443>
-
SSLEngine on //开启ssl认证访问
-
SSLCertificateFile /etc/pki/tls/certs/localhost.crt //指定证书路径
-
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key //指定私钥文件路径
(2)生成证书
-
[]
-
Generating a RSA private key
-
..........................................................................................
-
.............................................................
-
writing new private key to '/etc/pki/tls/private/openlab.key'
-
-----
-
You are about to be asked to enter information that will be incorporated
-
into your certificate request.
-
What you are about to enter is what is called a Distinguished Name or a DN.
-
There are quite a few fields but you can leave some blank
-
For some fields there will be a default value,
-
If you enter '.', the field will be left blank.
-
-----
-
Country Name (2 letter code) [XX]:86
-
State or Province Name (full name) []:shannxi
-
Locality Name (eg, city) [Default City]:xi'an
-
Organization Name (eg, company) [Default Company Ltd]:openlab
-
Organizational Unit Name (eg, section) []:ce
-
Common Name (eg, your name or your server's hostname) []:xixi
-
Email Address []:ada
-
-
[]
-
total 4
-
-rw-------. 1 root root 3272 Sep 6 20:45 openlab.key
-
[]
-
total 4
-
lrwxrwxrwx. 1 root root 49 Jun 17 2021 ca-bundle.crt -> /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
-
lrwxrwxrwx. 1 root root 55 Jun 17 2021 ca-bundle.trust.crt -> /etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt
-
-rw-r--r--. 1 root root 2057 Sep 6 20:50 openlab.crt
(3)修改 /etc/httpd/conf.d/vhosts.conf 下的关于www.openlab.com/money部分
-
[]
-
-
<Virtualhost 192.168.225.140:443> //修改端口为443
-
DocumentRoot /www/openlab/money
-
ServerName www.openlab.com/money
-
SSLEngine on //开启ssl认证访问
-
SSLCertificateFile /etc/pki/tls/certs/openlab.crt //指定证书路径
-
SSLCertificateKeyFile /etc/pki/tls/private/openlab.key //指定私钥文件路径
-
</Virtualhost>
5、重启服务
[root@server ~]# systemctl restart httpd
三、测试
1、在缓存文件 /etc/hosts 中添加 IP 与域名信息
-
[]
-
-
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
-
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
-
192.168.225.140 www.openlab.com
2、访问www.openlab.com
-
[]
-
welcome to openlab
3、只有 song 和 tian 可以访问www.openlab.com/student,其他用户不能访问
-
[]
-
Enter host password for user 'song':
-
student information
-
[]
-
Enter host password for user 'tian':
-
student information
-
[]
-
Enter host password for user 'wu':
-
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
-
<html><head>
-
<title>401 Unauthorized</title> //请求未经授权
-
</head><body>
-
<h1>Unauthorized</h1>
-
<p>This server could not verify that you
-
are authorized to access the document
-
requested. Either you supplied the wrong
-
credentials (e.g., bad password), or your
-
browser doesn't understand how to supply
-
the credentials required.</p>
-
</body></html>
-
4、访问www.openlab.com/data
-
[]
-
teaching information
5、数据加密访问www.openlab.com/money
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /boutique/detail/tanhgejjkg
-
photoshop保存的图片太大微信发不了怎么办
PHP中文网 06-15 -
Android 11 保存文件到外部存储,并分享文件
Luke 10-12 -
《学习通》视频自动暂停处理方法
HelloWorld317 07-05 -
word里面弄一个表格后上面的标题会跑到下面怎么办
PHP中文网 06-20 -
photoshop扩展功能面板显示灰色怎么办
PHP中文网 06-14 -
微信公众号没有声音提示怎么办
PHP中文网 03-31 -
excel下划线不显示怎么办
PHP中文网 06-23 -
excel打印预览压线压字怎么办
PHP中文网 06-22 -
怎样阻止微信小程序自动打开
PHP中文网 06-13 -
TikTok加速器哪个好免费的TK加速器推荐
TK小达人 10-01