centos6.3安裝python2.7, pip2.7, mysql

來源:互聯網
上載者:User

標籤:

參考:

https://github.com/h2oai/h2o-2/wiki/Installing-python-2.7-on-centos-6.3.-Follow-this-sequence-exactly-for-centos-machine-only

http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/

 

背景:

生產環境下使用的是centos  6.3, 系統預設python2.6, 在不改變系統預設的前提下, 想額外的安裝python2.7.

所有步驟基本都複製於參考文章, 此篇僅作為筆記備查.

 

安裝Python2.7

步驟:

1. 配置yum國內源

cd /etc/yum.repos.dmv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backupwget http://mirrors.163.com/.help/CentOS6-Base-163.repomv CentOS6-Base-163.repo CentOS6-Base.repoyum clean allyum makecache

2. 配置python2.7源碼安裝編譯環境

yum groupinstall "Development tools"yum install zlib-develyum install bzip2-develyum install openssl-develyum install ncurses-develyum install sqlite-devel

3. 下載並編譯安裝python2.7

cd /optwget --no-check-certificate https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tar.xztar xf Python-2.7.11.tar.xzcd Python-2.7.11./configure --prefix=/usr/localmake && make altinstall

注意, 是 make altinstall 而不是 make install

安裝完成後, /usr/bin/python 和 /usr/local/bin/python 應該如下

[email protected]:/opt/Python-2.7.11 ] ls -ltr /usr/bin/python*
lrwxrwxrwx 1 root root 6 Nov 16 2002 /usr/bin/python2 -> python-rwxr-xr-x 1 root root 1418 Jul 10 2013 /usr/bin/python2.6-config-rwxr-xr-x 2 root root 4864 Jul 10 2013 /usr/bin/python2.6-rwxr-xr-x 2 root root 4864 Jul 10 2013 /usr/bin/pythonlrwxrwxrwx 1 root root 16 Oct 24 15:39 /usr/bin/python-config -> python2.6-config[email protected]:/opt/Python-2.7.11 ] ls -ltr /usr/local/bin/python*-rwxr-xr-x 1 root root 6214533 Mar 19 22:46 /usr/local/bin/python2.7-rwxr-xr-x 1 root root 1674 Mar 19 22:46 /usr/local/bin/python2.7-config

4. 檢查一下$PATH, /usr/local/bin的位置應該在/usr/bin之前

[email protected] h2o]# echo $PATH/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

5. 建立軟連結, 把 /usr/local/bin/python2.7 連結到 /usr/local/bin/python

ln -s /usr/local/bin/python2.7 /usr/local/bin/python

6. 斷開ssh, 重新ssh到伺服器, python已預設為2.7.11, yum可以正常使用

 

安裝pip, virtualenv

1. 安裝pip 8.1.2

因為所有的環境都在virtualenv中配置, 所以pip沒有修改, 如果預設的pip是2.6版本, 建立軟連結到/usr/local/bin/pip即可

wget https://bootstrap.pypa.io/get-pip.pypython get-pip.py

2. 安裝virtualenv

pip install virtualenv

 

安裝mysql

1. 安裝mysql用戶端和服務端

yum install mysqlyum install mysql-serveryum install mysql-devel

2. 配置mysql預設charset

/etc/my.cnf中加入default-character-set=utf8

3. 啟動mysql服務和設定開機啟動

service mysqld startchkconfig -add mysqldchkconfig mysqld on

4. 建立mysql root使用者

mysqladmin -u root password 123456

 

centos6.3安裝python2.7, pip2.7, mysql

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.