yum install httpd -y
yum install mod_ssl -y
<>为起始标志,</>为结束标志
AllowOverride none 不允许这个目录下的访问控制文件来改变这里的配置,这也意味着不用查看这个目录下的访问控制文件。
vim /etc/httpd/conf.d/openlab.conf
<VirtualHost 172.24.8.130:80>
DocumentRoot /www *主目录
ServerName www.openlab.com
<VirtualHost 172.24.8.130:443>
DocumentRoot /hh *主目录为/ hh(还需要至少一个次目录)
ServerName www.openlab.com
SSLEngine on
SSLcertificatefile /etc/pki/tls/certs/money.crt
SSlcertificatekeyfile /etc/pki/tls/certs/money.key
<Directory /hh> *访问控制
ALLowOverride none *不允许覆盖
Require all granted *授权所有用户可以访问 /hh
<Directory /www>
ALLowOverride none
Require all granted
<Directory /www/student>
AuthType Basic *认证类型
AuthName “miaoshu” *认证描述
AuthUserFile /etc/httpd/users *自定义的认证文件路径
Require user song tian *认证用户
:wq
mkdir -p /hh/money
mkdri -p /www/student
mkdir /www/data
echo this is money > /hh/money/index.html
echo this is student > /www/student/index.html
echo this is data > /www/data/index.html
echo welcome to openlab > /www/index.html
cd /etc/pki/tls/certs 创私钥
/usr/bin/openssl genrsa -aes128 2048 > money.key
输入密码
openssl req -utf8 -new -key money.key -x509 -days 365 -out money.crt -set_serial 0
给私钥颁证书
htpasswd -c /etc/httpd/users tian
htpasswd /etc/httpd/users song
vim /etc/hosts
172.24.8.130 www.openlab.com
systemctl stop firewalld
setenforce 0
systemctl restart httpd
curl http://www.openlab.com/
curl http://www.openlab.com/data/
curl http://www.openlab.com/student/ -u tian
curl -k https://www.openlab.com/money/