centos7更换阿里云yum源后无法安装nginx的问题解决

在centos7上,我将yum源更换为阿里云源,按照配置完成后,想使用yum安装nginx,但是老是提示我找不到nginx,没有可用的安装包,无论我是换为华为云的yum源,还是其他国内源,都无法找到。我的centos版本为7.7

无论我是安装epel-release,还是安装nginx的仓库,都没办法找到nginx包

我的nginx repo配置也没问题

一安装就找不到

但是可以用yum搜索到nginx的其他组件

这不科学

后来我想一个办法,在能够yum安装nginx的同样的机器上,把nginx相关包下载下来,然后把rpm包导入问题的机器上,然后使用rpm方式安装

yum install --downloadonly --downloaddir=/tmp/nginx nginx<br/>
命令说明
--downloadonly 只下载,不安装

--downloaddir=/tmp/nginx 指定下载保存目录

可以看到相关的依赖的rpm包已经下载好了

然后使用打包上传到问题机器上

tar -cvf nginx.tar nginx
scp  nginx.tar [email protected]:/root

到问题机上解压后,以依次忽略依赖和强制安装的方式安装这些rpm包

rpm -ivh nginx-all-modules-1.12.2-2.el7.noarch.rpm --nodeps --force
rpm -ivh nginx-filesystem-1.12.2-2.el7.noarch.rpm --nodeps --force
rpm -ivh nginx-mod-http-geoip-1.12.2-2.el7.x86_64.rpm --nodeps --force
rpm -ivh nginx-mod-http-image-filter-1.12.2-2.el7.x86_64.rpm --nodeps --force
rpm -ivh nginx-mod-http-perl-1.12.2-2.el7.x86_64.rpm --nodeps --force
rpm -ivh nginx-mod-http-xslt-filter-1.12.2-2.el7.x86_64.rpm --nodeps --force
rpm -ivh nginx-mod-mail-1.12.2-2.el7.x86_64.rpm --nodeps --force
rpm -ivh nginx-mod-stream-1.12.2-2.el7.x86_64.rpm --nodeps --force

安装完成后,确定nginx可用

最后将nginx作为服务加入sytemd启动

vi /lib/systemd/system/nginx.service

内容如下:

 [Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/run/nginx.pid
# Nginx will fail to start if /run/nginx.pid already exists but has the wrong
# SELinux context. This might happen when running `nginx -t` from the cmdline.
# https://bugzilla.redhat.com/show_bug.cgi?id=1268621
ExecStartPre=/usr/bin/rm -f /run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true

[Install]
WantedBy=multi-user.target                                

Description:描述服务
After:描述服务类别
[Service]服务运行参数的设置
Type=forking是后台运行的形式
ExecStart为服务的具体运行命令
ExecReload为重启命令
ExecStop为停止命令
PrivateTmp=True表示给服务分配独立的临时空间
注意:[Service]的启动、重启、停止命令全部要求使用绝对路径
[Install]运行级别下服务安装的相关设置,可设置为多用户,即系统运行级别为3

然后niginx就可以正常启动了

原文地址:https://blog.51cto.com/11555417/2486622

时间: 2024-07-28 13:32:33

centos7更换阿里云yum源后无法安装nginx的问题解决的相关文章

安装丨CentOS7更换阿里云yum源

参考: https://blog.csdn.net/HistoryCreator/article/details/78570711 https://yq.aliyun.com/ziliao/408380 1.备份系统yum源 cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak 2.设置阿里云yum源 wget -O /etc/yum.repos.d/CentOS-Base.repo http://m

Centos7更换阿里云yum源

备份 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup或mv /etc/yum/repos.d/{,CentOS-Base.repodate -I} centos7 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 或 curl -o /etc/yum.repos.d/

CentOS7 配置阿里云yum源,非常之简单

1.进入yum的文件夹 命令:cd   /etc/yum.repos.d/ 2.下载wget 命令:yum -y install wget 3.删除yum文件夹所有yum源 命令:rm -rf    /etc/yum.repos.d/*.repo 4.利用wget下载阿里云repo文件 命令:wget  http://mirrors.aliyun.com/repo/Centos-7.repo 5.执行yum源更新命令 命令:yum clean all 命令:yum makecache 注意:依次

更换阿里云YUM源

下载阿里云的repo文件 centos 6: wget http://mirrors.aliyun.com/repo/Centos-6.repo centos 7: wget http://mirrors.aliyun.com/repo/Centos-7.repo cd /etc/yum.repos.d 备份旧的源 cp CentOS-Base.repo CentOS-Base.repo_2015-06-11 覆盖旧的源文件 mv Centos-6.repo CentOS-Base.repo 生

CentOS7 配置阿里云yum源

1.打开centos的yum文件夹 输入命令cd  /etc/yum.repos.d/ 2.用wget下载repo文件 输入命令wget  http://mirrors.aliyun.com/repo/Centos-7.repo 如果wget命令不生效,说明还没有安装wget工具,输入yum -y install wget 回车进行安装. 当前目录是/etc/yum.repos.d/,刚刚下载的Centos-7.repo也在这个目录上 3.备份系统原来的repo文件 mv  CentOs-Bas

CentOS7安装(三)- 配置阿里云yum源

CentOS7安装(三)- 配置阿里云yum源 CentOS7安装好以后,完成网络配置以后,就是开始配置yum源,因为yum安装我们需要的各种软件. 具体步骤如下: 1.打开centos的yum文件夹 输入命令 cd /etc/yum.repos.d/ 2.用wget下载repo文件 输入命令wget:http://mirrors.aliyun.com/repo/Centos-7.repo 如果wget命令不生效,说明还没有安装wget工具,输入yum -y install wget 回车进行安

CentOS配置本地yum源/阿里云yum源/163yuan源,并配置yum源的优先级

一.用Centos镜像搭建本地yum源 由于安装centos后的默认yum源为centos的官方地址,所以在国内使用很慢甚至无法访问,所以一般的做法都是把默认的yum源替换成aliyun的yum源或者163等国内的yum源(下文介绍如何配置). 但是以上的方法都是需要网络的,当没有网络的时候就无法使用了,所以还有一个常用的方法就是用Centos的iso镜像搭建本地yum源,这样安装软件的速度就会飞快,缺点是可能有些包没有. 1.安装Centos后默认的yum源如下 [[email protect

【yum】搭建yum源,163 阿里云yum源部署

配置阿里云yum源 前提:可以访问互联网 1. 备份你的原镜像文件,以免出错后可以恢复 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup 2.下载新的CentOS-Base.repo 到/etc/yum.repos.d/ wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

【嵌入式硬件Esp32】Ubuntu18.04 更换阿里云软件源

使用Ubuntu 的apt-get来安装软件是总是因为官方源的速度太慢而抓狂. 但是用阿里云的源就很快,下面总结一下如何更换Ubuntu的软件源. 一.备份sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak  二.修改sudo vim /etc/apt/sources.list 将source.list文件内容替换成下面的 deb http://mirrors.aliyun.com/ubuntu/ trusty main restric