centos6.4 Install Python Web development + production environment

Source: Internet
Author: User
Tags memcached php download install django install perl iptables pip install django virtual environment virtualenv

1. Overview

centos6.4 installs Python, Setuptool, Pip, Virtualenv, MySQL, Django, libevent, Memcache, Nginx, Git, beyond compare, JDK, eclipse , Pydev


2. Reference command

centos6.4 with Python2.6, anyway 2.x difference is not big, also will be used.

1. Install Setuptool

wget--no-check-certificate  https://bootstrap.pypa.io/ez_setup.py
python ez_setup.py

Of course, can also go to download Setuptool source code, after decompression compiled installation

ez_setup.py This file has been updated, if the command line after the installation of the EASY_INSTALL-H report a mess error, nothing else, version does not match. The internet is always the latest version, while the local Python version is low, not 3. X.

Solution: Vim ez_setup.py

Default_version = "5.4" is found, PYTHON26/27 is changed to Default_version = "3.6" to rerun the Python ez_setup.py.

Python27 or below with 5.4 setuptools infinite bitter force, said many are tears

2. Install Pip

wget--no-check-certificate http://pypi.python.org/packages/source/p/pip/pip-1.0.2.tar.gz
tar zxf pip-1.0.2.tar.gz
cd pip-1.0.2
python setup.py install

with Easy_install, after the installation of the input pip-h, if the error is not found, this can not find that, the same version of the problem. PYTHON26/27 all use 1.0.2 bar, don't go to try the pit.

