红联Linux门户
Linux帮助

CentOS使用yum代理安装软件

发布时间:2017-07-29 15:39:39来源:linux网站作者:Moxiao__墨箫
解决问题:
Windows(192.168.25.11)和CentOS(192.168.106.231)在公司内网中,但是CentOS不能上网,Windows可以上网,需要在CentOS上安装比较多的软件,离线安装太麻烦。因此,为了能让CentOS使用yum联网安装,做一下工作。
 
1]、在windows上搭建Nginx正向代理服务器
1、在Nginx官网下载最新稳定版:http://nginx.org/en/download.html
2、Windows系统上安装Nginx(解压即可)。
cd c:\
unzip nginx-1.13.1.zip
cd nginx-1.13.1
start nginx
3、配置Nginx正向代理( nginx.conf)。
worker_processes  1;
events {
worker_connections  1024;
}
http {
resolver     192.168.99.100; # 对本机可用的DNS 
server {
listen   8000; # 监听端口
location / {
proxy_pass http://$http_host$request_uri;
}
}
}
4、重启nginx即可
 
2]、设置CentOS使用代理上网
1、暂时使用代理 (设置http代理为Windows上的Nginx即可)
export http_proxy="http://192.168.25.11:8000"
测试:
[root@dras-test yum.repos.d]# wget www.baidu.com
正在连接 192.168.25.11:8000... 已连接。
已发出 Proxy 请求,正在等待回应... 200 OK
长度:2381 (2.3K) [text/html]
正在保存至: “index.html”
100%[=============>] 2,381       --.-K/s   in 0s      
已保存 “index.html” [2381/2381])
成功,可以用代理上网了!
2、永久使用代理
yum里面可以单独设置代理
就是yum源的参数加proxy=“http://ip:PORT”
即在/etc/yum.conf中加入下面几句.
proxy=http://192.168.25.11:8000
proxy_username=username #可选
proxy_password=password #可选
另外:
/root/.bashrc中加入:
export http_proxy=”http://username:password@192.168.25.11:8000”
如果是通过ip或电脑的网卡地址认证,可忽略所有username 和 password .
注:停止使用代理的时候,要把改过的文件改成原样.尤其是如果使用了export http_proxy=”http://192.168.25.11:8000”命令,
要在命令行输入: unset http_proxy ,去除环境变量.
因为export http_proxy=”http://192.168.25.11:8000”这条命令的实质是把export后面的设置写进环境设置文件中.
 
3]、设置CentOS的yum源(此步可选,为了选择国内速度快的yum源)
1,进入yum源配置目录
cd /etc/yum.repos.d
2,备份系统自带的yum源
mv CentOS-Base.repo CentOS-Base.repo.bk
下载163网易的yum源:
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
3,更新玩yum源后,执行下边命令更新yum配置,使操作立即生效
yum makecache
4,除了网易之外,国内还有其他不错的yum源,比如中科大和搜狐的,大家可以根据自己需求下载
中科大的yum源:
wget http://centos.ustc.edu.cn/CentOS-Base.repo
sohu的yum源
wget http://mirrors.sohu.com/help/CentOS-Base-sohu.repo
理论上讲,这些yum源redhat系统以及fedora也是可以用 的,但是没有经过测试,需要的站长可以自己测试一下。
 
