SUSE Linux 15 sp5上Nginx安装配置升级

1.安装SUSE linux 15 SP5
图形化界面安装很简单,选择最小安装,安装好后,使用vim编辑配置文件,结果提示"bash: vim: command not found"。
最简安装把一些常用命令都整没有了,于是又重新选择了Server Applications Module 和 Web and scripting Module安装。
终于可以使用vim命令了,继续往下操作。
安装时没有设置IP地址,/etc/sysconfig/network下没有找到生成的ifcfg-eth0,于是用yast设置IP和网关


2.安装Nginx
localhost:/etc/sysconfig/network # zypper search nginx
Loading repository data...
Reading installed packages...
S | Name             | Summary                                                     | Type
--+------------------+-------------------------------------------------------------+--------
  | dehydrated-nginx | Nginx Integration for dehydrated                            | package
  | nginx            | A HTTP server and IMAP/POP3 proxy server                    | package
  | nginx-macros     | Just some macros to make packaging nginx and modules easier | package
  | nginx-source     | The nginx source                                            | package

Note: For an extended search including not yet activated remote resources please use 'zypper   search-packages'.
#安装
localhost:/etc/sysconfig/network # zypper in nginx
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following NEW package is going to be installed:  nginx
1 new package to install.
Overall download size: 703.3 KiB. Already cached: 0 B. After the operation, additional 2.3 MiB will be used.
Continue? [y/n/v/...? shows all options] (y): y
Retrieving: nginx-1.21.5-150400.3.3.1.x86_64 (sle-module-server-applications)                                                                                                                                                                             (1/1), 703.3 KiB    
Checking for file conflicts: ...........................................................................................................................................................................................................................................[done]
/usr/sbin/useradd -r -c User for nginx -d /var/lib/nginx -U nginx -s /usr/sbin/nologin
(1/1) Installing: nginx-1.21.5-150400.3.3.1.x86_64 .....................................................................................................................................................................................................................[done]
#启用
localhost:/etc/sysconfig/network # systemctl enable nginx
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
#开启服务
localhost:/etc/sysconfig/network # systemctl start nginx
#查看启动状态
localhost:/etc/sysconfig/network # systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
     Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
     Active: active (running) since Thu 2024-06-13 13:06:32 CST; 38s ago
    Process: 8487 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
   Main PID: 8489 (nginx)
      Tasks: 2
     CGroup: /system.slice/nginx.service
             ├─ 8489 "nginx: master process /usr/sbin/nginx -g daemon off;"
             └─ 8490 "nginx: worker process" "" "" "" "" "" "" "" "" ""

Jun 13 13:06:32 localhost systemd[1]: Starting The nginx HTTP and reverse proxy server...
Jun 13 13:06:32 localhost nginx[8487]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Jun 13 13:06:32 localhost nginx[8487]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Jun 13 13:06:32 localhost systemd[1]: Started The nginx HTTP and reverse proxy server.
#查看进程
localhost:/etc/sysconfig/network # ps -ef|grep nginx
root      8489     1  0 13:06 ?        00:00:00 nginx: master process /usr/sbin/nginx -g daemon off;
nginx     8490  8489  0 13:06 ?        00:00:00 nginx: worker process
root      8496  4496  0 13:09 pts/0    00:00:00 grep --color=auto nginx
#查看端口
localhost:/etc/sysconfig/network # ss -tulpn |grep nginx
一切都正常,但是访问http://ip,得到的结果是“无法反问,错误403 Forbidden nginx/1.21.5"
正常情况这里安装好了都是可以打开Nginx的欢迎界面的。
#防火墙设置
localhost:/etc/sysconfig/network # systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
     Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: disabled)
     Active: active (running) since Thu Jun 13 13:09:32 CST; 3h 8min ago
       Docs: man:firewalld(1)
   Main PID: 778 (firewalld)
      Tasks: 2
     CGroup: /system.slice/firewalld.service
             └─ 778 /usr/bin/python3 /usr/sbin/firewalld --nofork --nopid
Jun 13 13:09:32 localhost systemd[1]: Starting firewalld - dynamic firewall daemon...
Jun 13 13:09:32 localhost systemd[1]: Started firewalld - dynamic firewall daemon.
#添加了端口

