综合练习:请给
openlab
搭建
web
网站
网站需求:
1.
基于域名
www.openlab.com
可以访问网站内容为
welcome to openlab!!!
2.
给该公司创建三个子界面分别显示学生信息,教学资料
和缴费网站,基于,
www.openlab.com/data
网站访问教学
资料
www.openlab.com/money
网站访问缴费网站
。
3.
要求
(
1
)学生信息网站只有
song
和
tian
两人可以访问,其他
用户不能访问。
(
2
)访问缴费网站实现数据加密基于
https
访问。
1.第一步:准备工作
2.第二步:创建
www.openlab.com
网站
[root@server ~]# yum install nginx httpd-tools -y
[root@server ~]# mkdir -p /www/openlab
[root@server ~]# echo 'welcom to openlab' > /www/openlab/index.html
[root@server ~]# vim /etc/nginx/nginx.conf
[root@server ~]# systemctl start nginx
# Windows
的
C:\Windows\System32\drivers\etc\hosts
文件进
行
DNS
映射
# Windows端打开浏览器输入
www.openlab.com
测试
3.第三步:创建教学资料子网站
www.openlab.com/data
[root@server ~]# mkdir /www/openlab/data
[root@server ~]# echo 'data' > /www/openlab/data/index.html
[root@server ~]# vim /etc/nginx/nginx.conf
[root@server ~]# systemctl restart nginx
# Windows
端打开浏览器输入
www.openlab.com/data测试
4.第四步:创建学生信息子网站
www.openlab.com/student
[root@server ~]# mkdir /www/openlab/student
[root@server ~]# echo 'student' > /www/openlab/student/index.html
[root@server ~]# useradd song
[root@server ~]# passwd song
更改用户 song 的密码 。
新的密码:
无效的密码: 密码少于 8 个字符
重新输入新的密码:
passwd:所有的身份验证令牌已经成功更新。
[root@server ~]# useradd tian
[root@server ~]# passwd tian
更改用户 tian 的密码 。
新的密码:
无效的密码: 密码少于 8 个字符
重新输入新的密码:
passwd:所有的身份验证令牌已经成功更新。
[root@server ~]# htpasswd -c /etc/nginx/passwd song
New password:
Re-type new password:
Adding password for user song
[root@server ~]# htpasswd -c /etc/nginx/passwd tian
New password:
Re-type new password:
Adding password for user tian
[root@server ~]# vim /etc/nginx/nginx.conf
[root@server ~]# systemctl restart nginx
# Windows
端打开浏览器输入 www.openlab.com/student测试,多次测试需要清除浏 览器缓存
5.第五步:创建缴费子网站
www.openlab.com/money
[root@server ~]# mkdir /www/openlab/money
[root@server ~]# echo 'money' > /www/openlab/money/index.html
[root@server ~]# openssl genrsa -aes128 2048 > /etc/nginx/money.key
Generating RSA private key, 2048 bit long modulus (2 primes)
........................+++++
.............................................................................+++++
e is 65537 (0x010001)
Enter pass phrase:
Verifying - Enter pass phrase:
[root@server ~]# openssl req -utf8 -new -key /etc/nginx/money.key -x509 -days 365 -out
/etc/nginx/money.crt
req: Unrecognized flag out/etc/nginx/money.crt
req: Use -help for summary.
[root@server ~]# openssl req -utf8 -new -key /etc/nginx/money.key -x509 -days 365 -out /etc/nginx/money.crt
Enter pass phrase for /etc/nginx/money.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]:ningxia
Locality Name (eg, city) []:yingchuan
Organization Name (eg, company) [Internet Widgits Pty Ltd]:openlab
Organizational Unit Name (eg, section) []:RHCE
Common Name (e.g. server FQDN or YOUR name) []:server
Email Address []:andy@qq.com
[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
Enter pass phrase for money.key.org:
writing RSA key
[root@server nginx]# vim /etc/nginx/nginx.conf
[root@server nginx]# systemctl restart nginx
# Windows
端打开浏览器输入 https://www.openlab.com/money测试