第一次作业

[root@server ~]# mkdir /www/openlab

[root@server ~]# echo 'welcom to openlab' > /www/openlab/index.html [root@server ~]# vim /etc/nginx/nginx.conf   server {       listen       80;       server_name www.openlab.com;       root         /www/openlab;   } [root@server ~]# systemctl start nginx

[root@server ~]# mkdir /www/openlab/file [root@server ~]# echo 'data' > /www/openlab/data/index.html [root@server ~]# vim /etc/nginx/nginx.conf

server {               listen       80;               server_name www.openlab.com;               root         /www/openlab;               location /data {

alias /www/openlab/file;                                           index index.html index.htm;                               }

} [root@server ~]# systemctl restart nginx

创建学生信息子网站www.openlab.com/student

[root@server ~]# mkdir /www/openlab/student [root@server ~]# echo 'student' > /www/openlab/student/index.html [root@server ~]# useradd song [root@server ~]# passwd song

[root@server ~]# useradd tian [root@server ~]# passwd tian

[root@server ~]# htpasswd /etc/nginx/passwd song [root@server ~]# htpasswd /etc/nginx/passwd tian

[root@server ~]# vim /etc/nginx.conf server { listen 80; server_name www.openlab.com; root /www/openlab; location /data {                             alias /www/openlab/data;                             index index.html index.htm; }

location /student                         {                             alias /www/openlab/student;                             index index.html index.htm;                             auth_basic   "Please input password";                             auth_basic_user_file   /etc/nginx/passwd;                         }           } [root@server ~]# systemctl restart nginx

创建缴费子网站www.openlab.com/money

[root@server ~]# mkdir /www/openlab/money [root@server ~]# echo 'money' > /www/openlab/money/index.html [root@server ~]# openssl genrsa -aes128 2048 > /etc/nginx/money.key Generating RSA private key, 2048 bit long modulus (2 primes) ....................+++++ ...................................+++++ e is 65537 (0x010001) Enter pass phrase:Verifying - Enter pass phrase: [root@server ~]# openssl req -utf8 -new -key /etc/nginx/money.key -x509 -days 365 -out /etc/nginx/money.crt Enter pass phrase for /etc/nginx/money.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) [AU]:86 State or Province Name (full name) [SomeState]:ningxia Locality Name (eg, city) []:yingchuan Organization Name (eg, company) [Internet Widgits Pty Ltd]:openlab Organizational Unit Name (eg, section) []:RHCE Common Name (e.g. server FQDN or YOUR name) []:server Email Address []:123 [root@server ~]# cd /etc/nginx [root@server nginx]# cp money.key money.key.org

[root@server nginx]# openssl rsa -in money.key.org -out money.key Enter pass phrase for money.key.org:

writing RSA key           [root@server nginx]# vim /etc/nginx/nginx.conf server {           listen       80;           server_name www.openlab.com;           root         /www/openlab;           location /file {                               alias /www/openlab/file;                               index index.html index.htm;                                           }           location /student                           {                               alias /www/openlab/student;                               index index.html index.htm;                               auth_basic   "Please input password";                               auth_basic_user_file   /etc/nginx/passwd;                           }           }   server {               listen       443 ssl http2;server_name www.openlab.com;               location /money {                                       alias /www/openlab/money;                                       index index.html index.htm;                               }               ssl_certificate       "/etc/nginx/money.crt";               ssl_certificate_key   "/etc/nginx/money.key";         }           [root@server nginx]# systemctl restart nginx

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值