1|1111

news/2024/7/5 3:36:55

1、指定在每天凌晨4:00将该时间点之前的系统日志信息(/var/log/messages )备份到目录下/backup,备份后日志文件名显示格式logfileYY-MM-DD-HH-MM

2、配置ssh免密登陆:客户端主机通过redhat用户基于秘钥验证方式进行远程连接服务器的root用户。

3、

nginx基本配置
 
  [root@localhost ~]# dnf install nginx -y
    [root@localhost ~]# nginx -v
    [root@localhost ~]# nginx -V
    [root@localhost ~]# rpm -ql nginx
    [root@localhost httpd]# tree /etc/nginx
    [root@localhost ~]# tree /etc/nginx/
    /etc/nginx/
    ├── conf.d     #子配置文件目录
    ├── default.d  
    ├── fastcgi.conf
    ├── fastcgi.conf.default
    ├── fastcgi_params  #用以翻译nginx的变量供php识别
    ├── fastcgi_params.default
    ├── koi-utf
    ├── koi-win
    ├── mime.types   #用以配置支持的媒体文件类型
    ├── mime.types.default
    ├── nginx.conf    #主配置文件
    ├── nginx.conf.default
    ├── scgi_params
    ├── scgi_params.default
    ├── uwsgi_params  #用以配置nginx的变量供python识别
    ├── uwsgi_params.default
    └── win-utf
    [root@localhost ~]# tree /usr/share/nginx/html/  #默认的nginx网站根目录
    [root@localhost ~]# tree /var/log/nginx/  #nginx的日志文件所在目录
    
    

    #nginx服务主配置文件nginx.conf的结构
    [root@localhost nginx]# grep   ^[^#] nginx.conf
    =========全局配置(无{}标志)=======================
    user nginx;       #进程所属用户
    worker_processes auto;  #worker数量
    error_log /var/log/nginx/error.log;  #错误日志存放路径
    pid /run/nginx.pid;  #pid文件路径
    include /usr/share/nginx/modules/*.conf;  #include导入的功能模块配置文件
    =========全局配置(无{}标志)=======================
    
    ==========性能配置(有{}标志)=================
    events {
        worker_connections 1024;  #TCP连接数
    }
    ==========性能配置(有{}标志)=================
    
    =========http模块配置(有{}标志)==================
    http {   #http区块开始
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for"';   #错误日志格式
        access_log  /var/log/nginx/access.log  main;  #访问日志路径
        sendfile            on;   #开启高效文件传输模式
        tcp_nopush          on;   #性能优化参数
        tcp_nodelay         on;   #性能优化参数
        keepalive_timeout   65;   #持久连接时间或超时时间
        types_hash_max_size 4096;  #性能优化参数
        include             /etc/nginx/mime.types;  #可解析的静态资源类型
        default_type        application/octet-stream;  
        # Load modular configuration files from the /etc/nginx/conf.d directory.
        # See http://nginx.org/en/docs/ngx_core_module.html#include
        # for more information.
        include /etc/nginx/conf.d/*.conf;  #子配置文件存放路径
        server {  #server区块开始
            listen       80;   #监听端口
            listen       [::]:80;
            server_name  _;    #服务器的名字
            root         /usr/share/nginx/html;  #主页存放路径
            # Load configuration files for the default server block.
            include /etc/nginx/default.d/*.conf;  #子配置文件存放路径
            error_page 404 /404.html;  #404错误返回的页面
                location = /40x.html {  #使用location定义用户请求的uri
            }
            error_page 500 502 503 504 /50x.html; #500、502、503、504返回的页面
                location = /50x.html {
            }
        }  #server区块结束
    }   #http区块结束
    =========http模块配置(有{}标志)==================

    [root@localhost ~]#systemctl disable firewalld --now
    [root@localhost ~]# systemctl restart nginx
    #测试可以使用curl命令访问web服务器或者使用浏览器访问
    [root@localhost ~]# curl -I  localhost
    HTTP/1.1 200 OK
    Server: nginx/1.21.5
    Date: Fri, 17 Nov 2023 08:40:28 GMT
    Content-Type: text/html
    Content-Length: 3510
    Last-Modified: Mon, 23 Oct 2023 15:48:29 GMT
    Connection: keep-alive
    ETag: "653695cd-db6"
    Accept-Ranges: bytes

作业
构建静态网站

echo "hello world" > /usr/share/nginx/html/index.html
访问

curl 192.168.59.132
设置基于地址的网页访问

创建根目录

mkdir -pv /www/ip/100
mkdir -pv /www/ip/200
构建网站

echo this is 100 > /www/ip/100/index.html
echo this is 200 > /www/ip/200/index.html
设置selinux

 setenforce 0
#设置SELinux为permissive模式,这样可以避免无法看到网页页面内容的问题
创建并编写配置文件

[root@localhost ~]# vim /etc/nginx/conf.d/test_ip.conf
server {
        listen 192.168.59.100:80;
        root /www/ip/100;
        location / {
        }
}
server {
        listen 192.168.59.200:80;
        root /www/ip/200;
        location / {
        }
}
效果

[root@localhost ~]# systemctl restart nginx
[root@localhost ~]# curl 192.168.59.100
this is 100
[root@localhost ~]# curl 192.168.59.200
this is 200
设置基于端口的网站访问

创建根目录

mkdir -pv /www/port/80
mkdir -pv /www/port/8000

创建并编写配置文件

[root@localhost ~]# cat  /etc/nginx/conf.d/test_port.conf
server {
        listen 192.168.59.132:80;
        root /www/port/80;
        location / {
        }
}
server {
        listen 192.168.59.132:10000;
        root /www/port/10000;
        location / {
        }
}
 

 


http://lihuaxi.xjx100.cn/news/1829182.html

相关文章

【C/PTA —— 10.函数1(课外实践)】

C/PTA —— 10.函数1(课外实践) 一.函数题6-1 符号函数6-2 求排列数6-3 求一个大于10的n位整数w的后n-1位的数,并作为函数值返回。6-4 其右上三角(含主对角线)元素之和。6-5 字符串比较6-6 使用函数求素数和6-7 使用函…

Vue中mvvm的作用

目录 模型表示应用程序的数据。在Vue.js中,它们是JavaScript对象。视图是用户界面。在Vue.js中,使用模板语法编写HTML的表示层。ViewModel是视图的抽象表示,负责处理用户输入的数据,并处理视图的数据绑定。ViewModel使用模型中的…

文件夹重命名:彻底摆脱数字困扰,批量修改文件夹名去除数字

在日常生活和工作中,经常会遇到需要修改文件夹名称的情况。有时候是因为文件夹名称中包含了数字,有时候是因为文件夹名称不符合规范。无论出于什么原因,修改文件夹名称都是一件非常繁琐的事情。尤其是需要修改大量文件夹名称时,手…

一个悄然崛起的国产软件!!AI 又进化了!!

大家好,我是 Jack。 AI 写代码想必很多人都体验过了,使用 AI 编程工具是一个大趋势,越早学会使用 AI 辅助你写代码,你的效率也会越高。 甚至有些公司已经要求员工具备 AI 编程能力。 对于学生党,AI 编程可以帮助我们…

基于白鲸算法优化概率神经网络PNN的分类预测 - 附代码

基于白鲸算法优化概率神经网络PNN的分类预测 - 附代码 文章目录 基于白鲸算法优化概率神经网络PNN的分类预测 - 附代码1.PNN网络概述2.变压器故障诊街系统相关背景2.1 模型建立 3.基于白鲸优化的PNN网络5.测试结果6.参考文献7.Matlab代码 摘要:针对PNN神经网络的光滑…

MySQL 优化器 Index Condition Pushdown下推(ICP)

ICP 测试 准备数据 CREATE TABLE icp (employee_id int(6) NOT NULL AUTO_INCREMENT,first_name varchar(20) DEFAULT NULL,last_name varchar(25) DEFAULT NULL,email varchar(25) DEFAULT NULL,phone_number varchar(20) DEFAULT NULL,PRIMARY KEY (employee_id) );insert i…

LED驱动控制专用电路

一、基本概述 TM1628是一种带键盘扫描接口的LED(发光二极管显示器)驱动控制专用IC,内部集成有MCU 数 字接口、数据锁存器、LED 驱动、键盘扫描等电路。本产品质量可靠、稳定性好、抗干扰能力强。 主要适用于家电设备(智能热水器、微波炉、洗衣机、空调…

初学ARM嵌入式开发有什么好书值得去学习?

初学ARM嵌入式开发有什么好书值得去学习? 以一个从业者的角度来讲,嵌入式覆盖的范围还是比较广的,比如简单单片机,ARM系列,有无操作系统等。复杂程度也不断增加。 刚刚踏入这个行业的时候,算是从零做起。建…