01.Centos6&7环境安装Python3.72

【Python环境】CentOS6/7 升级安装

python2,和python3混合

选python服务器就用单核就够用 1 核 2G的 撑死2核8G的

Xshell下载(Win):

http://dlsw.baidu.com/sw-search-sp/soft/7b/15201/Xshell_5.0.0.37_setup.1459931786.exe

 

 

下载、

安装SSH

yum install openssh-server

启动SSH

service sshd start

设置开机运行

chkconfig sshd on

Linux平台需要安装客户端软件

yum install openssh-clients

卸载软件:yum remove xxx

搜索软件:yum serach xxx

清理缓存:yum clean packages

列出已安装:yum list

软件包信息 : yum info xxx

内存:free –m

硬盘:df –h

负载:w/top

cpu个数 和 核数

 

文件上传

scp

scp [email protected]:/tmp/imooc.txt ./

scp imooc.txt [email protected]:/tmp/

xshell(windows)

sudo yum install lrzsz

 

 

Python环境安装

 

Windows下载地址:https://www.python.org/ftp/python/3.5.0/

Pycharm下载地址:http://www.jetbrains.com/pycharm/

http://idea.lanyus.com/ (授权码地址)

编辑 vim ~/.bashrc

alias pycharm="bash /opt/pytharm/bin/pycharm.sh"

export WORKON_HOME=$HOME/.virtualenvs

source /urs/local/python3.73/bin/virtualenvwrapper.sh

 

Linux CentOS环境安装

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

[Python3.5]

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

yum groupinstall "Development tools" -y

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel -y

CentOS 6.5默认只安装了readline模块而没有安装readline-devel模块,所以只要安装下即可。

1.首先安装readline-devel模块

yum install readline-devel -y

2.然后下载python

wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz

下载tgz包就可以了。其实下面的2个包其一都可以使用 

Python-3.5.1.tgz (这个不是编译过的东西,不能解压之后直接使用) 

Python-3.5.1.tar.xz (这个是pthon的源码)

3.解压文件

tar -zxvf Python-3.5.2.tgz

4.开始安装,使用编译的方法进行安装

在python的目录中有一个README文件,他介绍了如何安装python。 

但是我们要指定这个安装目录

mkdir /usr/python3.5 ./configure --prefix=/usr/python3.5 make make install

说明./configure命令执行完毕之后创建一个文件creating Makefile,供下面的make命令使用 

执行make install之后就会把程序安装到我们指定的目录中去

cd /usr/bin mv python python.bak ln -s /usr/python3.5/bin/python3 /usr/bin/python

ln -s /usr/local/python3.5/bin/python3 /usr/bin/python3

ln -s /usr/local/python3/bin/pip3 /usr/bin/pip

安装pip3 和 virtualenv

pip install virtualenv

ln -s /usr/local/python3/bin/virtualenv /usr/bin/virtualenv

virutalenv -p /usr/bin/python3

 

pip3 使用豆瓣源

https://www.cnblogs.com/clockwork/p/6133720.html

虚拟机Centos如何和主机共享目录

1.mkdir /mnt/cdrom

2.mount /dev/cdrom /mnt/cdrom

3.cp -R /mnt/cdrom /usr/local/src/VBoxAdditions

4.yum install -y gcc gcc-devel gcc-c++ gcc-c++-devel make kernel kernel-devel bzip2

5./usr/local/src/VBoxAdditions/VBoxLinuxAdditions.run install

6.启用共享文件夹:

mkdir /home/www

mount -t vboxsf mooc /home/www

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

[Python3.61]

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

yum groupinstall "Development tools" -y

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel readline-devel -y

wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz

tar -zxvf Python-3.6.1.tgz

cd Python-3.6.1

./configure --prefix=/usr/local/python3.6/ --enable--shared

make && make install

rm -rf /usr/bin/python /usr/bin/pip

ln -s /usr/local/python3.5/bin/python3 /usr/bin/python

cd ../setuptools-30.2.0

python setup.py build

python setup.py install

