搭建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)网站访问教学资料,网站访问缴费网站(http://www.openlab.com/money网站访问缴费网站)。

3.要求 (1)学生信息网站只有song和tian两人可以访问,其他用户不能访问。

​ (2)访问缴费网站实现数据加密基于https访问。

架设一台NFS服务器,并按照以下要求配置
1、开放/nfs/shared目录,供所有用户查询资料
2、开放/nfs/upload目录,为192.168.xxx.0/24网段主机可以上传目录,
并将所有用户及所属的组映射为nfs-upload,其UID和GID均为210
3、将/home/tom目录仅共享给192.168.xxx.xxx这台主机,并只有用户tom可以完全访问该目录

 

准备工作

(1)关闭防火墙,便于访问Linux虚拟机上服务

0742045bcbfd4df891e1ad13358e4541.png

(2)设置selinux为permissive模式

[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce
Permissive
 

(3)安装相应的nginx包和httpd包

[root@localhost ~]# yum install nginx -y

[root@localhost ~]# yum install httpd -y

[root@localhost ~]# yum install httpd-tools

 

1.基于域名[www.openlab.com](http://www.openlab.com)可以访问网站内容为 welcome to openlab!!!

1.使用vim编辑/etc/nginx/conf.d/openlab.conf文件

 

2.创建目录并将要输出内容写入里面

[root@localhost ~]# mkdir /www/openlab -pv
mkdir: 已创建目录 '/www'
mkdir: 已创建目录 '/www/openlab'
[root@localhost ~]# echo www.openlab.com\!\!\! > /www/openlab/index.html
[root@localhost ~]# cat /www/openlab/index.html
www.openlab.com!!!

3.重启nginx服务端

[root@localhost ~]# systemctl restart nginx
 

使用客户端进行测试

[root@localhost ~]# vim /etc/hosts

 

# Loopback entries; do not change.
# For historical reasons, localhost precedes localhost.localdomain:
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
# See hosts(5) for proper format and other examples:
# 192.168.1.10 foo.mydomain.org foo
# 192.168.1.13 bar.mydomain.org bar
192.168.44.135 www.openlab.com
~              

 

 

[root@localhost ~]# curl www.openlab.com
www.openlab.com!!!
              

 

2.给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,基于[www.openlab.com/student](http://www.openlab.com/student) 网站访问学生信息,[www.openlab.com/data](http://www.openlab.com/data)网站访问教学资料,网站访问缴费网站(http://www.openlab.com/money网站访问缴费网站)。

3.要求 (1)学生信息网站只有song和tian两人可以访问,其他用户不能访问。

​ (2)访问缴费网站实现数据加密基于https访问。

 

1.使用 vim 编辑/etc/nginx/conf.d/openlab.conf

[root@localhost ~]# vim /etc/nginx/conf.d/openlab.conf

server {
         listen       192.168.44.135:80;
         server_name  www.openlab.com;
         root         /www/openlab;
         location /student{
                 index index.html;
                 alias /www/openlab/student;
                 auth_basic on;
                 auth_basic_user_file /etc/nginx/users;
         }
 }

 

2.创建三个子目录并写入内容

[root@localhost ~]# mkdir /www/openlab/{data,money,student} -pv
mkdir: 已创建目录 '/www/openlab/data'
mkdir: 已创建目录 '/www/openlab/money'
mkdir: 已创建目录 '/www/openlab/student'
[root@localhost ~]# echo 教学资料 > /www/openlab/data/index.html
[root@localhost ~]# echo 缴费网站 > /www/openlab/money/index.html
[root@localhost ~]# echo 学生信息 > /www/openlab/student/index.html

3.重启nginx服务端

[root@localhost ~]# systemctl restart nginx
 

进行测试

[root@localhost ~]# curl www.openlab.com/data/
教学资料
[root@localhost ~]# curl www.openlab.com/money/
缴费网站
[root@localhost ~]# curl www.openlab.com/student/
学生信息

 

4.添加用户信息

[root@localhost ~]# htpasswd -c /etc/nginx/usrs song
New password: 
Re-type new password: 
Adding password for user song
[root@localhost ~]# htpasswd  /etc/nginx/usrs tian
New password: 
Re-type new password: 
Adding password for user tian

(1)学生信息网站只有song和tian两人可以访问,其他用户不能访问。

测试

[root@localhost ~]# curl www.openlab.com/student/ -u song:123456
学生信息
[root@localhost ~]# curl www.openlab.com/student/ -u tian:123456
学生信息
 

​ (2)访问缴费网站实现数据加密基于https访问。

1.修改配置文件

 server {
         listen       192.168.44.135:80;
         server_name  www.openlab.com;
         root         /www/openlab;
         2.16.44.1location /student{
                 index index.html;
                 alias /www/openlab/student;
                 auth_basic on; 
                 auth_basic_user_file /etc/nginx/users;
            
   server { 
       listen       192.168.44.135: ssl ;
       server_name  www.openlab.com;
       root         /www;
       ssl_certificate "/etc/pki/tls/certs/openlab.crt";
       ssl_certificate_key "/etc/pki/tls/private/openlab.key";
       location / { 
               index index.html;
       }

进行加密

[root@localhost ~]# openssl genrsa -aes128 2048 > /etc/pki/tls/private/openlab.key
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
 

[root@localhost ~]#  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) [AU]:86
State or Province Name (full name) [Some-State]:11
Locality Name (eg, city) []:21
Organization Name (eg, company) [Internet Widgits Pty Ltd]:1
Organizational Unit Name (eg, section) []:4
Common Name (e.g. server FQDN or YOUR name) []:5
Email Address []:5
 

测试

[root@localhost ~]# curl https:/www.openlab.com/money/ -k
缴费网站

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Python是一门功能强大且易于学习的编程语言,它可以用于构建Web网站。在Python中,我们可以使用许多第三方库或框架来简化Web开发的过程。 首先,我们可以使用Flask或Django这样的Web框架来搭建Web网站。Flask是一个轻量级的框架,适合小型应用或原型开发。而Django是一个全功能的框架,适用于大型应用开发。这两个框架都提供了路由功能、模板引擎、表单处理和数据库集成等重要特性,使Web开发更加简单和高效。 其次,我们可以使用HTML、CSS和JavaScript来设计和布局网页。HTML是用于构建网页结构的标记语言,CSS用于样式设计,而JavaScript用于动态交互和用户体验的改进。Python中,我们可以使用模板引擎来渲染HTML模板,并将数据传递给前端页面进行呈现。 另外,Python还提供了许多有用的库来处理与Web相关的任务。比如,我们可以使用Requests库来进行HTTP请求和响应处理,BeautifulSoup库来解析HTML或XML文档,以及Pillow库来处理图像。 最后,要搭建Python Web网站,我们需要了解基本的Web开发概念,例如Web服务器、路由、请求和响应等。我们还需要学习数据库的基本知识,以便与Web应用程序集成和存储数据。 总而言之,Python是一种优秀的语言,可以用于快速构建Web网站。通过使用适当的库和框架,我们可以简化开发过程,并实现功能丰富的Web应用程序。无论是小型应用还是大型项目,Python都是一个可靠的工具。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值