yum更换国内源
yum源默认从国外网站下载,速度相对较慢。可以更换成内容源。
步骤:ls /etc/yum.repos.d ,将CentOS-Base.repo移走或改名。
[root@glinux-01 ~]# ls /etc/yum.repos.dCentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repoCentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
下载CentOS7-Base-163.repo文件,命令:wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
该命令会将文件下载到当前目录下,移动至/etc/yum.repos.d
[root@glinux-01 ~]# ls1.txt anaconda-ks.cfg bad boduo.av CentOS7-Base-163.repo cuowu test.sh zhengque
注意:最好先安装wget包,在移走CentOS-Base.repo。要不没法运行wget命令
也可以用curl -O http://mirrors.163.com/.help/CentOS7-Base-163.repo下载CentOS7-Base-163.repo文件。
yum clean all 清除缓存。
安装扩展源epel
有些源很有用,但是自带源没有,需要安装扩展源
方法:
- yum install -y epel-release安装扩展源
- yum list|grep epel查看扩展源
yum下载rpm包
- yum install -y 包名 --downloadonly //只下载包,不安装。
- ls /var/cache/yum/x86_64/7/ 下载的包保存目录
- yum install -y 包名 --downloadonly --downloaddir=路径 (指定下载的路径)
- yum reinstall -y 包名 --downloadonly --downloaddir=路径 (reinstall重新安装)
下载的包保存目录,从哪个仓库下载的就在哪个文件夹下。
[root@glinux-01 ~]# ls /var/cache/yum/x86_64/7/base extras timedhosts timedhosts.txt updates
源码包安装
示例:Apache源码包安装步骤
- cd /usr/local/src/ 源码包放置地址,约定俗成的,方便寻找
- wget //apache下载地址(地址网上找最新的)
- tar zxvf httpd-2.2.32.tar.gz
- cd httpd-2.2.32
- ./configure --prefix=/usr/local/apache2(指定路径为/usr/local/apache2)
- make
- make install
- 卸载就是删除安装的文件
下载后解压 tar -zxvf httpd-2.4.29.tar.gz
[root@glinux-01 src]# lshttpd-2.4.29 httpd-2.4.29.tar.gz
[root@glinux-01 httpd-2.4.29]# lsABOUT_APACHE BuildBin.dsp emacs-style LAYOUT NOTICE srclibacinclude.m4 buildconf httpd.dep libhttpd.dep NWGNUmakefile supportApache-apr2.dsw CHANGES httpd.dsp libhttpd.dsp os testApache.dsw CMakeLists.txt httpd.mak libhttpd.mak README VERSIONINGapache_probes.d config.layout httpd.spec LICENSE README.cmakeap.d configure include Makefile.in README.platformsbuild configure.in INSTALL Makefile.win ROADMAPBuildAll.dsp docs InstallBin.dsp modules server
目录中文件README,INSTALL一般是安装信息
[root@glinux-01 httpd-2.4.29]# cat INSTALL APACHE INSTALLATION OVERVIEW Quick Start - Unix ------------------ For complete installation documentation, see [ht]docs/manual/install.html or http://httpd.apache.org/docs/2.4/install.html $ ./configure --prefix=PREFIX //指定安装路径 $ make //译成电脑识别的二进制文件 $ make install //用于创建相关软件的存放目录和配置文件 $ PREFIX/bin/apachectl start //启动方法
./configure --prefix=/usr/local/apache2 (还有很多选项,可以./configure --help查看)指定路径
[root@glinux-01 httpd-2.4.29]# ./configure --prefix=/usr/local/apache2checking for chosen layout... Apachechecking for working mkdir -p... yeschecking for grep that handles long lines and -e... /usr/bin/grepchecking for egrep... /usr/bin/grep -Echecking build system type... x86_64-pc-linux-gnuchecking host system type... x86_64-pc-linux-gnuchecking target system type... x86_64-pc-linux-gnuconfigure: configure: Configuring Apache Portable Runtime library...configure: checking for APR... noconfigure: error: APR not found. Please read the documentation.[root@glinux-01 httpd-2.4.29]# echo $?1
居然报错。。。configure: error: APR not found. Please read the documentation.
网上搜索的解决方案:https://www.cnblogs.com/visec479/p/5160297.html
echo $? 可以检测上一条命令执行正确(0)还是错误(1)
下载apr软件包:wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz
- [root test]# tar -zxf apr-1.4.5.tar.gz 解压
- [root test]# cd apr-1.4.5
- [root apr-1.4.5]# ./configure --prefix=/usr/local/apr 安装
又报错!
[root@glinux-01 apr-1.4.5]# ./configure --prefix=/usr/local/aprchecking build system type... x86_64-unknown-linux-gnuchecking host system type... x86_64-unknown-linux-gnuchecking target system type... x86_64-unknown-linux-gnuConfiguring APR libraryPlatform: x86_64-unknown-linux-gnuchecking for working mkdir -p... yesAPR Version: 1.4.5checking for chosen layout... aprchecking for gcc... nochecking for cc... nochecking for cl.exe... noconfigure: error: in `/usr/local/src/apr-1.4.5':configure: error: no acceptable C compiler found in $PATHSee `config.log' for more details.
安装gcc yum install gcc
重新安装 :[root apr-1.4.5]# ./configure --prefix=/usr/local/apr 安装
重新安装 ./configure --prefix=/usr/local/apache2 成功
make
make install