搭建PHP7私有仓库
一、服务端配置
1. 编辑站点配置
# 1. 安装nginx
➜ ~ yum install nginx -y
# 2. 编辑配置文件
➜ ~ cat /etc/nginx/conf.d/file.conf
server {
server_tokens off;
listen 80;
server_name file.wangrengang.pro;
location / {
root /html/file;
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
}
}
# 3. 启动nginx
➜ ~ systemctl enable --now nginx
2. 创建仓库目录
➜ ~ mkdir -p /html/file/Package/
# 仓库目录放置在nginx配置的下载页面,以此提供http访问
3. 准备安装包
# 1. 配置第三方源
➜ ~ rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
➜ ~ rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
# 2. 下载PHP软件到仓库目录
➜ ~ yum install -y --downloadonly --downloaddir=/html/file php71w-cli php71w-common php71w-devel php71w-embedded php71w-gd php71w-mcrypt php71w-mbstring php71w-pdo php71w-xml php71w-fpm php71w-mysqlnd php71w-opcache php71w-pecl-memcached php71w-pecl-redis php71w-pecl-mongodb php71w-json php71w-pecl-apcu php71w-pecl-apcu-devel # 此操作只下载rpm包
4. 创建索引信息
# 1. 安装createrepo
➜ ~ yum install createrepo -y
# 2. 创建索引信息
➜ ~ createrepo /html/file/Package
# /html/file/Package目录为软件目录,此目录必须包含软件包,才可以正确生成repodata目录及数据信息
说明:
-
软件仓库必须包含
repodata
(软件包索引信息,此目录名称必须为repodata
)以及软件包目录(此目录对名称没有要求) -
在仓库目录创建
repodata
,使其成为一个yum
可以识别的仓库
二、客户端配置
1. 编写自建仓库文件
➜ ~ cat /etc/yum.repos.d/rengang.repo
[Rengang] # 仓库名称
name=rengang PHP7 repo # 仓库简介
baseurl=http://file.wangrengang.pro/Package/ # 仓库地址
enabled=1 # 启用仓库
gpgcheck=0 # 禁用签名验证
说明:repo
仓库文件中,不要使用中文及注释,复制本文内容时,请删除中文信息
2. 生成仓库缓存
➜ ~ yum clean all
➜ ~ yum makecache
3. 检查仓库信息
➜ ~ yum repolist all
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
repo id repo name status
Rengang rengang PHP7 repo enabled: 31 # 仓库识别正常
4. 安装PHP7.1软件
➜ ~ yum install php71w-cli php71w-common php71w-devel php71w-embedded php71w-gd php71w-mcrypt php71w-mbstring php71w-pdo php71w-xml php71w-fpm php71w-mysqlnd php71w-opcache php71w-pecl-memcached php71w-pecl-redis php71w-pecl-mongodb php71w-json php71w-pecl-apcu php71w-pecl-apcu-devel
说明: 将repo
文件上传到服务器,以后使用就可以直接下载,而不用编辑仓库文件了
# 1. 上传文件到服务器
➜ ~ scp -rp /etc/yum.repos.d/rengang.repo root@wangrengang.pro:/html/file/Package
# 2. 客户端下载即可使用
➜ ~ wget -c -P /etc/yum.repos.d/ http://file.wangrengang.pro/rengang.repo