配置Wab服务器,访问网站,并显示内容—— 练习二

题目二

1.新建一个网站,该网站网址为www.world.com,用户访问该网站时网站显示:  欢迎来到这个世界!Welcome;

2.当用户访问www.world.com/study/网站时,网站内容显示为:good good study,day day up

3.当用户访问www.world.com/computer/网站时,必须要使用账号名root,密码为777才能访问,该网站内容为:KNOW

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

#添加ip地址
[root@localhost ~]# nmtui
[root@localhost ~]# nmcli connection up ens224

#创建网页文件根目录,并定义网页内容
[root@localhost ~]# vim /www/world/index.html
[root@localhost ~]# cat /www/world/index.html

<head>	
	<meta charset="utf-8">
</head>

欢迎来到这个世界!Welcome

[root@localhost ~]# mkdir -pv /www/world


#配置文件
[root@localhost ~]# vim /etc/nginx/conf.d/test_world.conf
[root@localhost ~]# cat /etc/nginx/conf.d/test_world.conf

server {
	listen 192.168.50.102:80;
	server_name www.world.com;
	root /www/world;
	location /study/{}
	location /computer {
		auth_basic on;
		auth_basic_user_file /etc/nginx/conf.d/auth-password;
	}
}

[root@localhost ~]# vim /www/world/study/index.html
[root@localhost ~]# cat /www/world/study/index.html
good good study,day day up
[root@localhost ~]# vim /www/world/computer/index.html
[root@localhost ~]# cat /www/world/computer/index.html
KNOW
[root@localhost ~]# tree /www/world/
/www/world/
├── computer
│   └── index.html
├── index.html
└── study
    └── index.html

2 directories, 3 files

[root@localhost ~]# mkdir -pv /www/world/{study,computer}
mkdir: 已创建目录 '/www/world/study'
mkdir: 已创建目录 '/www/world/computer'

[root@localhost ~]# vim /etc/hosts
[root@localhost ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.50.102 www.world.com

[root@localhost ~]# dnf install httpd-tools -y

[root@localhost ~]# htpasswd -cb /etc/nginx/conf.d/auth-password root 777
Adding password for user root

#关闭防火墙
[root@localhost ~]# systemctl disable firewalld --now

#设置selinux,必须设置,否则无法看到网页页面内容
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce
Permissive
[root@localhost ~]# systemctl restart nginx


#以下为鉴定部分
[root@localhost ~]# curl 192.168.50.102

<head>	
	<meta charset="utf-8">
</head>

欢迎来到这个世界!Welcome
[root@localhost ~]# curl 192.168.50.102/study/
good good study,day day up

[root@localhost ~]# curl 192.168.50.102/computer/
<html>
<head><title>401 Authorization Required</title></head>
<body>
<center><h1>401 Authorization Required</h1></center>
<hr><center>nginx/1.20.1</center>
</body>
</html>

#需要使用账户和密码登录
[root@localhost ~]# curl root:777@192.168.50.102/computer/
KNOW


[root@localhost ~]# curl www.world.com
<head>	
	<meta charset="utf-8">
</head>

欢迎来到这个世界!Welcome

[root@localhost ~]# curl www.world.com/study/
good good study,day day up

[root@localhost ~]# curl root:777@www.world.com/computer/
KNOW

  • 5
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Eclipse中配置Web应用程序(.wab文件),请按照以下步骤操作: 1. 首先,确保已经安装了Eclipse IDE for Java EE Developers版本。如果没有,请从Eclipse官网下载并安装该版本。 2. 在Eclipse中,选择“File”菜单,然后选择“New”>“Project”。 3. 在“New Project”对话框中选择“Dynamic Web Project”,然后单击“Next”。 4. 在“Project Name”字段中输入项目名称,然后单击“Next”。 5. 在“Configuration”页面中,选择“Generate web.xml deployment descriptor”选项。 6. 单击“Finish”按钮创建项目。 7. 在项目中创建一个新的“WebContent”目录,并将.wab文件放入该目录中。 8. 右键单击项目,选择“Properties”选项。 9. 在“Properties”对话框中选择“Deployment Assembly”选项。 10. 单击“Add”按钮,然后选择“Folder”选项。 11. 选择“WebContent”目录,并单击“Finish”按钮。 12. 在“Deployment Assembly”页面中,你应该看到“WebContent”目录已添加到项目中。 13. 单击“OK”按钮保存更改,并关闭“Properties”对话框。 14. 现在,你可以在Eclipse中运行Web应用程序。在“Servers”视图中,右键单击服务器并选择“Add and Remove...”选项。 15. 将项目添加到服务器并启动它。在Web浏览器中输入`http://localhost:<port>/<context-path>`访问应用程序,其中`<port>`是服务器端口号,`<context-path>`是应用程序的上下文路径。 注意:在运行Web应用程序之前,你需要在Eclipse中安装适当的Web容器插件,例如Tomcat或Jetty插件。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值