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

Linux之nginx离线安装

1、安装Nginx

  1. 官网下载linux版本,然后安装nginx运行时需要的依赖
yum install -y pcre pcre-devel zlib zlib-devel openssl openssl-devel gcc-c++
  1. 上传nginx的源码包【已上传就忽略】
  2. 解压源码包到当前目录:
tar -zxvf nginx-1.20.2.tar.gz
  1. 进入到解压目录(cd nginx-1.20.2)后,执行指令
cd nginx-1.20.2
./configure --prefix=/usr/local/nginx
  1. 执行编译nginx的指令
make
  1. 执行安装nginx的指令,安装到上述指定的 /usr/local/nginx 目录
make install
  1. 进入到nginx安装目录/usr/local/nginx,启动nginx服务
cd /usr/local/nginx
sbin/nginx

2、yum方式下载网络问题

异常信息
已加载插件:fastestmirror
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"


 One of the configured repositories failed (未知),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=<repoid> ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable <repoid>
        or
            subscription-manager repos --disable=<repoid>

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: base/7/x86_64
原因说明

CentOS 内置的软件镜像源无法访问,替换成国产的软件镜像源即可。

解决办法

找到/etc/yum.repos.d/CentOS-Base.repo文件并打开,将如下内容覆盖掉CentOS-Base.repo文件中的内容。或者直接将资料中提供的CentOS-Base.repo文件替换掉/etc/yum.repos.d/CentOS-Base.repo文件。

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
 
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#released updates 
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

3、Nginx部署项目、启停

1、将vue打包后的静态资源,上传到nginx的html目录中
2、配置nginx的配置文件,在 conf/nginx.conf 的http中增加配置(反向代理等)
3、启动nginx服务:sbin/nginx
4、停止:sbin/nginx -s quit
5、重新加载(修改配置后使用):sbin/nginx -s reload

http://www.kler.cn/news/368324.html

相关文章:

  • 【MyBatis源码】SqlSessionFactoryBuilder源码分析
  • Redis 基础 问题
  • 100种算法【Python版】第10篇——深度优先搜索
  • 【轻量级聊天应用】Vocechat本地服务器部署结合cpolar异地即时通讯
  • Handler、Looper、message进阶知识
  • 计算机网络:网络层 —— IPv4 地址的应用规划
  • 图文详解ChatGPT-o1完成论文写作的全流程
  • android openGL ES详解——缓冲区VBO/VAO/EBO/FBO/离屏渲染
  • 使用Node.js和Express构建RESTful API
  • 机器学习介绍
  • QT 信号重载时的处理方法
  • jmeter自定义函数
  • 浅谈网络 | 通信协议
  • Leetcode刷题笔记13
  • 16天自制CppServer-day05
  • apply,call,bind手写
  • 关于Docker的docker engine stopped问题解决
  • Lesson11---stack
  • fileinclude
  • 【计算机网络 - 基础问题】每日 3 题(五十五)
  • Discuz 论坛开发一套传奇发布站与传奇开服表
  • Python中的递归函数是如何工作的,它有哪些应用场景?
  • JAVA高性能缓存项目
  • 基于SSM 的音乐播放系统设计与实现
  • vue3中mitt和pinia的区别和主要用途,是否有可重合的部分?
  • 防火墙和堡垒机有什么区别?