天天看点

创建yum仓库及nginx目录映射创建仓库,并目录映射

本文章为原创,如有转载,请注明出处

创建仓库,并目录映射

一、创建 yum 本地仓库

1. 创建本地仓库

mkdir /repo && cd /repo
createrepo .           

2. 下载 rpm 包

mkdir x86_64 && cd x86_64
yumdownloader  xxx(包名)           

3. 更新仓库

cd ..
createrepo --update .           

4. 配置 yum 源

vim /etc/yum.repos.d/test.repo

# 内容
[test]
name=test-base
baseurl=file:///repo/
enabled=1
countme=1
metadata_expire=7d
repo_gpgcheck=0
type=rpm
gpgcheck=0
skip_if_unavailable=True           

5. 安装测试

yum reinstall which(第2步下载的rpm包)           

二、 nginx 目录映射

1. 安装 nginx

dnf install nignx           

2. nginx 启动,查看

# 启动
systemctl start nginx.service

# 查看
ps aux | grep nginx           

3. 修改配置文件

vim /etc/nginx/nginx.conf

# 要修改的内容
    server {
        listen       80;
        location /REPO/ {
            alias /home/REPO/;
            autoindex on;
        }
    }           

4. 重新加载配置文件

# 查看修改之后配置文件的格式是否正确
nginx -t

# 重新加载配置文件
nginx -s reload           

5. 网页访问

http://localhost/repo/           

三、错误解决

1. Permission denied

可能开启了 selinux

# 查看是否开启 selinux
getenforce 

# 关闭 selinux
setenforce 0           

继续阅读