本文章為原創,如有轉載,請注明出處
建立倉庫,并目錄映射
一、建立 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