当前位置: 首页 > article >正文

五分钟学会搭建web网站

一、准备工作

关闭安全软件

安装所需软件

[root@Server ~]# yum install nginx httpd-tools -y

C:\Windows\System32\drivers\etc\hosts 文件进行DNS映射

192.168.205.137 www.openlab.com

第二步:创建www.openlab.com网站

#创建网页目录及网页

[root@Server ~]# mkdir -p /www/openlab
[root@Server ~]# echo 'welcome to openlab' > /www/openlab/index.html
[root@Server ~]# vim /etc/nginx/nginx.conf

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

        # Load configuration files for the default server block.
    }


[root@Server ~]# systemctl start nginx

测试

window端打开浏览器输入www.openlab.com测试

第三步:创建教学资料子网站www.openlab,com/data

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

        location /data{
                        alias /www/openlab/data;
                        index index.

}

[root@Server ~]# systemctl restart nginx

window端打开浏览器输入www.openlab.com/data测试

第四步:创建学生信息子网站www.openlab.com/student

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

[root@Server ~]# useradd song
[root@Server ~]# passwd song            #密码123456

[root@Server ~]# useradd tian              #密码654321
[root@Server ~]# passwd tian

[root@Server ~]# htpasswd -c /etc/nginx/passwd song    #密码123456

[root@Server ~]# htpasswd /etc/nginx/passwd tian         #密码654321

[root@Server ~]# vim /etc/nginx/nginx.conf

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

window端打开浏览器输入www.openlab.com/student测试

第五步:创建缴费子网站www.openlab.com/money

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) [Some-State]:ningxia
Locality Name (eg, city) []:yinchuan
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 []:andy@qq.com

去除私钥的加密密码

[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:

[root@Server nginx]# vim /etc/nginx/nginx.conf

增加以下内容

 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

此网站需要location二次映射

1、只要监听端口号变,就要重新增加入口段,入口不一样

2、只要server_name变,就得重新增加server段

window端打开浏览器输入www.openlab.com/money测试

实验完毕!!!

http://www.lryc.cn/news/2419936.html

相关文章:

  • 手把手教你搭建自己的个人博客(图文教程)
  • 9大代理服务器软件的比较与分析
  • 海外电商平台开发流程
  • Milvus的向量索引(内存索引)
  • 【转】3gpp和3gpp2
  • 浏览器HTTP_USER_AGENT汇总——Firefox、Chrome、IE9、IE8、IE7、IE6
  • 软件质量管理体系_软件质量管理概述
  • 个人站长三次网站备案的经历及经验总结
  • 基于智能移动设备的IP电话软件的设计与实现
  • 83102 三种常见网络协议
  • 第二学期无人机操作师结业复习测试
  • OpenFeign不支持{}特殊字符的header解决
  • c语言中pause的作用,c++中的system(pause)的作用和含义解析
  • 微信小程序_介绍
  • 非诚勿扰又来一男程序员
  • 深度全方位盘点你眼中的IT行业现状与未来趋势
  • BZOJ 2462 BeiJing 2011 矩阵模板 二维hash
  • 2023计算机毕业设计SSM最新选题之java体育运动兴趣社区系统8bisy
  • CSS3:3D移动translate3d及3D转换透视效果perspective
  • 分布式系统架构网络之IDC机房
  • 靶向代谢组
  • 【UWB 定位】高精度定位
  • js获取数组长度-length属性的介绍
  • 专访 SphereEx 创始团队:获数百万美金投资,接棒 ShardingSphere 打造全新分布式生态
  • SpringBoot+Flowable 完美结合,优雅实现工作流!
  • EWSA破解WPA无线密码具体图文教程
  • 抓取静态网页数据
  • Hyperledger Fabric2.3 环境搭建及Fabric 测试网络使用
  • 初步了解SequoiaDB数据库
  • CSS3动画—— transition