cd ../pip-9.0.1

python setup.py build

python setup.py install

ln -s /usr/local/python3.5/bin/pip /usr/bin/pip

pip install uwsgi

下载

setuptools-30.2.0.tar.gz (md5)

https://pypi.python.org/pypi/setuptools#code-of-conduct

wget https://pypi.python.org/pypi/setuptools#code-of-conduct

然后

tar xvf setuptools-30.2.0.tar.gz

cd setuptools-20.3.1

python setup.py install

 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

[Python2.7]

 

centos7 默认带python2.7主要用于服务器管理自动化运维

yum -y install epel-release

yum -y install python-pip

pip install --upgrade pip

pip install ipython

yum clean all

 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

[Python3.7]

++++++++++++++++

yum update -y && yum install wget gcc pcre pcre-devel zlib-devel openssl perl openssl-devel -y

cd /opt/

wget https://tar-1259110394.cos.ap-guangzhou.myqcloud.com/openssl-1.0.2r.tar.gz

wget https://www.openssl.org/source/openssl-1.0.2s.tar.gz

tar -zxvf openssl-1.0.2r.tar.gz

cd openssl-1.0.2r

mkdir -p /usr/local/openssl

./config --prefix=/usr/local/openssl

make && make install

mv /usr/bin/openssl /usr/bin/openssl.old

mv /usr/include/openssl/ /usr/include/openssl.old

ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl

ln -s /usr/local/openssl/include/openssl/ /usr/include/openssl

echo "/usr/local/openssl/lib/">>/etc/ld.so.conf

ldconfig

openssl version -a

 

yum groupinstall "Development tools" -y

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel readline-devel -y

wget https://linux-1254084810.cos.ap-chengdu.myqcloud.com/Python-3.7.2.tgz

wget http://mirror.centos.org/centos/7/os/x86_64/Packages/libffi-devel-3.0.13-18.el7.x86_64.rpm

 

cd /opt

yum install libffi-devel -y

wget https://tar-1259110394.cos.ap-guangzhou.myqcloud.com/Python-3.7.3.tar.xz

tar -xvf Python-3.7.3.tar.xz

cd Python-3.7.3/

mkdir -p /usr/local/python3.7.3

vim Modules/Setup.dist

----------------------------------------------------------------------

如果想同时python2版本

./configure --prefix=/usr/local/python3.7.3/ --enable--shared --with-openssl=/usr/local/openssl

ln -s /usr/local/python3.7.3/bin/python3 /usr/bin/python3

ln -s /usr/local/python3.7.3/bin/pip3 /usr/bin/pip3

-----------------------------------------------------------------------

 

SSL=/usr/local/openssl _ssl _ssl.c \ -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ -L$(SSL)/lib -lssl -lcrypto

 

./configure --prefix=/usr/local/python3.7.3/ --with-openssl=/usr/local/openssl

make && make install

rm -rf /usr/bin/python /usr/bin/pip

ln -s /usr/local/python3.7.3/bin/python3 /usr/bin/python

ln -s /usr/local/python3.7.3/bin/pip3 /usr/bin/pip

pip -V

pip install --upgrade pip

pip install setuptools

pip install uwsgi

pip install virtualenv

ln -s /usr/local/python3.7.3/bin/virtualenv /usr/local/bin/virtualenv

mkdir /opt/Py3Project

cd /opt/Py3Project/

virtualenv seodemo1

source seodemo1/bin/activate

需要更改两个文件

vim /usr/bin/yum

vim /usr/libexec/urlgrabber-ext-down

替换为python2.7

sed -i "s/python/python2.7/g" /usr/bin/yum

sed -i "s/python/python2.7/g" /usr/libexec/urlgrabber-ext-down

安装virtualenvwrapper:

 

1,*nix pip install virtualenvwrapper

2 win pip install virtualenvwrapper-win

 

 

pip2 install virtualenvwrapper-wi

创建

mkvirtualenv py3_my_env

指定python版本

mkvirtualenv --python==C:\python27\python.exe py2_my_env

 

