网站需求:请给openlab搭建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)网站访问教学资料 [www.openlab.com/money网站访问缴费网站](http://www.openlab.com/money网站访问缴费网 站)。
3.要求 | (1)学生信息网站只有song和tian两人可以访问,其他用户不能访问。 (2)访问缴费网站实现数据加密基于https访问 |
第一题
1、挂载:通过光盘挂载
[root@localhost hh]# mount /dev/sr0 /mnt
2、配置yum源
[root@localhost hh]# vim /ect/yum.repos.d/base.repo
再配置中定义包的路径,定义源的连接和标符名称
[base] name=base baseurl=file:///mnt/BaseOS gpgcheck=0 [app] name=app baseurl=file:///mnt/AppStream gpgcheck=0
完成配置后点击Esc键,退出保存命令—— :wq
3、装包——装包工具——dnf
[root@localhost hh]# dnf install httpd -y
4、关闭防火墙和SELinux
[root@localhost hh]# systemctl stop firewalld [root@localhost hh]# setenforce 0
5、更改配置文件实现自定义设置
虚拟主机标签的示例参考文件:/usr/share/doc/httpd/httpd-vhosts.conf
子配置目录:conf.d ?
<VirtualHost 192.168.142.130:80>
? ? ? ? Servername www.openlab.com
? ? ? ? DocumentRoot /www/openlab
</VirtualHost>
<Directory /www/>
? ? ? ? AllowOverride none
? ? ? ? Require all granted
</Directory>
6、利用本机的/etc/hosts文件做域名解析
[root@localhost ~]# vim /etc/hosts 192.168.101.200 ?www.openlab.com
7、创建网页根目录
[root@localhost ~]# mkdir -p /www/openlab
8、根据配置创建网页资源文件
[root@localhost ~]# echo 'welcome to openlab!!!' > /www/openlab/index.html
9、重启hppd服务
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# setenforce 0
10、Client主机测试
[root@localhost ~]# curl www.openlab.com
welcome to openlab!!!
第二题
前两部同上
3、创建目录
[root@localhost etc]# cd /root [root@localhost ~]# mkdir {student,data,money}
修改权限:[root@localhost ~]# chmod /root 777
4、添加内容
[root@localhost ~]# echo who is money > /root/money/index.html
[root@localhost ~]# echo who is data > /root/data/index.html
[root@localhost ~]# echo who is student > /root/student/index.html
第三题
1、挂载光盘到/mnt
[root@localhost ~]# mount /dev/sr0 /mnt mount: /mnt: WARNING: device write-protected, mounted read-only.
2、下载mod_ssl 软件包
[root@localhost ~]# yum install mod_ssl -y
3、制作秘钥及证书
[root@localhost ~]# openssl req -newkey rsa:4096 -nodes -sha256 -keyout /etc/pki/tls/private/openlab.key -x509 -days 365 -out /etc/pki/tls/certs/openlab.crt
Generating a RSA private key
...........................................................................................++++
..............................................++++
writing new private key to '/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) []:shannxi ? ? ? ??
Locality Name (eg, city) [Default City]:xi'an
Organization Name (eg, company) [Default Company Ltd]:openlab
Organizational Unit Name (eg, section) []:ce
Common Name (eg, your name or your server's hostname) []:localhost ? ? ? ??
Email Address []:admin?
4、更改配置文件
[root@localhost ~]# vim /etc/httpd/conf.d/vshots.conf?
<VirtualHost 192.168.101.200:443>
? ? ? ? DocumentRoot ?/www/openlab
? ? ? ? Alias ?/money ? ?/www/openlab/money
? ? ? ? ServerName ?www.openlab.com
? ? ? ? SSLEngine on
? ? ? ? SSLCertificateFile /etc/pki/tls/certs/openlab.crt
? ? ? ? SSLCertificateKeyFile /etc/pki/tls/private/openlab.key
</VirtualHost>
5、创建网页文件根目录
[root@localhost ~]# mkdir /www/openlab/money
6、编辑子网页money内容
[root@localhost ~]# echo 'this is openlab money' > /www/openlab/money/index.html
7、重启httpd服务
[root@localhost ~]# systemctl ?restart httpd
8、Client主机测试
[root@localhost ~]# curl --insecure https://www.openlab.com/money/ this is openlab money
9、money子页面更改配置文件
[root@server ~]# vim /etc/httpd/conf.d/vshots.conf?
<VirtualHost 192.168.101.200:80>
? ? ? ? DocumentRoot ?/www/openlab
? ? ? ? Alias ?/student ? ?/www/openlab/student
? ? ? ? ServerName ?www.openlab.com
</VirtualHost>
<Directory /www/openlab/student>
? ? ? ? AuthType Basic
? ? ? ? AuthName "Please login:..."
? ? ? ? AuthuserFile /etc/httpd/usrfile
? ? ? ? Require user ?song tian
</Directory>
10、创建用户 指定用户名及密码
[root@localhost ~]# htpasswd -c /etc/httpd/userfile song
New password:?
Re-type new password:?
Adding password for user song
[root@server ~]# htpasswd /etc/httpd/userfile tian
New password:?
Re-type new password:?
Adding password for user tian
#创建网页文件根目录
[root@server ~]# mkdir /www/openlab/student
#重启httpd服务
[root@server ~]# systemctl restart httpd
访问/student 子页面
?
|