网站需求
1、基于域名www.openlab.com可以访问网站内容为welcome to openlab!!!
修改配置文件
[root@redhat ~]
<VirtualHost 192.168.159.128:80>
DocumentRoot /www/openlab
ServerName www.openlab.com
</VirtualHost>
<Directory /www>
AllowOverride none
Require all granted
</Directory>
重启服务、关闭防火墙、关闭selinux
[root@redhat ~]
[root@redhat ~]
[root@redhat ~]
根据配置文件添加资源文件
[root@redhat ~]
[root@redhat ~]
修改hosts文件
[root@redhat ~]
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.159.128 www.openlab.com
使用curl命令查看网页资源
[root@redhat ~]
welcome to openlab!
2、给该公司创建三个子页面分别显示学生信息,教学资料和缴费网站,基于www.openlab.com/student网站访问学生信息,www.openlab/data网站访问教学资料,www.openlab.com/money网站访问缴费网站。
修改配置文件
[root@redhat ~]
<VirtualHost 192.168.159.128:80>
DocumentRoot /www/openlab
alias /student /openlab/student
alias /data /openlab/data
alias /money /openlab/money
ServerName www.openlab.com
</VirtualHost>
<Directory /www>
AllowOverride none
Require all granted
</Directory>
<Directory /openlab>
AllowOverride none
Require all granted
</Directory>
重启服务
[root@redhat ~]
根据配置文件创建网页资源
[root@redhat ~]
[root@redhat ~]
[root@redhat ~]
[root@redhat ~]
在linux查看
[root@redhat ~]
this is a student
[root@redhat ~]
this is data
[root@redhat ~]
this is money
3、要求(1)学生信息网站只有song和tian两个人可以访问,其他用户不能访问。 (2)访问缴费网站实现数据加密基于https访问
(1)
修改配置文件
[root@redhat ~]
<Directory /openlab/student>
AuthType Basic
AuthName "qing shu ru"
AuthUserFile /etc/httpd/users
Require user song tian
</Directory>
重启服务
[root@redhat ~]
添加用户 注意多次添加用户不要加-c选项否则添加的用户信息覆盖前面的用户
[root@redhat ~]
New password:
Re-type new password:
Adding password for user song
[root@redhat ~]
New password:
Re-type new password:
Adding password for user tian
(2) 下载工具
[root@redhat ~]
生成私钥并输入通行语句
[root@redhat ~]
Generating RSA private key, 2049 bit long modulus (2 primes)
...................................................+++++
................................................+++++
e is 65537 (0x010001)
Enter pass phrase:
Verifying - Enter pass phrase:
生成证书文件 输入私钥通行语句
[root@redhat ~]
Enter pass phrase for /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) []:shannx
Locality Name (eg, city) [Default City]:xian
Organization Name (eg, company) [Default Company Ltd]:openlab
Organizational Unit Name (eg, section) []:phce
Common Name (eg, your name or your server's hostname) []:localhost
Email Address []:admin@admin.com
修改配置文件
[root@redhat ~]
<VirtualHost 192.168.159.128:443>
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/openlab.crt
SSLCertificateKeyFile /etc/pki/tls/private/openlab.key
DocumentRoot /www/openlab
alias /money /openlab/money
ServerName www.openlab.com
</VirtualHost>
<Directory /openlab>
AllowOverride none
Require all granted
</Directory>
重启服务 需要输入之前生成密钥时所需的enter pass phrase
[root@redhat ~]
Enter TLS private key passphrase for www.openlab.com:443 (RSA) : *****************
查看
[root@redhat ~]
curl: (60) SSL certificate problem: self signed certificate in certificate chain
More details here: https://curl.haxx.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
|