centos6.4 upgrades to Python27, pip>=1.5.6 is likely to Importerror:no module named _ctypes (why is that possible? Because we all except a Yum God encountered this error more than 10 minutes to change Yum recompile Python27 done, the rest of the encounter this mistake, for a lower version. I can't compare with Yum, so be careful to assert that, with probable


3. Install virtualenv

Pip Install Virtualenv

You can specify the version 1.11.6 pip install virtualenv==1.11.6 (there is no version problem found virtualenv, but no pits are specified)

Pip install virtualenv==1.8.2 seems more suitable for PYTHON26/27


4. Create a virtual environment and activate

Virtualenv pydj14--no-setuptools
Source Pydj14/bin/activate

parameter--no-setuptools is necessary because virtualenv with Setuptools and Pip, which we have installed on our own, are not guaranteed to be consistent with the two versions of Virtualenv. If there is an inconsistency, the virtualenv comes with a cover that is installed on top of us, and it may not be the appropriate Python version. So add this parameter, do not bring it from, directly using the above we successfully installed, save some time to test version of the pit.

With the--no-setuptools parameter, there is no Pip Setuptools in the new virtual environment, the virtual environment is activated, and the Setuptools Pip is installed again, at which point these two things are installed into the virtual environment.

For example, virtualenv1.11.6 setuptools3.6 just with the above consistent, with pip1.5.6 (above has said centos6.4 Python27 will complain), so do not add--no-setuptools parameters, will be an error

Installing Setuptools, Pip ...

..... A lot of stack information ....

Importerror:no module named _ctypes

do not want to install in the virtual environment again, want to use the virtual environment, it is also the line specified version pip install virtualenv==1.8.2 This version 26 27 is compatible with great


5. Install MySQL

wget Http://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-5.5.17-1.linux2.6.x86_64.tar
TAR-XF Mysql-5.5.17-1.linux2.6.x86_64.tar
Yum Erase mysql-libs
RPM-IVH mysql-server-5.5.17-1.linux2.6.x86_64.rpm
RPM-IVH mysql-devel-5.5.17-1.linux2.6.x86_64.rpm  (Install devel will have mysql_config file, otherwise Mysql-python error can not find this file)
RPM-IVH mysql-client-5.5.17-1.linux2.6.x86_64.rpm Optional
chown-r mysql:mysql/var/lib/mysql
/etc/init.d/mysql Start          start
mysqladmin-uroot password ' PPP '
/usr/bin/mysqladmin-u root-p shutdown      

power-on Startup Optional:
/sbin/chkconfig--add MySQL
Database Directory/var/lib/mysql/
Configuration file/usr/share/mysql
Related Commands/usr/bin (mysqladmin mysqldump, etc.)

Start Script/etc/rc.d/init.d/


5.** If you don't want to install MySQL, just Mysql_python

Install Rpm-build gcc-c++ 

yum install MySQL mysql-devel 

yum install python_devel wget http://download yum-y

sourceforge.net/sourceforge/mysql-python/mysql-python-1.2.3.tar.gz 
Editor Site.cfg, uncomment the Mysql_config line and replace it with the following: 

mysql_config =/usr/lib64/mysql/mysql_config 

python setup.py build 

python setup.py install 






6. Install the Django development environment

Pip install South
pip install--download Mysql-python  after decompression modify setup_posix.py change mysql_config path to/usr/bin/mysql_ The config
parameter may be slightly changed to download only and not install, and it is possible that the parameter is--no-install and depends on the PIP version.  Pip Install-h take a look on the line, only the bottom is not installed, change the file, and then install the
pip install python-memcached
pip install django==1.4.5
pip Install Uwsgi
7. Install Libevent
Install yum gcc
yum install gcc-c++ libstdc++-devel yum install zlib-devel wget http://monkey.org/~provos/
libevent-1.4.14b-stable.tar.gz
tar zxvf libevent-1.4.14b-stable.tar.gz  
cd libevent-1.4.14b-stable  
./ Configure--prefix=/usr/local/libevent/make  
&& make install 
below two select one 
ln-s/usr/local/libevent/lib /libevent-1.4.so.2/lib/libevent-1.4.so.2        32-bit system
ln-s/usr/local/libevent/lib/libevent-1.4.so.2/lib64/ Libevent-1.4.so.2      64-bit system
8. Install Memcache
wget http://www.danga.com/memcached/dist/memcached-1.2.5.tar.gz
tar zxvf memcached-1.2.5.tar.gz
CD memcached-1.2.5
 ./configure--prefix=/usr/local/memcached/--with-libevent=/usr/local/libevent/  
make && make install
/usr/local/memcached/bin/memcached-d-M 64-u root-l 127.0.0.1-p 11211-c 128-p/TMP/MEMC Ached.pid
9. Install Nginx
wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
RPM-IVH nginx-release-centos-6-0.el6.ngx.noarch.rpm
Yum Install nginx
Modify firewall
vi/etc/sysconfig/iptables
-A Input-m State--state new-m tcp-p TCP--dport 80-j ACCEPT
service iptables restart
Configuration directory:/etc/nginx/
PID Directory:/var/run/nginx.pid
Error log:/var/log/nginx/error.log
Access log:/var/log/nginx/access.log
Default Site Directory:/usr/share/nginx/html
Start Nginx:nginx
Restart Nginx:killall-hup Nginx
Test Nginx configuration: nginx-t

10. Install git

Yum-y zlib-devel openssl-devel Install perl cpio expat-devel gettext-devel yum install autoconf yum install
git
11. Install Beyondcompare
http://www.scootersoftware.com/download.php Download RPM Package Installation

12.git configuration BC3

[Color]
        UI = True
[core]
        editor = vim

[diff]
        tool = BC3
[difftool "BC3"]
        cmd = bcompare $LOCAL $REMOTE 
  [difftool]
        prompt = False
13.Python web Development Environment
Download jdk1.7rpm package, rpm command installation

Download Eclipse decompression, mv to/usr/local directory, configure the desktop startup icon as follows code


Note the JDK version and Eclipse version, eclipse4.3 and jdk1.6 (recommended jdk1.6 install 3.3--3.7 Eclipse), eclipse4.4 must be jdk1.7 and above.

Note that the JDK is consistent with the eclipse bits, preferably in line with the operating system, with 64-bit, 32-bit. From the above installation command can be seen, this article is centos6.4 64-bit


Desktop Add Eclipse startup icon (centos6.4 added after the desktop does not immediately appear this icon, only in desktop options, manually click on the upper left corner, apply, find Eclipse, right, add to the desktop)

Vim/usr/share/applications/eclipse.desktop

Enter the following
[desktop Entry]
encoding=utf-8
name=eclipse
comment=eclipse IDE
Exec=/usr/local/eclipse/eclipse
icon=/usr/local/eclipse/icon.xpm
terminal=false
Type=Application
Categories=gnome; application;development;
Startupnotify=true

Install Pydev

Download the source package to the Eclipse Dropins directory, or install online (the Eclipse online installation is likely to fail under 3.7), omit

Just pay attention to pydev2. X jdk1.6 or above, but 1.8 has a little problem. Pydev3 must be jdk1.7 above.


Specific MySQL configuration, nginx configuration, memcache configuration on their respective Baidu Google it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.