CentOS搭建局域网YUM源
-
先搭建本地YUM源
确认系统版本 [root@moke ~]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) [root@moke ~]#
准备资源: http://mirror.nsc.liu.se/centos-store/7.2.1511/isos/x86_64/CentOS-7-x86_64-Everything-1511.iso
配置本地Yum源 FTP方式上传系统ISO资源至home目录 加载 CentOS的ISO镜像并挂载: [root@moke media]# cd /mnt/ [root@moke mnt]# ls CentOS-7-x86_64-Everything-1511.iso [root@moke mnt]# mkdir dvdiso [root@moke mnt]# ls CentOS-7-x86_64-Everything-1511.iso dvdiso [root@moke mnt]# mount -o loop -t iso9660 CentOS-7-x86_64-Everything-1511.iso dvdiso/ mount: /dev/loop0 写保护,将以只读方式挂载 umount -v /mnt/dvdiso 这是卸载
cd /etc/yum.repos.d/ //禁用yum的网络更新方式,简单地将默认首选的CentOS-Base.repo改名为CentOS-Base.repo.bak即可 mv CentOS-Base.repo CentOS-Base.repo.bak [root@moke yum.repos.d]# ls CentOS-Base.repo [root@moke yum.repos.d]# cat CentOS-Base.repo [base] name=CentOS-7 - Base #mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=os&infra=$infra baseurl=file:///mnt/dvdiso/ gpgcheck=1 enable=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 [root@moke yum.repos.d]# 其中baseurl修改为ISO的挂载目录,enabled=1开启本地更新模式
清除原有的yum信息并建立缓存文件 [root@moke yum.repos.d]# yum clean all 已加载插件:fastestmirror 正在清理软件源: base c7-media centosplus extras updates Cleaning up everything [root@moke yum.repos.d]# yum makecache
检查ISO软件列表 [root@moke yum.repos.d]# yum list Loaded plugins: fastestmirror Determining fastest mirrors
-
nginx安装
上传文件至nginx-1.18.0.tar.gz 服务器
安装依赖 yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel openssl openssl-devel gcc
错误处理: Error: Package: glibc-devel-2.17-105.el7.x86_64 (base) Requires: glibc = 2.17-105.el7 Installed: glibc-2.17-157.el7_3.2.x86_64 (@update) glibc = 2.17-157.el7_3.2 Available: glibc-2.17-105.el7.x86_64 (base) glibc = 2.17-105.el7 解决方法: yum downgrade glibc glibc-devel glibc-common glibc-headers
编译安装 使用普通权限用户安装,安全起见。 [moke@moke ~]$ cd nginx-1.18.0 配置 ./configure --prefix=/home/moke/nginx 编译安装 make && make install 检测nginx的配置是否正确 /home/moke/nginx/sbin 命令 ./nginx -t nginx: the configuration file /home/moke/nginx/conf/nginx.conf syntax is ok nginx: configuration file /home/moke/nginx/conf/nginx.conf test is successful 启动 ./nginx
配置nginx http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 8080; #普通用户只能启动1024以上端口 server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { autoindex on; root /mnt/dvdiso; #此处为服务器镜像路径 #index index.html index.htm; }
nginx重新加载配置 ./nginx -s reload
访问效果
配置yum client vi /etc/yum.repos.d/nginx.repo [rhel-media] name=Red Hat Enterprise Linux 7.2 baseurl=http://172.16.2.157/ # 指向反向代理yum enabled=1 gpgcheck=0 gpgkey=http://172.16.2.157/RPM-GPG-KEY-CentOS-7