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

web实验(2)

实验1
  • 搭建nginx+ssl的加密认证web服务器

  • 第一步:准备工作

# 恢复快照
[root@server ~]# setenforce  0           

[root@server ~]# systemctl stop  firewalld

[root@server ~]# systemctl disable  firewalld

[root@server ~]# yum  install  nginx  mod_ssl -y

[root@server ~]# systemctl start  nginx   # 启动
 
[root@server ~]# systemctl enable  nginx  # 设置开机启动

第二步:新建存储网站数据文件的目录

[root@server ~]# mkdir  -p  /www/zy
# 私用xftp将windows的zy网站数据文件上传到/www/zy目录中

第三步:制作证书

# 在/etc/nginx目录下制作整数所用的私钥文件zy.key
[root@server ~]# openssl  genrsa  -aes128  2048 > /etc/nginx/zy.key
Generating RSA private key, 2048 bit long modulus (2 primes)
............+++++
......................................................................................................................................................................................................+++++
e is 65537 (0x010001)
Enter pass phrase:             # 输入加密私钥的密码123456
Verifying - Enter pass phrase: # 再输一遍# 制作证书
[root@server ~]# openssl  req  -utf8  -new  -key  /etc/nginx/zy.key  -x509  -days  365  -out  /etc/nginx/zy.crt
Enter pass phrase for /etc/nginx/zy.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]:shanxi			  # 省份
Locality Name (eg, city) []:xi'an								  # 城市
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									  # 邮箱# 在加载SSL支持的Nginx并使用上述私钥时除去必须的口令
[root@server ~]# cd  /etc/nginx
[root@server nginx]# cp  zy.key  zy.key.org
[root@server nginx]# openssl rsa -in zy.key.org -out zy.key
Enter pass phrase for zy.key.org:  # 输入加密私钥的密码
writing RSA key

第五步:修改配置文件

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

server {
                listen       443 ssl http2;
                server_name  192.168.48.130;
                root         /www/zy;
                ssl_certificate  /etc/nginx/zy.crt;
                ssl_certificate_key  /etc/nginx/zy.key;
        }
server {      # 输入http跳转到https
                listen 80;
                server_name 192.168.48.130;
                return 301 https://192.168.48.130;
        }

第六步:重启服务

[root@server nginx]# cd  ~
[root@server ~]# nginx  -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@server nginx]# systemctl start nginx

第七步:测试

使用LNMP搭建私有云存储

准备工作

恢复快照,关闭安全软件

[root@server ~]# setenforce  0

[root@server ~]# systemctl stop  firewalld

搭建LNMP环境

[root@server ~]# yum  install  nginx  mariadb-server  php*  -y

上传软件
  • 使用xftp将nextcloud-25.0.1.zip软件压缩包上传到Linux的根目录,并解压缩

[root@server ~]# cd  /

[root@server /]# unzip  /nextcloud-25.0.1.zip 

设置nextcloud安装命令权限

[root@server /]# chmod  -Rf  777  /nextcloud

设置数据库

[root@server /]# systemctl start  mariadb   # 启动数据库

[root@server /]# mysql

# 数据库设置
MariaDB [(none)]> create  database  nextcloud;  # 创建数据库

MariaDB [(none)]> create  user  'nextcloud'@'localhost' identified  by  '123456';   # 创建用户及密码

MariaDB [(none)]> grant all on  nextcloud.*  to  'nextcloud'@'localhost';
# 设置权限
 
MariaDB [(none)]> exit       # 退出

重启数据库

[root@server /]# systemctl restart  mariadb

配置nginx

[root@server /]# vim  /etc/nginx/nginx.conf 
  server {
        listen       80;
        server_name  192.168.48.130;
        root         /nextcloud;
    }

重启nginx服务

[root@server /]# systemctl  start  nginx

安装
  • 打开浏览器后输入服务器IP地址,进入nextcloud安装向导

  • 管理员的用户名即密码自定

  • 存储与数据库:选择MySQL/MariaDB,设置数据库用户为nextcloud,密码:123456,数据库名:nextcloud,主机名:localhost

内网穿透
cpolar的域名信任
[root@server ~]# vim  /nextcloud/config/config.php
# 按照下面的内容对源文件进行修改
<?php
$CONFIG = array ('instanceid' => 'ocvy7jm0iqom','passwordsalt' => 'jLg0GXwJtlj8vowMsLpN5MbBSRsoiC','secret' => 'ayTVaC6dsHrSKgXazVP6llFMWdNVxjF582v5pAPKuyEecdTU','trusted_domains' =>array (0 => '192.168.48.130',1 => '2dc0afad.r17.cpolar.top',  # 需添加),'datadirectory' => '/nextcloud/data','dbtype' => 'mysql','version' => '25.0.1.1','overwrite.cli.url' => 'http://192.168.48.130','dbname' => 'nextcloud','dbhost' => 'localhost','dbport' => '','dbtableprefix' => 'oc_','mysql.utf8mb4' => true,'dbuser' => 'nextcloud','dbpassword' => '123456','installed' => true,
);
# 保存退出后重试

相关文章:

  • 【Dify平台】使用Dify API 实现网页内嵌式AI助手
  • Redis实战篇Day01(短信登录篇)
  • 谷歌medgemma-27b-text-it医疗大模型论文速读:多语言大型语言模型医学问答基准测试MedExpQA
  • PyTorch可视化工具——使用Visdom进行深度学习可视化
  • java 基础知识巩固
  • 论文阅读笔记——PixArt-α,PixArt-δ
  • [Harmony]网络请求
  • 【COMPUTEX 2025观察】NVIDIA开放NVLink:一场重构AI算力版图的“阳谋“
  • 应用案例 | 集成Docker,解锁 HMI/网关的定制化应用
  • 数据库基础面试题(回答思路和面试建议)
  • 力扣第450场周赛
  • upload-labs靶场通关详解:第14关
  • python:基础爬虫、搭建简易网站
  • Intel oneAPI 入门
  • 浙江大学python程序设计(陈春晖、翁恺、季江民)习题答案-第八章
  • RAG系统实战:文档切割与转换核心技术解析
  • Postgresql14+Repmgr部署
  • sentinel滑动时间窗口算法详解
  • 性能测试场景题
  • leetcode hot100刷题日记——10.螺旋矩阵
  • wordpress url参数/seo 是什么
  • app设计模板网站/网络推广岗位职责和任职要求
  • 做塑料哪个网站好/惠州seo排名
  • 网站开发转包协议/漯河seo推广
  • 阿里云域名注册云盾/专业seo培训学校
  • 平凉市政府门户网站/青岛seo经理