4]、yum安装软件
# yum install php php-fpm php-cli php-pdo php-mysql php-gd php-bcmath php-xml php-mbstring php-mcrypt php-redis
Loaded plugins: aliases, changelog, downloadonly, fastestmirror, kabi, presto, refresh-packagekit, security, tmprepo, verify, versionlock
Loading support for CentOS kernel ABI
Loading mirror speeds from cached hostfile
base   | 3.7 kB     00:00     
extras   | 3.4 kB     00:00     
mysql-connectors-community   | 2.5 kB     00:00     
mysql-tools-community   | 2.5 kB     00:00     
mysql56-community   | 2.5 kB     00:00     
updates   | 3.4 kB     00:00     
Setting up Install Process
No package php-mcrypt available.
No package php-redis available.
Resolving Dependencies
--> Running transaction check
---> Package php.x86_64 0:5.3.3-26.el6 will be updated
---> Package php.x86_64 0:5.3.3-49.el6 will be an update
--> Processing Dependency: php-common(x86-64) = 5.3.3-49.el6 for package: php-5.3.3-49.el6.x86_64
---> Package php-bcmath.x86_64 0:5.3.3-49.el6 will be installed
---> Package php-cli.x86_64 0:5.3.3-26.el6 will be updated
---> Package php-cli.x86_64 0:5.3.3-49.el6 will be an update
---> Package php-fpm.x86_64 0:5.3.3-49.el6 will be installed
---> Package php-gd.x86_64 0:5.3.3-26.el6 will be updated
---> Package php-gd.x86_64 0:5.3.3-49.el6 will be an update
---> Package php-mbstring.x86_64 0:5.3.3-47.el6 will be updated
---> Package php-mbstring.x86_64 0:5.3.3-49.el6 will be an update
---> Package php-mysql.x86_64 0:5.3.3-49.el6 will be installed
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: php-mysql-5.3.3-49.el6.x86_64
--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: php-mysql-5.3.3-49.el6.x86_64
---> Package php-pdo.x86_64 0:5.3.3-26.el6 will be updated
---> Package php-pdo.x86_64 0:5.3.3-49.el6 will be an update
---> Package php-xml.x86_64 0:5.3.3-26.el6 will be updated
---> Package php-xml.x86_64 0:5.3.3-49.el6 will be an update
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:5.6.36-2.el6 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.6.10 for package: mysql-community-libs-compat-5.6.36-2.el6.x86_64
---> Package php-common.x86_64 0:5.3.3-26.el6 will be updated
--> Processing Dependency: php-common(x86-64) = 5.3.3-26.el6 for package: php-ldap-5.3.3-26.el6.x86_64
--> Processing Dependency: php-common(x86-64) = 5.3.3-26.el6 for package: php-xmlrpc-5.3.3-26.el6.x86_64
--> Processing Dependency: php-common(x86-64) = 5.3.3-26.el6 for package: php-soap-5.3.3-26.el6.x86_64
--> Processing Dependency: php-common(x86-64) = 5.3.3-26.el6 for package: php-pgsql-5.3.3-26.el6.x86_64
--> Processing Dependency: php-common(x86-64) = 5.3.3-26.el6 for package: php-odbc-5.3.3-26.el6.x86_64
---> Package php-common.x86_64 0:5.3.3-49.el6 will be an update
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.6.36-2.el6 will be installed
--> Processing Dependency: mysql-community-common(x86-64) >= 5.6.10 for package: mysql-community-libs-5.6.36-2.el6.x86_64
---> Package php-ldap.x86_64 0:5.3.3-26.el6 will be updated
---> Package php-ldap.x86_64 0:5.3.3-49.el6 will be an update
---> Package php-odbc.x86_64 0:5.3.3-26.el6 will be updated
---> Package php-odbc.x86_64 0:5.3.3-49.el6 will be an update
---> Package php-pgsql.x86_64 0:5.3.3-26.el6 will be updated
---> Package php-pgsql.x86_64 0:5.3.3-49.el6 will be an update
---> Package php-soap.x86_64 0:5.3.3-26.el6 will be updated
---> Package php-soap.x86_64 0:5.3.3-49.el6 will be an update
---> Package php-xmlrpc.x86_64 0:5.3.3-26.el6 will be updated
---> Package php-xmlrpc.x86_64 0:5.3.3-49.el6 will be an update
--> Running transaction check
---> Package mysql-community-common.x86_64 0:5.6.36-2.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
Package   Arch   Version   Repository   Size
Installing:
php-bcmath   x86_64   5.3.3-49.el6   base   40 k
php-fpm   x86_64   5.3.3-49.el6   base   1.1 M
php-mysql      x86_64   5.3.3-49.el6   base   86 k
Updating:
php        x86_64   5.3.3-49.el6   base   1.1 M
php-cli    x86_64   5.3.3-49.el6   base   2.2 M
php-gd     x86_64   5.3.3-49.el6   base   111 k
php-mbstring    x86_64   5.3.3-49.el6   base   460 k
php-pdo    x86_64   5.3.3-49.el6   base   80 k
php-xml    x86_64   5.3.3-49.el6   base   108 k
Installing for dependencies:
mysql-community-common        x86_64   5.6.36-2.el6   mysql56-community   308 k
mysql-community-libs          x86_64   5.6.36-2.el6   mysql56-community   1.9 M
mysql-community-libs-compat   x86_64   5.6.36-2.el6   mysql56-community   1.6 M
Updating for dependencies:
php-common      x86_64   5.3.3-49.el6   base   530 k
php-ldap   x86_64   5.3.3-49.el6   base   43 k
php-odbc   x86_64   5.3.3-49.el6   base   56 k
php-pgsql      x86_64   5.3.3-49.el6   base   75 k
php-soap   x86_64   5.3.3-49.el6   base   145 k
php-xmlrpc      x86_64   5.3.3-49.el6   base   58 k
Transaction Summary
Install       6 Package(s)
Upgrade      12 Package(s)
Total size: 10 M
Total download size: 1.6 M
Is this ok [y/N]: y
Downloading Packages:
Setting up and reading Presto delta metadata
Processing delta metadata
Package(s) data still to download: 1.6 M
(1/3): php-bcmath-5.3.3-49.el6.x86_64.rpm   |  40 kB     00:00     
(2/3): php-fpm-5.3.3-49.el6.x86_64.rpm   | 1.1 MB     00:14     
(3/3): php-mbstring-5.3.3-49.el6.x86_64.rpm   | 460 kB     00:01     
Total   107 kB/s | 1.6 MB     00:15     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating   : php-common-5.3.3-49.el6.x86_64        1/30 
Updating   : php-pdo-5.3.3-49.el6.x86_64           2/30 
Updating   : php-cli-5.3.3-49.el6.x86_64           3/30 
Installing : mysql-community-common-5.6.36-2.el6.x86_64           4/30 
Installing : mysql-community-libs-5.6.36-2.el6.x86_64             5/30 
Installing : mysql-community-libs-compat-5.6.36-2.el6.x86_64      6/30 
Installing : php-mysql-5.3.3-49.el6.x86_64         7/30 
Updating   : php-5.3.3-49.el6.x86_64               8/30 
Updating   : php-odbc-5.3.3-49.el6.x86_64          9/30 
Updating   : php-pgsql-5.3.3-49.el6.x86_64        10/30 
Installing : php-bcmath-5.3.3-49.el6.x86_64       11/30 
Updating   : php-xmlrpc-5.3.3-49.el6.x86_64       12/30 
Installing : php-fpm-5.3.3-49.el6.x86_64          13/30 
Updating   : php-ldap-5.3.3-49.el6.x86_64         14/30 
Updating   : php-xml-5.3.3-49.el6.x86_64          15/30 
Updating   : php-gd-5.3.3-49.el6.x86_64           16/30 
Updating   : php-soap-5.3.3-49.el6.x86_64         17/30 
Updating   : php-mbstring-5.3.3-49.el6.x86_64     18/30 
Cleanup    : php-pgsql-5.3.3-26.el6.x86_64        19/30 
Cleanup    : php-odbc-5.3.3-26.el6.x86_64         20/30 
Cleanup    : php-5.3.3-26.el6.x86_64              21/30 
Cleanup    : php-cli-5.3.3-26.el6.x86_64          22/30 
Cleanup    : php-pdo-5.3.3-26.el6.x86_64          23/30 
Cleanup    : php-soap-5.3.3-26.el6.x86_64         24/30 
Cleanup    : php-gd-5.3.3-26.el6.x86_64           25/30 
Cleanup    : php-xml-5.3.3-26.el6.x86_64          26/30 
Cleanup    : php-ldap-5.3.3-26.el6.x86_64         27/30 
Cleanup    : php-xmlrpc-5.3.3-26.el6.x86_64       28/30 
Cleanup    : php-common-5.3.3-26.el6.x86_64       29/30 
Cleanup    : php-mbstring-5.3.3-47.el6.x86_64     30/30 
Verifying  : php-bcmath-5.3.3-49.el6.x86_64        1/30 
Verifying  : mysql-community-common-5.6.36-2.el6.x86_64           2/30 
Verifying  : php-cli-5.3.3-49.el6.x86_64           3/30 
Verifying  : php-5.3.3-49.el6.x86_64               4/30 
Verifying  : php-common-5.3.3-49.el6.x86_64        5/30 
Verifying  : php-pdo-5.3.3-49.el6.x86_64           6/30 
Verifying  : php-xmlrpc-5.3.3-49.el6.x86_64        7/30 
Verifying  : php-fpm-5.3.3-49.el6.x86_64           8/30 
Verifying  : php-ldap-5.3.3-49.el6.x86_64          9/30 
Verifying  : php-xml-5.3.3-49.el6.x86_64          10/30 
Verifying  : php-odbc-5.3.3-49.el6.x86_64         11/30 
Verifying  : php-mysql-5.3.3-49.el6.x86_64        12/30 
Verifying  : mysql-community-libs-5.6.36-2.el6.x86_64            13/30 
Verifying  : php-gd-5.3.3-49.el6.x86_64           14/30 
Verifying  : mysql-community-libs-compat-5.6.36-2.el6.x86_64         15/30 
Verifying  : php-soap-5.3.3-49.el6.x86_64         16/30 
Verifying  : php-pgsql-5.3.3-49.el6.x86_64        17/30 
Verifying  : php-mbstring-5.3.3-49.el6.x86_64     18/30 
Verifying  : php-ldap-5.3.3-26.el6.x86_64         19/30 
Verifying  : php-pdo-5.3.3-26.el6.x86_64          20/30 
Verifying  : php-cli-5.3.3-26.el6.x86_64          21/30 
Verifying  : php-5.3.3-26.el6.x86_64              22/30 
Verifying  : php-common-5.3.3-26.el6.x86_64       23/30 
Verifying  : php-xml-5.3.3-26.el6.x86_64          24/30 
Verifying  : php-xmlrpc-5.3.3-26.el6.x86_64       25/30 
Verifying  : php-odbc-5.3.3-26.el6.x86_64         26/30 
Verifying  : php-pgsql-5.3.3-26.el6.x86_64        27/30 
Verifying  : php-gd-5.3.3-26.el6.x86_64           28/30 
Verifying  : php-soap-5.3.3-26.el6.x86_64         29/30 
Verifying  : php-mbstring-5.3.3-47.el6.x86_64     30/30 
Installed:
php-bcmath.x86_64 0:5.3.3-49.el6   php-fpm.x86_64 0:5.3.3-49.el6   php-mysql.x86_64 0:5.3.3-49.el6
Dependency Installed:
mysql-community-common.x86_64 0:5.6.36-2.el6 mysql-community-libs.x86_64 0:5.6.36-2.el6 mysql-community-libs-compat.x86_64 0:5.6.36-2.el6
Updated:
php.x86_64 0:5.3.3-49.el6         php-cli.x86_64 0:5.3.3-49.el6     php-gd.x86_64 0:5.3.3-49.el6     php-mbstring.x86_64 0:5.3.3-49.el6    
php-pdo.x86_64 0:5.3.3-49.el6     php-xml.x86_64 0:5.3.3-49.el6    
Dependency Updated:
php-common.x86_64 0:5.3.3-49.el6   php-ldap.x86_64 0:5.3.3-49.el6     php-odbc.x86_64 0:5.3.3-49.el6   php-pgsql.x86_64 0:5.3.3-49.el6  
php-soap.x86_64 0:5.3.3-49.el6     php-xmlrpc.x86_64 0:5.3.3-49.el6  
Complete!
 
本文永久更新地址:http://www.linuxdiyf.com/linux/32162.html