第三次作业

搭建环境

安装nginx软件
yum install nginx -y

关闭防火墙

systemctl stop firewalld

setenforce 0

配置映射关系
echo "192.168.95.139 www.openlab.com" >> /etc/hosts

创建网站目录已经内容
mkdir -p /usr/share/nginx/html/openlab/{student,data,money}

echo "welcome to openlab!!!" > /usr/share/nginx/html/openlab/index.html
echo "学生信息" > /usr/share/nginx/html/openlab/student/index.html
echo "教学资料" > /usr/share/nginx/html/openlab/data/index.html
echo "缴费网站" > /usr/share/nginx/html/openlab/money/index.html

创建HTTPS证书

openssl  genrsa   2048 > /etc/pki/openlab.key
openssl req -utf8 -new  -key /etc/pki/openlab.key -x509  -days 365  -out /etc/pki/openlab.crt
mkdir   /etc/nginx/ssl

nginx核心配置

vim /etc/nginx/conf.d/openlab.conf
server {
    listen 80;
    server_name www.openlab.com;
    return 301 https://192.168.95.139;
}
server {
    listen 443 ssl;
    server_name www.openlab.com;
    ssl_certificate /etc/nginx/ssl/openlab.crt;
    ssl_certificate_key /etc/nginx/ssl/openlab.key;
    root /usr/share/nginx/html/openlab;
    location /student {

        allow song tian
        auth_basic "please login ......";
        auth_basic_user_file /etc/nginx/conf.d/student_users;
    }
}
检查配置

nginx -t

重启nginx

systemctl restart nginx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值