6.Python环境
6.1 升级Python
- 安装gcc
yum install gcc* openssl openssl-devel ncurses-devel.x86_64 bzip2-devel sqlite-devel python-devel zlib
- 下载python
wget http://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz
- 安装python
cd Python-2.7.13 ./configure --prefix=/usr/local make && make install
- 替换原有的python
mv /usr/bin/python /usr/bin/python2.7.5 ln -s /usr/local/bin/python2.7 /usr/bin/python
- 修改yum中的python路径
将#!/usr/bin/python 修改为 #!/usr/bin/python2.7.5
- 测试
[root@ecs-69d8-1 opt]# python Python 2.7.13 (default, Jun 30 2017, 12:08:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
6.2 安装pip
- 下载setuptools
wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gz
- 安装setuptools
tar -xvf setuptools-1.4.2.tar.gz cd setuptools-1.4.2 python setup.py install
- 下载安装pip
wget https://bootstrap.pypa.io/get-pip.py python get-pip.py
- 替换pip的源
mkdir ~/.pip cat > ~/.pip/pip.conf << EOF [global] trusted-host=mirrors.aliyun.com index-url=http://mirrors.aliyun.com/pypi/simple/ EOF
6.3 安装ansible
- 安装依赖包
yum -y install python-devel openssl-devel gcc python-setuptools epel-release yum install libffi-devel -y
- 安装ansible
pip install ansible
- 测试
[root@ecs-69d8-1 opt]# ansible --version ansible 2.3.1.0 config file = configured module search path = Default w/o overrides python version = 2.7.13 (default, Jun 30 2017, 12:08:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] // nslookup yum install bind-utils