localhost:/etc/sysconfig/network # firewall-cmd --add-port=80/tcp --permanent
localhost:/etc/sysconfig/network # firewall-cmd --reload
设置了也没有用,原因不在这儿。
#查看错误日志
localhost:/etc/nginx # cat /var/log/nginx/error.log
2024/06/13 13:47:16 [error] 1453#1453: *4 open() "/srv/www/htdocs/index.html" failed (2: No such file or directory), client: 192.168.10.8, server: localhost, request: "GET /index.html HTTP/1.1", host: "192.168.10.39"
"http://192.168.0.39/index.html"
2024/06/13 13:56:43 [error] 2376#2376: *1 directory index of "/srv/www/htdocs/" is forbidden, client: 192.168.10.8, server: localhost, request: "GET / HTTP/1.1", host: "192.168.10.39"
2024/06/13 13:56:47 [error] 2376#2376: *1 directory index of "/srv/www/htdocs/" is forbidden, client: 192.168.10.8, server: localhost, request: "GET / HTTP/1.1", host: "192.168.10.39"
2024/06/13 13:57:00 [error] 2376#2376: *1 directory index of "/srv/www/htdocs/" is forbidden, client: 192.168.10.8, server: localhost, request: "GET / HTTP/1.1", host: "192.168.10.39
里面空空荡荡的,使用SUSE库安装的和从Nginx下载的安装还是有点不同的。
localhost:~ # cd /srv/www/htdocs
localhost:/srv/www/htdocs # ls
50x.html

3.配置Nginx
配置之前好好看了优化的相关文章,优化的参数太多,就修改了自己中意的几个。
3.1配置参数优化Nginx: vim /etc/nginx/nginx.conf
worker_processes  8;
worker_rlimit_nofile 65536;
events {
    worker_connections  10240;
    use epoll;
}
--高效传输
    sendfile        on;
    tcp_nopush     on;

--压缩
    gzip  on;
    gzip_min_length 1k;
    gzip_buffers 4 32k;
    gzip_comp_level 6;
    gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    gzip_vary off;
    gzip_disable "MSIE [1-6]\.";


3.2文件句柄限制:vim /etc/security/limits.conf
*               -       nofile          65536
*               soft    nofile          65536
*               hard    nofile          65536
root            soft    nofile          65536
root            hard    nofile          65536


3.3内核参数优化:vim /etc/sysctl.conf
net.core.somaxconn = 40960
fs.file-max = 999999  --同时打开的最大句柄数
net.ipv4.tcp_tw_recycle = 1--快速回收
net.ipv4.tcp_tw_reuse = 1--开启重用
net.ipv4.tcp_syncookies = 0--启用SYNC cookies
net.ipv4.tcp_max_orphans = 3276800

