Linux之web服务搭建静态网页------综合练习
网站需求
1、基于域名www.openlab.com可以访问网站内容为welcome to openlab!!!
修改配置文件
[root@redhat ~]# vim /etc/httpd/conf.d/vhost.conf
<VirtualHost 192.168.159.128:80>DocumentRoot /www/openlabServerName www.openlab.com
</VirtualHost><Directory /www>AllowOverride noneRequire all granted
</Directory>
重启服务、关闭防火墙、关闭selinux
[root@redhat ~]# systemctl restart httpd
[root@redhat ~]# systemctl stop firewalld
[root@redhat ~]# setenforce 0
根据配置文件添加资源文件
[root@redhat ~]# mkdir /www/openlab
[root@redhat ~]# echo welcome to openlab! > /www/openlab/index.html
修改hosts文件
[root@redhat ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.159.128 www.openlab.com
使用curl命令查看网页资源
[root@redhat ~]# curl www.openlab.com
welcome to openlab!
2、给该公司创建三个子页面分别显示学生信息,教学资料和缴费网站,基于www.openlab.com/student网站访问学生信息,www.openlab/data网站访问教学资料,www.openlab.com/money网站访问缴费网站。
修改配置文件
[root@redhat ~]# vim /etc/httpd/conf.d/vhost.conf
<VirtualHost 192.168.159.128:80>DocumentRoot /www/openlabalias /student /openlab/studentalias /data /openlab/dataalias /money /openlab/moneyServerName www.openlab.com
</VirtualHost><Directory /www>AllowOverride noneRequire all granted
</Directory><Directory /openlab>AllowOverride noneRequire all granted
</Directory>
重启服务
[root@redhat ~]# systemctl restart httpd
根据配置文件创建网页资源
[root@redhat ~]# mkdir -p /openlab/{student,data,money}
[root@redhat ~]# echo this is a student > /openlab/student/index.html
[root@redhat ~]# echo this is data > /openlab/data/index.html
[root@redhat ~]# echo this is money > /openlab/money/index.html
在linux查看
[root@redhat ~]# curl www.openlab.com/student/
this is a student
[root@redhat ~]# curl www.openlab.com/data/
this is data
[root@redhat ~]# curl www.openlab.com/money/
this is money
3、要求(1)学生信息网站只有song和tian两个人可以访问,其他用户不能访问。 (2)访问缴费网站实现数据加密基于https访问
(1)
修改配置文件
[root@redhat ~]# vim /etc/httpd/conf.d/vhost.conf
<Directory /openlab/student> AuthType Basic AuthName "qing shu ru"AuthUserFile /etc/httpd/users Require user song tian
</Directory>
重启服务
[root@redhat ~]# systemctl restart httpd
添加用户
注意多次添加用户不要加-c选项否则添加的用户信息覆盖前面的用户
[root@redhat ~]# htpasswd -c /etc/httpd/users song
New password:
Re-type new password:
Adding password for user song
[root@redhat ~]# htpasswd /etc/httpd/users tian
New password:
Re-type new password:
Adding password for user tian
(2)
下载工具
[root@redhat ~]# yum install mod_ssl -y
生成私钥并输入通行语句
[root@redhat ~]# openssl genrsa -aes128 2049 > /etc/pki/tls/private/openlab.key
Generating RSA private key, 2049 bit long modulus (2 primes)
...................................................+++++
................................................+++++
e is 65537 (0x010001)
Enter pass phrase:
Verifying - Enter pass phrase:
生成证书文件
输入私钥通行语句
[root@redhat ~]# openssl req -utf8 -new -key /etc/pki/tls/private/openlab.key -x509 -days 365 -out /etc/pki/tls/certs/openlab.crt
Enter pass phrase for /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) []:shannx
Locality Name (eg, city) [Default City]:xian
Organization Name (eg, company) [Default Company Ltd]:openlab
Organizational Unit Name (eg, section) []:phce
Common Name (eg, your name or your server's hostname) []:localhost
Email Address []:admin@admin.com
修改配置文件
[root@redhat ~]# vim /etc/httpd/conf.d/vhost.conf
<VirtualHost 192.168.159.128:443>SSLEngine onSSLCertificateFile /etc/pki/tls/certs/openlab.crtSSLCertificateKeyFile /etc/pki/tls/private/openlab.keyDocumentRoot /www/openlabalias /money /openlab/moneyServerName www.openlab.com
</VirtualHost>
<Directory /openlab>AllowOverride noneRequire all granted
</Directory>
重启服务
需要输入之前生成密钥时所需的enter pass phrase
[root@redhat ~]# systemctl restart httpd
Enter TLS private key passphrase for www.openlab.com:443 (RSA) : *****************
查看
[root@redhat ~]# curl https://www.openlab.com/money/
curl: (60) SSL certificate problem: self signed certificate in certificate chain
More details here: https://curl.haxx.se/docs/sslcerts.htmlcurl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
Linux之web服务搭建静态网页------综合练习相关推荐
- [Linux CentOS7] Web服务器搭建和设置
[Linux CentOS7] Web服务器搭建和设置 题目 基本网络配置 问题1 问题2 问题3 问题4 问题5 环境: VMware workstation14 CentOS 7 题目 请完成以下 ...
- Linux Java Web 服务器搭建之tomcat安装
Linux Java Web 服务器搭建之tomcat安装 一 Tomcat 简介 Tomcat 服务器是一个免费的开放源代码的Web 应用服务器,属于轻量级应用服务器,在中小型系统和并发访问用户不是 ...
- 静态网页怎么搭建在服务器上,云服务器搭建静态网页教程
云服务器搭建静态网页教程 内容精选 换一换 为系统添加静态路由,避免重启系统后路由丢失而影响到网络可用性.以CentOS 6.5操作系统为例.登录弹性云服务器.创建或修改静态路由配置文件.在/etc/ ...
- Web服务搭建 - Apache
Web服务搭建 - Apache Web服务器搭建 Web服务介绍 服务器与浏览器利用HTTP协议进行交互的过程 统一资源定位符URL Apache服务器 配置Apache服务 搭建基础web服务 建 ...
- DIV布局——化妆品商城-功能齐全(43页) HTML+CSS+JavaScript web大作业 静态网页
HTML5期末大作业:化妆品商城网站设计--化妆品商城-功能齐全(43页) HTML+CSS+JavaScript web大作业 静态网页 文章目录 HTML5期末大作业:化妆品商城网站设计--化妆品 ...
- HTML5期末大作业:化妆品商城网站设计——化妆品商城-功能齐全(43页) HTML+CSS+JavaScript web大作业 静态网页
HTML5期末大作业:化妆品商城网站设计--化妆品商城-功能齐全(43页) HTML+CSS+JavaScript web大作业 静态网页 常见网页设计作业题材有 个人. 美食. 公司. 学校. 旅游 ...
- HTML5期末大作业:棋牌游戏网站设计——棋牌游戏(8页) HTML+CSS+JavaScript web大作业 静态网页
HTML5期末大作业:棋牌游戏网站设计--棋牌游戏(8页) HTML+CSS+JavaScript web大作业 静态网页 常见网页设计作业题材有 个人. 美食. 公司. 学校. 旅游. 电商. 宠物 ...
- Linux之apache服务搭建以及浅析web安全
WEB服务器的架设,在linux有一个很著名的架构叫lamp:linux+apache+mysql+php,就知道apache的分量了. 在搭建apache服务钱需要做DNS服务器 DNS的搭建h ...
- Linux之web服务
一:HTTP协议 超文本传输协议 (HTTP-Hypertext transfer protocol) 是一种详细规定了浏览器和万维网服务器之间互相通信的规则,传送协议.是一个标准的C/S架构, ...
- linux使用flask设计网站,linux下Flask框架搭建简单网页
开始安装FLASK需要创建一个虚拟环境,虚拟环境可以不干扰正在使用的系统环境,避免影响,并且也不需要完全的root权限,更加安全可靠. 搭建环境 Python3.4 进入到microblog目录下创建 ...
最新文章
- Mozilla两款火狐插件包含恶意代码被紧急喊停
- linux 交叉编译 生成模块 makefile
- adb server无法启动方法,结束占用端口的进程
- Linux根文件系统学习总结
- C语言ATD1SC,2020-10-13_ATD(模数转换)模块介绍
- 化工原理 补考(重点)
- Go语言的分词器(sego)
- 使用 nohup 设置后台进程
- 安卓页面去掉顶部标题
- android studio安装Kotlin(零)
- KV型内存数据库Redis
- python安装pyltp_windows 安装pyltp详细教程
- 汉诺塔问题的总结(1)
- 【嵌入式系统】STM32时钟系统+时钟配置函数解析
- 养兔子c语言sdut,SDUT 养兔子
- 报错:The media could not be loaded, either because the server or network failed or ...
- 90 后董事长的国内首个元宇宙婚礼!网友:不由得想起了 QQ 炫舞和飞车......
- 近期刷题小结9.24-10.11
- Active Directory概述
- html交互式课件如何制作,如何制作交互式课件精选.ppt