nginx配置本地yum源

一、安装nginx

  1、编辑yum文件

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

[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

  2、安装最新版nginx

yum install nginx -y

  3、修改nginx.conf文件

server {
        listen 8888;
        server_name localhost;
        charset utf-8;                     #设置中文字符集

        location / {
        root  /data;                                                                                                
             autoindex on;                     #打开目录浏览功能
             autoindex_exact_size off;         #关闭字节显示(会以MB的方式显示)
             autoindex_localtime on;           #打开会显示文件上传的本地的时间(默认格林威治时间-8h)
        }
    }

  4、创建repo文件

[local]
name=Centos-local
baseurl=http://127.0.0.1:8888
gpgcheck=0
enabled=1

   5、安装createrepo

yum install -y createrepo

  6、创建源文件

createrepo /data
原文地址:https://www.cnblogs.com/aqicheng/p/14820860.html