我的目的是让Nginx做请求代理服务器,所以http配置如下
http {
    include       mime.types;
    default_type  application/octet-stream;

    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;
    keepalive_timeout  65;
    gzip  on;
    gzip_min_length 1k;
    gzip_buffers 4 32k;
    gzip_comp_level 6;
    gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    gzip_vary off;
    gzip_disable "MSIE [1-6]\.";
    upstream srm {
              #sticky;
              ip_hash;
          server  192.168.10.1:82 weight=3 max_fails=2 fail_timeout=36;
          server  192.168.10.2:82 weight=3 max_fails=2 fail_timeout=36;
          server  192.168.10.3:82 weight=3 max_fails=2 fail_timeout=36;
          server  192.168.10.4:82 weight=3 max_fails=2 fail_timeout=36;
                      }
    include conf.d/*.conf;
    server {
        listen       80;
        server_name  localhost;
        #charset koi8-r;
        access_log  /var/log/nginx/host.access.log  main;
        location / {
           root   /srv/www/htdocs/;
           index  index.html index.htm;
           proxy_pass         http://srm;
           proxy_set_header   Host             $host:80;
           proxy_set_header   X-Real-IP        $remote_addr;
           proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
           client_max_body_size     100m;
           proxy_connect_timeout       15;
           proxy_read_timeout          300;
           proxy_send_timeout          500;
           if (-d $request_filename){ rewrite ^/(.*)([^/])$ /$1$2/ permanent; }
        }


4.防火墙设置允许端口
SuSEfirewall2配置简单,但是将被 firewalld替代,用yast2配置更直观一些。
#启停命令及状态查看
systemctl start firewalld
systemctl enable firewalld
systemctl stop firewalld
systemctl disable firewalld
firewall-cmd --state
#查看安全域
localhost:/etc/sysconfig/network  # firewall-cmd --get-zones
localhost:/etc/sysconfig/network  # firewall-cmd --get-default-zone
#配置多个端口
localhost:/etc/sysconfig/network # firewall-cmd --add-port=80/tcp --add-port=22/tcp --permanent
#配置服务
localhost:/etc/sysconfig/network #firewall-cmd --zone=public --add-service=http
#配置修改后重新加载
localhost:/etc/sysconfig/network #firewall-cmd --reload
#列出安全域允许的服务
localhost:/etc/sysconfig/network #firewall-cmd --list-services --zone=public
#查看配置结果
localhost:/etc/sysconfig/network #firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: eth0
  sources: 
  services: dhcpv6-client ssh
  ports: 80/tcp
  protocols: 
  forward: no
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 


5.升级Nginx失败
localhost:/etc/sysconfig/network # nginx -v
nginx version: nginx/1.21.5
但是官网上的版本都已经1.27了,继续往上升级
找到下载链接,下载解压缩:
localhost:/tmp #wget https://nginx.org/download/nginx-1.27.0.tar.gz
localhost:/tmp #mkdir /usr/nginx
localhost:/tmp #mv nginx-1.27.0.tar.gz /usr/nginx
localhost://usr/nginx #tar -zxf nginx-1.27.0.tar.gz
localhost:/usr/nginx #./configure && make &&make install
结果获得错误:
checking for C compiler ... not found
./configure: error: C compiler cc is not found
localhost:/usr/nginx #whereis gcc
可以看到安装了gcc,怀疑版本问题
localhost:/usr/nginx #zypper install gcc
果然更新后,检查通过,但是遇到新问题了:
./configure error the HTTP rewrite module requires the PCRE library
localhost:/usr/nginx #zypper install pcre
找不到安装包,只能选择跳过
localhost:/usr/nginx #./confgure --without-http_rewrite_module && make && make install
又遇到新错误
./configure error the HTTP Gzip module requires the zlib library
缺失那我就安装
localhost:/usr/nginx #zypper install zlib
可系统提示已经存在,那就继续跳过
localhost:/usr/nginx #./configure --wirhout-http_rewrite_module --with-zlib=/usr/share/man/mann/zbil.n.gz && make && make install
还是错误:
fatal error:zlib.h:No such file or directory
算了,还是老老实实用1.21.5版本。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/746714.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

ZGC垃圾收集的主要流程

值得说明的是,在执行就地迁移时,ZGC 必须首先压缩指定为对象迁移区域内的对象,这可能会对性能产生负面影响。增加堆大小可以帮助 ZGC 避免使用就地迁移。 如上图,ZGC 的工作流程主要包括以下几个步骤: (STW…

DVWA 靶场 SQL Injection 通关解析

前言 DVWA代表Damn Vulnerable Web Application,是一个用于学习和练习Web应用程序漏洞的开源漏洞应用程序。它被设计成一个易于安装和配置的漏洞应用程序,旨在帮助安全专业人员和爱好者了解和熟悉不同类型的Web应用程序漏洞。 DVWA提供了一系列的漏洞场…

Python+Vue+Springboot实现电脑端微信好友导入导出

主要实现思路是使用python的自动化库uiautomation进行客户端抓取联系人,vue做管理界面,springboot做后端服务。 截图如下 登录: 首页 好友导出 不足之处就是只有windows版本,mac上还不行 而且谷歌和edge浏览器的效果是最好的&a…

面试-Java线程池

1.利用Excutors创建不同的线程池满足不同场景的需求 分析: 如果并发的请求的数量非常多,但每个线程执行的时间非常短,这样就会频繁的创建和销毁线程。如此一来,会大大降低系统的效率。 可能出现,服务器在为每个线程创建…

LAMP架构的源码编译环境下部署Discuz论坛

一、LAMP架构 LAMP架构是一种常见的用于构建动态网站的技术栈 组成功能Linux(操作系统)LAMP 架构的基础,用于托管 Web 服务器和应用程序Apache(Web服务器)接收和处理客户端请求,并将静态和动态内容发送给…

20240626让飞凌的OK3588-C开发板在相机使用1080p60分辨率下预览

20240626让飞凌的OK3588-C开发板在相机使用1080p60分辨率下预览 2024/6/26 15:15 4.2.1 全编译测试 在源码路径内,提供了编译脚本 build.sh,运行该脚本对整个源码进行编译,需要在终端切换到解压 出来的源码路径,找到 build.sh 文件…

设备智能化:中国星坤线缆组件的解决方案!

在当今快速发展的电子行业中,产品小型化和成本效益是制造商追求的两大目标。中国星坤端子电缆组件以其灵活性和高效性,为电子设备制造商提供了一种理想的解决方案。本文将探讨星坤端子电缆组件的优势以及其在不同电子设备中的应用。 端子线:小…

Spring AI 实现调用openAi 多模态大模型

什么是多模态? 多模态(Multimodal)指的是数据或信息的多种表现形式。在人工智能领域,我们经常会听到这个词,尤其是在近期大型模型(如GPT-4)开始支持多模态之后。 模态:模态是指数据的一种形式,例如文本、图像、音频等。每一种形式都是一种模态。多模态:多模态就是将…

uniapp地图点击获取位置

主页面 <view class"right-content" click.stop"kilometer(item)"><view class"km">{{item.distance||0}}km</view><image src"../../static/map.png" mode""style"width: 32rpx; height: 32rpx…

Linux-笔记 OverlayFS文件系统入门

目录 前言 主要概念 工作原理 特点特性 1、上下合并 2、同名文件覆盖 3、同名目录合并 4、写时拷贝 实操入门 内核配置 挂载文件系统 验证 1、同名文件覆盖 2、同名目录合并 3、写时拷贝 1&#xff09;验证新增文件或目录 2&#xff09;验证修改文件 3&…

2024最新谷歌镜像网站入口分享

google谷歌搜索引擎最新可用镜像站列表&#xff1a;&#xff08;注意不要登录账号&#xff0c;镜像站并非谷歌官方网站&#xff09; 谷歌镜像网站1&#xff1a;https://google.cloudnative.love/ 谷歌镜像网站2&#xff1a;https://gsearch.g.shellten.top/ 谷歌镜像网站3&…

【论文阅读】--Popup-Plots: Warping Temporal Data Visualization

弹出图&#xff1a;扭曲时态数据可视化 摘要1 引言2 相关工作3 弹出图3.1 椭球模型3.1.1 水平轨迹3.1.2 垂直轨迹3.1.3 组合轨迹 3.2 视觉映射与交互 4 实施5 结果6 评估7 讨论8 结论和未来工作致谢参考文献 期刊: IEEE Trans. Vis. Comput. Graph.&#xff08;发表日期: 2019&…

螺丝扭断力试验机SJ-12

一、设备简介&#xff1a; 螺丝扭断力试验机用于测试螺丝的耐扭断力。本机将螺丝产品所受到轴向扭转力与反作用力&#xff0c;常用扭力扳手来计量。本机可对产品进行转力测、锁动测试、锁动扭力测试等多种测试方式。 二、设备使用&#xff1a; 1、将螺丝强度扭力试验机底座锁于…

天润融通:AI赋能客户体验,推动企业收入和业绩增长

“客户体验已经成为全球企业差异化的关键。人工智能与数据分析等创新技术正在加速推动企业在客户体验计划中取得成功&#xff0c;以保持领先地位”。Customer Insights & Analysis 研究经理Craig Simpson说道。 客户体验 (CX&#xff0c;Customer Experience) 是客户在与企…

STM32CubeMX与RT-Thread Studio协助使用(实现点亮LED)

1创建自己的项目 1-1选择板子 1-2生成的项目 运行一下看是否创建成功 零警告零错误 2配置STM32Cude 2-1找打如图图标点击&#xff08;CubeMX的图标&#xff09; 2-2输入自己安装的路径选中exe文件 点击Browse 找到如图选中&#xff0c;在打开&#xff08;STM32CubeMX的安装路…

变长的时间戳设计,第2版

以前的时间戳有32位&#xff0c;以秒为单位&#xff0c;231秒≈68年&#xff0c;从1970年开始&#xff0c;到2038年会出问题。 现在的时间戳有64位&#xff0c;表达范围仍然受限。 设计变长的时间戳&#xff0c;以32位为单元&#xff0c;最短有32位&#xff0c;最长有328256位…

如何使用代理 IP 防止多个 Facebook 帐户关联 - 最佳实践

在社交媒体被广泛应用的今天&#xff0c;Facebook作为全球最大的社交网络平台之一&#xff0c;面临着很多挑战&#xff0c;其中之一就是用户行为的管理和安全。 为了防止多个账户之间的关联和滥用&#xff0c;Facebook需要采取一系列措施&#xff0c;其中包括使用静态住宅代理…

【Redis】数据持久化

https://www.bilibili.com/video/BV1cr4y1671t?p96 https://blog.csdn.net/weixin_54232666/article/details/128821360 单点redis问题&#xff1a; 数据丢失问题&#xff1a;实现Redis数据持久化并发能力问题&#xff1a;搭建主从集群&#xff0c;实现读写分离故障恢复问题&…

探索顺序结构:栈的实现方式

&#x1f511;&#x1f511;博客主页&#xff1a;阿客不是客 &#x1f353;&#x1f353;系列专栏&#xff1a;渐入佳境之数据结构与算法 欢迎来到泊舟小课堂 &#x1f618;博客制作不易欢迎各位&#x1f44d;点赞⭐收藏➕关注 ​​ 一、栈的定义 栈&#xff08;Stack&#xf…