1.挂载
[root@localhost ~]# mount /dev/sr0 /mnt
mount: /mnt: WARNING: device write-protected, mounted read-only.
2.安装httpd 和https要用到的mod_ssl
[root@localhost ~]# yum install httpd -y
[root@localhost ~]# yum install mod-ssl -y
3.关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
4.开启http服务
[root@localhost ~]# systemctl start httpd
1.进入配置文件
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
2.创建网页根目录
[root@localhost ~]# mkdir -p /www/openlab
3.编辑网页内容
[root@localhost ~]# echo "Welcome to openlab.com" > /var/www/html/index.html
4.重启http服务
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# setenforce 0
创建/data网页根目录
[root@localhost ~]# mkdir /www/openlab/data
Client主机测试
[root@localhost ~]# curl www.openlab.com/data/
this is openlab data
挂载到 /mnt
[root@localhost ~]# mount /dev/sr0 /mnt
mount: /mnt: /dev/sr0 already mounted on /run/media/rhat/RHEL-8-5-0-BaseOS-x86_64.
下载mod_ssl 软件包
[root@localhost ~]# yum install mod_ssl -y
制作秘钥及证书
[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
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>
创建用户 指定用户名及密码
[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 子页面