CentOS6.4安装Python web开发+生产环境

前端之家收集整理的这篇文章主要介绍了CentOS6.4安装Python web开发+生产环境前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

CentOS6.4安装Python web开发+生产环境

1.概述

centos6.4安装Python,setuptool,pip,virtualenv,MysqL,django,libevent,memcache,Nginx,git,beyond compare,jdk,eclipse,pydev

2.参考命令

centos6.4自带Python2.6,反正2.x区别不大,也就将就着用了.

1.安装setuptool

[plain]view plaincopy

在CODE上查看<a href=代码片" src="http://img.jb51.cc/vcimg/static/loading.png" src="https://code.csdn.net/assets/CODE_ico.png">

派生到我的<a href=代码片" src="http://img.jb51.cc/vcimg/static/loading.png" src="https://code.csdn.net/assets/ico_fork.svg">

  1. wget--no-check-certificatehttps://bootstrap.pypa.io/ez_setup.py

  2. pythonez_setup.py

当然也可以去下载setuptool源码,解压后编译安装

2.安装pip

[plain]view plaincopy

在CODE上查看<a href=代码片" src="http://img.jb51.cc/vcimg/static/loading.png" src="https://code.csdn.net/assets/CODE_ico.png">

派生到我的<a href=代码片" src="http://img.jb51.cc/vcimg/static/loading.png" src="https://code.csdn.net/assets/ico_fork.svg">

  1. wget--no-check-certificatehttp://pypi.python.org/packages/source/p/pip/pip-1.0.2.tar.gz

  2. tarzxfpip-1.0.2.tar.gz

  3. cdpip-1.0.2

  4. pythonsetup.pyinstall

3.安装virtualenv

[plain]view plaincopy

在CODE上查看<a href=代码片" src="http://img.jb51.cc/vcimg/static/loading.png" src="https://code.csdn.net/assets/CODE_ico.png">

派生到我的<a href=代码片" src="http://img.jb51.cc/vcimg/static/loading.png" src="https://code.csdn.net/assets/ico_fork.svg">

  1. pipinstallvirtualenv

