本文所有实验均在CentOS6.8环境下验证成功
[root@localhost ~]# yum install vim
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os&infra=stock error was
14: PYCURL ERROR 6 - "Couldn't resolve host 'mirrorlist.centos.org'"
Error: Cannot find a valid baseurl for repo: base
[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os&infra=stock error was
14: PYCURL ERROR 6 - "Couldn't resolve host 'mirrorlist.centos.org'"
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=extras&infra=stock error was
14: PYCURL ERROR 6 - "Couldn't resolve host 'mirrorlist.centos.org'"
1. 进入库配置文件修改baseurl为有效URL(vi /etc/yum.repo.d/xxx.repo)
2. 进入/etc/hosts写入有效DNS服务器,如电信nameserver 114.114.114.114.
[root@www ~]# yum install mysql-server
bash: /usr/bin/yum: /usr/bin/python2.4: bad interpreter: No such file or directory
进入vi /usr/bin/yum修改编译器(第一行)为#!/usr/bin/python2.6
[root@localhost ~]# mount -a
mount: no medium found on /dev/sr0
[root@localhost ~]# mount -t iso9660 /dev/sr0 /media/cdrom
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Vault.repo
[root@localhost yum.repos.d]# rm -rf /etc/yum.repos.d/*
源代码就是经过编译器编译之后形成的中间代码或者及其语言代码;
源代码 (编译器) 链接 目标代码
源码包就是源代码 的可见软件包,基于Linux和BSD系统的软件最常见;
源代码就相当于说明书,一个软件如果有源码,我们就可以知道它是怎么开发出来的,一般来说它的用处有2点:
1. 根据用户需要修改软件;
2. 二次开发;
[root@www ~]#yum install gcc automake pcre-devel openssl-devel zlib-devel
gcc:C编译工具;
automake:自动编译工具;
pcre-devel:正则表达式的支持,必装;
openssl-devel:支持ssl加密
zlib-devel: zlib库对响应的数据压缩;
-devel一般表示 表示源码包
[root@www ~]#wget http://nginx.org/download/nginx-1.13.5.tar.gz
[root@www ~]#tar -xf FILE
绝大多数来自“源头”的源代码都是封装成所谓的tarball格式,其扩展名是.tar.gz 或 .tgz
configure是用户个性配置的工具, –表示要配置的选项,后面所跟参数可以指定某些配置文件所在路径,如:–prefix安装路径、日志路径等;也可以启动或者禁用某些模块,如http、ssl等;
./configure –help可以查看到选项;
[root@www nginx-1.12.2]#./configure --prefix=/usr/local/nginx --with-ssl-module --with-pcre --with-zlib
[root@www nginx-1.12.2]#vim Makefile
1
2 default: build
3
4 clean:
5 rm -rf Makefile objs
6
7 build:
8 $(MAKE) -f objs/Makefile
9
10 install:
11 $(MAKE) -f objs/Makefile install
12
13 modules:
14 $(MAKE) -f objs/Makefile modules
15
16 upgrade:
17 /usr/local/nginx/sbin/nginx -t
18
19 kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
20 sleep 1
21 test -f /usr/local/nginx/logs/nginx.pid.oldbin
22
23 kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`
"Makefile" 23L, 376C 23,1-8 All
由上可知,生成一个make编译时需要用到Makefile,来定义软件功能开关,检查源码依赖的库是否齐全,说明安装顺序等。我们可以通过vim obis查看源代码
注意: 这条命令表示运行目录nginx-1.12.2下的一个脚本文件,因此需要进入该目录运行,且运行前需要保证有x权限 ,否则将出现以下错误提示
-bash: ./configure: No such file or directory
[root@www nginx-1.12.2]# make
[root@www nginx-1.12.2]# make install
[root@www nginx-1.12.2]# vim ~/.bashrc
export PATH=$PATH:/usr/local/nginx/sbin #环境变量通过冒号:连接;
[root@www nginx-1.12.2]# source ~/.bashrc #使环境变量生效
[root@www nginx-1.12.2]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/nginx/sbin
#echo查看PATH中出现/usr/local/nginx/sbin即可;
执行
关闭
nginx -s stop
重启
nginx -s reload
注意:必须要开启了才能重启,否则将出现以下报错
[root@www ~]# nginx -s reload
nginx: [error] open() “/usr/local/nginx/logs/nginx.pid” failed (2: No such file or directory)
查看/usr/local/nginx目录
[root@www nginx]# ls
conf html logs sbin
源码编译后的软件放在conf,即主配置文件为/usr/local/nginx/conf/nginx.conf;
yum install gcc automake pcre-devel openssl-devel zlib-devel
wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz
tar xf Python-3.5.1
./configure --prefix=/usr/local/python #定义python的编译器的安装路径,即是用C语言写的源代码;
make
make install
vim ~/.bashrc
//export PATH=$PATH:/usr/loacl/python/bin #将python3.5.1执行路径导入环境变量
mv /usr/bin/python /usr/bin/python2.6
ln -s /usr/local/python/bin/python3.5 /usr/bin/python#将系统默认的python版本改为3.5.1
python -V #查看python版本显示3.5.1即可
vim /usr/bin/yum
// #!/usr/bin/python2.6 #将编译器改为此即可解决python升级后yum无法使用的问题