搭建web网站

综合练习:请给openlab搭建web网站

网站需求:

1.基于域名 www.openlab.com可以访问网站内容为 welcome to openlab!!!

准备工作
#关闭安全软件
[root@server ~]# setenforce 0
[root@server ~]# systemctl stop firewalld
[root@server ~]# systemctl disable firewalld
# 安装所需软件
[root@server ~]# yum install nginx httpd tools -y
#在windows上的C:\Windows\System32\drivers\etc\hosts文件中进行DNS映射

搭建web网站_第1张图片

创建www.openlab.com网站
#创建网页目录及网页
[root@server ~]# mkdir -p /www/openlab
[root@server ~]# echo "welcome to openlab" > /www/openlab/index.html
[root@server ~]# vim /etc/nginx/nginx.conf

搭建web网站_第2张图片

重启nginx:
[root@server ~]# systemctl start nginx
打开浏览器测试:使用www.openlab.com

搭建web网站_第3张图片

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

创建教学资料网站www.openlab.com/data
[root@server ~]# echo 'data' > /www/openlab/data/index.html
[root@server ~]# ls /www/openlab/data/

#server端中启用location模块
[root@server ~]# vim /etc/nginx/nginx.conf

搭建web网站_第4张图片

#重启服务
[root@server ~]# systemctl start nginx
#测试

搭建web网站_第5张图片

3.要求

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

#先创建学生信息子网站www.openlab.com/student:
[root@server ~]# mkdir /www/openlab/student
[root@server ~]# echo 'student' > /www/openlab/student/index.html
[root@server ~]# ls /www/openlab/

搭建web网站_第6张图片

#添加用户song和tian
[root@server ~]# useradd song
[root@server ~]# passwd song
[root@server ~]# useradd tian
[root@server ~]# passwd tian
#创建加密文件
搭建web网站_第7张图片

搭建web网站_第8张图片

#编写nginx服务:
[root@server ~]# vim /etc/nginx/nginx.conf

搭建web网站_第9张图片

#重启服务:
[root@server ~]# systemctl restart nginx
#测试
搭建web网站_第10张图片

搭建web网站_第11张图片

搭建web网站_第12张图片

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

#先创建缴费子网站www.openlab.com/money
[root@server ~]# mkdir /www/openlab/money
[root@server ~]# echo 'money' > /www/openlab/money/index.html
[root@server ~]# ls /www/openlab/money
[root@server ~]# ls /www/openlab/

搭建web网站_第13张图片

#制作私钥
[root@server ~]# openssl genrsa -aes128 2048 > /etc/nginx/money.key

搭建web网站_第14张图片

#制作证书
[root@server ~]# openssl req -utf8 -new -key /etc/nginx/money.key -x509 -days 365 -out /etc/nginx/money.crt

搭建web网站_第15张图片

[root@server ~]# cd /etc/nginx
[root@server nginx]# cp money.key money.key.org
[root@server nginx]# openssl rsa -in money.key.org -out money.key

#打开nginx配置文件:
[root@server nginx]# vim /etc/nginx/nginx.conf

搭建web网站_第16张图片

#重启服务:
[root@server nginx]# systemctl restart nginx
#测试:
#添加返回输入http跳转到https,我们放在下面,这样三个网页都就可以执行了。

搭建web网站_第17张图片

搭建web网站_第18张图片

搭建web网站_第19张图片

你可能感兴趣的:(RHCE,服务器,linux,运维)