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

Nginx作为下载站点

 grep -Ev '^$|#' /usr/local/nginx/conf/nginx.conf > /opt/nginx.txt
cat /opt/nginx.txt > /usr/local/nginx/conf/nginx.conf
用上面的指令提取最小化的配置文件
vim /usr/local/nginx/conf/nginx.conf
[root@localhost ~]# cat /usr/local/nginx/conf/nginx.conf
worker_processes  1;
events {worker_connections  1024;
}
http {include       mime.types;default_type  application/octet-stream;sendfile        on;keepalive_timeout  65;server {listen       80;server_name  localhost;location / {root   html;index  index.html index.htm;}location /wu
{
alias wucg.com;
}error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}}
}

进入配置文件
填入关键信息测验网站是否能执行(alias)

location /wu
{
alias wucg.com;
}

创建需要的网页目录与网页信息

root@localhost:# mkdir wucg.com
root@localhost:# echo "<h1>wuwuwuwuwuwu</h1>" > wucg.com/index.html
root@localhost:# cat wucg.com/index.html
<h1>wuwuwuwuwuwu</h1>

查看配置文件语法是否正确并重启服务

root@localhost:/usr/local/nginx# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
root@localhost:/usr/local/nginx# /usr/local/nginx/sbin/nginx -s reload
从浏览器测验

在这里插入图片描述

填入关键信息测验网站是否能执行(root)

location /txt
{
root text;
}
vim /usr/local/nginx/conf/nginx.conf
[root@localhost ~]# cat /usr/local/nginx/conf/nginx.conf
worker_processes  1;
events {worker_connections  1024;
}
http {include       mime.types;default_type  application/octet-stream;sendfile        on;keepalive_timeout  65;server {listen       80;server_name  localhost;location / {root   html;index  index.html index.htm;}location /txt
{
root text;
}error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}}
}
创建需要的网页目录与网页信息
root@localhost:/usr/local/nginx# mkdir text
root@localhost:/usr/local/nginx# echo "<h1>gangganggangganggang</h1>" > text/index.htmlroot@localhost:/usr/local/nginx# cat text/index.html
<h1>gangganggangganggang</h1>

在这里插入图片描述

只新建一个text目录无法满足访问需求还需要在text目录下新建一个txt目录才行
root@localhost:/usr/local/nginx# cd text/
root@localhost:/usr/local/nginx/text# mkdir txt
root@localhost:/usr/local/nginx/text# ll
总用量 4
-rw-r--r-- 1 root root 30  63 22:32 index.html
drwxr-xr-x 2 root root  6  63 22:37 txt
root@localhost:/usr/local/nginx/text# cp -av index.html txt/
'index.html' -> 'txt/index.html'

新建好后再次用浏览器查看,浏览器一出现设置好的信息。

在这里插入图片描述

网页显示没用问题后,在回到配置文件内将一下内容填写进去,即可实现作为下载站点的需求

### wcg 20240603 -beginlocation /wcg {   #alias html;  # 替换为你的文件存储路径             root html;  # 替换为你的文件存储路径 #autoindex on;  # 开启目录浏览#autoindex_exact_size off;  # 显示文件的大概大小#autoindex_localtime on;  # 显示文件的服务器时间#charset utf-8,gbk;  # 解决中文目录乱码问题
### wcg 20240603 -begin

配置文件具体信息:

[root@wcg ~]# cat /usr/local/nginx/conf/nginx.conf
worker_processes  1;
events {worker_connections  1024;
}
http {include       mime.types;default_type  application/octet-stream;sendfile        on;keepalive_timeout  65;server {listen       80;server_name  localhost;location / {root   html;index  index.html index.htm;}### wcg 20240603 -beginlocation /wcg {  #alias html;  # 替换为你的文件存储路径  root html;  # 替换为你的文件存储路径  #autoindex on;  # 开启目录浏览  #autoindex_exact_size off;  # 显示文件的大概大小  #autoindex_localtime on;  # 显示文件的服务器时间  #charset utf-8,gbk;  # 解决中文目录乱码问题 
### wcg 20240603 -begin
}location /v {alias v.hanyw.com;
}error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}}
}
http://www.lryc.cn/news/362457.html

相关文章:

  • vue3简单快速实现主题切换功能
  • 国联易安:网络反不正当竞争,要防患于未然
  • Linux 网络配置 01
  • 快速入门C++正则表达式
  • java —— 缓冲字符输入流/缓冲字符输出流
  • blender从视频中动作捕捉,绑定到人物模型
  • 掘金滑块验证码安全升级,继续破解
  • 数据结构练习题——Java实现
  • 行为设计模式之状态模式
  • 找回以前的视频:技术与实践3个指南
  • GCN 代码解析(一) for pytorch
  • 2024年云计算、信号处理与网络技术国际学术会议(ICCCSPNT 2024)
  • 希尔排序法
  • thinkphp6.0版本下子查询sql处理
  • flowable工作流 完成任务代码 及扩展节点审核人(实现多级部门主管 审核等)详解【JAVA+springboot】
  • 【电源专题】一体成型电感为什么需要注意耐压问题
  • 如何看待时间序列与机器学习?
  • vue图标不显示
  • 文件夹如何加密码全攻略,5个文件夹加密方法新手也能学
  • useState和store的区别
  • vscode远程登录阿里云服务器【使用密钥方式--后期无需再进行密码登录】【外包需要密码】
  • 解决uniapp里的onNavigationBarSearchInputClicked不生效
  • Windows下搭建Cmake编译环境进行C/C++文件的编译
  • 实用新型专利申请材料的撰写与准备
  • 代码随想录算法训练营第60天|● 84.柱状图中最大的矩形
  • 让AI给你写代码(9.3):一点改进,支持扩展本地知识库
  • 探索煤化工厂巡检机器人的功能、应用及前景
  • 【活动】GPT-4O:AI语言生成技术的新里程碑
  • 实验笔记之——DPVO(Deep Patch Visual Odometry)
  • 力扣----轮转数组