yum更换国内源
yum源默认从国外网站下载,速度相对较慢。可以更换成内容源。
步骤:ls /etc/yum.repos.d ,将CentOS-Base.repo移走或改名。
[root@glinux-01 ~]# ls /etc/yum.repos.d
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
CentOS-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 ~]# ls
1.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 http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.32.tar.gz //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]# ls
httpd-2.4.29 httpd-2.4.29.tar.gz
[root@glinux-01 httpd-2.4.29]# ls
ABOUT_APACHE BuildBin.dsp emacs-style LAYOUT NOTICE srclib
acinclude.m4 buildconf httpd.dep libhttpd.dep NWGNUmakefile support
Apache-apr2.dsw CHANGES httpd.dsp libhttpd.dsp os test
Apache.dsw CMakeLists.txt httpd.mak libhttpd.mak README VERSIONING
apache_probes.d config.layout httpd.spec LICENSE README.cmake
ap.d configure include Makefile.in README.platforms
build configure.in INSTALL Makefile.win ROADMAP
BuildAll.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/apache2
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no
configure: 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@xt test]# tar -zxf apr-1.4.5.tar.gz 解压
- [root@xt test]# cd apr-1.4.5
- [root@xt apr-1.4.5]# ./configure --prefix=/usr/local/apr 安装
又报错!
[root@glinux-01 apr-1.4.5]# ./configure --prefix=/usr/local/apr
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
Configuring APR library
Platform: x86_64-unknown-linux-gnu
checking for working mkdir -p... yes
APR Version: 1.4.5
checking for chosen layout... apr
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/usr/local/src/apr-1.4.5':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
安装gcc yum install gcc
重新安装 :[root@xt apr-1.4.5]# ./configure --prefix=/usr/local/apr 安装
重新安装 ./configure --prefix=/usr/local/apache2 成功
make
make install