退出

deactivate

 

安装:virtualenv;

安装:virtualenvwrapper;

virtualenvwrapper 基本使用

1 创建虚拟环境

mkvirtualenv my_env

那么会在当前用户下创建一个Env的文件夹,然后将这个虚拟环境安装到这个目录下

2 切换到某个虚拟环境

workon my_env

推出当前虚拟环境

deactivate

删除某个虚拟环境

rmvirtualenv my_env

列出所有虚拟环境

lsvirtualenv

 

++++++++++++++++++++++++++++++++++++++++

 

安装flask:

7.5 需求文件

程序中必须包含一个requirements.txt 文件,用于记录所有依赖包及其精确的版本号。如果

要在另一台电脑上重新生成虚拟环境,这个文件的重要性就体现出来了,例如部署程序时

使用的电脑。pip 可以使用如下命令自动生成这个文件:

(venv) $ pip freeze >requirements.txt

安装或升级包后,最好更新这个文件。需求文件的内容示例如下:

72 | 第7 章

Flask==0.10.1

Flask-Bootstrap==3.0.3.1

Flask-Mail==0.9.0

Flask-Migrate==1.1.0

Flask-Moment==0.2.0

Flask-SQLAlchemy==1.0

Flask-Script==0.6.6

Flask-WTF==0.9.4

Jinja2==2.7.1

Mako==0.9.1

MarkupSafe==0.18

SQLAlchemy==0.8.4

WTForms==1.0.5

Werkzeug==0.9.4

alembic==0.6.2

blinker==1.3

itsdangerous==0.23

如果你要创建这个虚拟环境的完全副本,可以创建一个新的虚拟环境,并在其上运行以下

命令:

(venv) $ pip install -r requirements.txt

当你阅读本书时,该示例requirements.txt 文件中的版本号可能已经过期了。如果愿意,你

可以试着使用这些包的最新版。如果遇到问题,你可以随时换回这个需求文件中的版本,

因为这些版本和程序兼容。

 

 

妈蛋气死了

添加链接:

vim

ln -s /usr/local/python3.7.2/bin/virtualenv /usr/local/bin/virtualenv

WORKON_HOME = " 自己定义 不要用网上那个傻逼的地方$HOME/.virtualenvs 瞎弄给我弄糊涂了"

然后我就放opt/home里面了

如果装了tomcat 或者jdk 的/etc/profile文件引用了$HOME 请更换名字不然冲突

 

export WORKON_HOME=/opt/virtualenv # <-- Where all virtualenvs will be stored

export VIRTUALENVWRAPPER_PYTHON=/usr/local/python3.7.2

export PIP_VIRTUALENV_BASE=/usr/local/python3.7.2/bin/

export PIP_RESPECT_VIRTUALENV=true

source /usr/local/python3.7.2/bin/virtualenvwrapper_lazy.sh

export VIRTUALENV_USE_DISTRIBUTE=1 # <-- Always use pip/distribute

sorce ~/.bashrc

 

yum remove mysql-libs -y

yum clean dbcache

wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm

rpm -ivh mysql-community-release-el6-5.noarch.rpm

yum install mysql-community-server -y

service mysqld start

/usr/bin/mysqladmin -u root password 'Aa123.com'

/usr/bin/mysqladmin -u root password 'Nu2.&#HkSr18^%'

 

47.75.251.71:48456

用户名:root

密码:w57h$qFG*[email protected]

mysql密码:Nu2.&#HkSr18^%

创建数据库指定字符集

 

CREATE DATABASE IF NOT EXISTS seokfz DEFAULT CHARSET utf8;

 

netstat -anptu | grep nginx

./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module

--with-http_mp4_module --with-http_flv_module

++++++++++++++++++++++++++++++++++++++++++++++

 

相关推荐

评论

  1. #2

    7pm.pub(2016/10/28 11:41:03)
    不错的网站主题,看着相当舒服

  2. #1

    7pm.pub(2016/10/14 21:02:39)
    博客做得好漂亮哦!