4.创建一个虚拟环境,并激活

  • virtualenvpydj14

  • sourcepydj14/bin/activate

  • 5.安装MysqL

  • wgethttp://dev.MysqL.com/get/Downloads/MysqL-5.5/MysqL-5.5.17-1.linux2.6.x86_64.tar

  • tar-xfMysqL-5.5.17-1.linux2.6.x86_64.tar

  • yumeraseMysqL-libs

  • rpm-ivhMysqL-server-5.5.17-1.linux2.6.x86_64.rpm

  • rpm-ivhMysqL-devel-5.5.17-1.linux2.6.x86_64.rpm(安装devel才会有MysqL_config文件,否则MysqL-python报错找不到此文件)

  • rpm-ivhMysqL-client-5.5.17-1.linux2.6.x86_64.rpm可选

  • chown-RMysqL:MysqL/var/lib/MysqL

  • /etc/init.d/MysqLstart启动

  • MysqLadmin-urootpassword'ppp'

  • /usr/bin/MysqLadmin-uroot-pshutdown关闭


  • 开机启动可选:

  • /sbin/chkconfig--addMysqL

  • 数据库目录 /var/lib/MysqL/
    配置文件 /usr/share/MysqL
    相关命令 /usr/bin (MysqLadmin MysqLdump等命令)
    启动脚本 /etc/rc.d/init.d/

    6.安装django开发环境

    [plain]view plaincopy

    在CODE上查看<a href=代码片" src="http://img.jb51.cc/vcimg/static/loading.png" src="https://code.csdn.net/assets/CODE_ico.png">

    派生到我的<a href=代码片" src="http://img.jb51.cc/vcimg/static/loading.png" src="https://code.csdn.net/assets/ico_fork.svg">

    1. pipinstallsouth

    2. pipinstall--downloadMysqL-python解压后修改setup_posix.py将MysqL_config路径改为/usr/bin/MysqL_config

    3. pipinstallpython-memcached

    4. pipinstalldjango==1.4.5

    5. pipinstalluwsgi

    7.安装libevent

  • yuminstallgcc

  • yuminstallgcc-c++libstdc++-devel

  • yuminstallzlib-devel

  • wgethttp://monkey.org/~provos/libevent-1.4.14b-stable.tar.gz

  • tarzxvflibevent-1.4.14b-stable.tar.gz

  • cdlibevent-1.4.14b-stable

  • ./configure--prefix=/usr/local/libevent/

  • make&&makeinstall

  • 下面二选一

  • ln-s/usr/local/libevent/lib/libevent-1.4.so.2/lib/libevent-1.4.so.232位系统

  • ln-s/usr/local/libevent/lib/libevent-1.4.so.2/lib64/libevent-1.4.so.264位系统

  • 8.安装memcache

  • wgethttp://www.danga.com/memcached/dist/memcached-1.2.5.tar.gz

  • tarzxvfmemcached-1.2.5.tar.gz

  • cdmemcached-1.2.5

  • ./configure--prefix=/usr/local/memcached/--with-libevent=/usr/local/libevent/

  • make&&makeinstall

  • /usr/local/memcached/bin/memcached-d-m64-uroot-l127.0.0.1-p11211-c128-P/tmp/memcached.pid

  • 9.安装Nginx

  • wgethttp://Nginx.org/packages/centos/6/noarch/RPMS/Nginx-release-centos-6-0.el6.ngx.noarch.rpm

  • rpm-ivhNginx-release-centos-6-0.el6.ngx.noarch.rpm

  • yuminstallNginx

  • 修改防火墙

  • vi/etc/sysconfig/iptables

  • -AINPUT-mstate--stateNEW-mtcp-ptcp--dport80-jACCEPT

  • serviceiptablesrestart

  • 配置目录:/etc/Nginx/
    PID目录:/var/run/Nginx.pid
    错误日志:/var/log/Nginx/error.log
    访问日志:/var/log/Nginx/access.log
    默认站点目录:/usr/share/Nginx/html
    启动NginxNginx
    重启Nginx:killall -HUP Nginx
    测试Nginx配置:Nginx -t

    10.安装git

    [plain]view plaincopy

    在CODE上查看<a href=代码片" src="http://img.jb51.cc/vcimg/static/loading.png" src="https://code.csdn.net/assets/CODE_ico.png">

    派生到我的<a href=代码片" src="http://img.jb51.cc/vcimg/static/loading.png" src="https://code.csdn.net/assets/ico_fork.svg">

    1. yum-yinstallzlib-developenssl-develperlcpioexpat-develgettext-devel

    2. yuminstallautoconf

    3. yuminstallgit

    11.安装BeyondCompare
    http://www.scootersoftware.com/download.PHP下载rpm包安装

    12.git 配置bc3

    [plain]view plaincopy

    在CODE上查看<a href=代码片" src="http://img.jb51.cc/vcimg/static/loading.png" src="https://code.csdn.net/assets/CODE_ico.png">

    派生到我的<a href=代码片" src="http://img.jb51.cc/vcimg/static/loading.png" src="https://code.csdn.net/assets/ico_fork.svg">

    1. [color]

    2. ui=true

    3. [core]

    4. editor=vim

    5. [diff]

    6. tool=bc3

    7. [difftool"bc3"]

    8. cmd=bcompare$LOCAL$REMOTE

    9. [difftool]

    10. prompt=false

    13.Python web开发环境
    下载jdk1.7rpm包, rpm命令安装
    下载eclipse 解压,mv至/usr/local目录下,配置桌面启动图标如下代码

    注意jdk版本与eclipse版本, eclipse4.3及以前可以使用jdk1.6(推荐jdk1.6安装3.3--3.7的eclipse),eclipse4.4起必须jdk1.7及以上.

    注意jdk与eclipse位数一致,最好与操作系统一致,都用64位,32位。从上面安装命令可以看出,本文章是centos6.4 64位

    桌面添加eclipse启动图标(centos6.4添加后桌面不会立即出现该图标,仅仅放在桌面备选项中,手动点击左上角,应用,找到eclipse,右键,添加至桌面)

  • vim/usr/share/applications/eclipse.desktop

  • 输入如下

  • [DesktopEntry]

  • Encoding=UTF-8

  • Name=Eclipse

  • Comment=EclipseIDE

  • Exec=/usr/local/eclipse/eclipse

  • Icon=/usr/local/eclipse/icon.xpm

  • Terminal=false

  • Type=Application

  • Categories=GNOME;Application;Development;

  • StartupNotify=true

  • 安装pydev

    下载源码包解压至eclipse dropins目录,或者在线安装(3.7以下版本eclipse在线安装很可能失败),略去

    仅需要注意pydev2.X jdk1.6或以上,但1.8有点小问题。pydev3必须jdk1.7以上。

    具体MysqL配置,Nginx配置, memcache配置就各自百度谷歌吧.

    原文链接:https://www.f2er.com/centos/376802.html

    猜你在找的CentOS相关文章