确保该rpm已经下载到本地,如在/opt/packages下边有createrepo-0.9.9-17.el6.noarch.rpm
#cd /opt/packages
#rpm -ivh createrepo-0.9.9-17.el6.noarch.rpm
安装createrepo需要依赖, 执行上面命令时确保已经安装以下包:
deltarpm.x86_64 0:3.5-0.5.20090913git.el6.rpm
libxml2-python.x86_64 0:2.7.6-12.el6_4.1.rpm
python-deltarpm.x86_64 0:3.5-0.5.20090913git.el6.rpm
libxml2.x86_64 0:2.7.6-12.el6_4.1.rpm
如果联网可以直接安装:yum install -y createrepo
将所有需要的rpm包放在本地任意目录下,如/opt/packages
#cd /opt/packages
#createrepo ./
#cd /etc/yum.repo.d
#touch local.repo
#vi local.repo
[repo-local]
name=local
baseurl=file:///opt/packages
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
yum install perl
#yum -y install nginx
#yum -y install createrepo
修改为location / {
root /usr/share/nginx/html;
index index.html index.htm;
autoindex on;
}
重启nginx服务:#service nginx restart
#cd /usr/share/nginx/html(该目录可以在配置文件default.conf中修改,在这儿用它默认值)
#mkdir -p yumrepo/centos/x86_64/6/
将需要的包和依赖都放入yumrepo/centos/x86_64/6/
#createrepo yumrepo/centos/x86_64/6/
#cd /etc/yum.repos.d
#vim /myrepo.repo (必须要以.repo作为后缀)
[base]
name = baserepo
baseurl = http://server_name/yumrepo/centos/x86_64/6/
enable = 1
gpgcheck = 0