Python and scrapy deployment in centos environment

1 operating system##

Centos 6.5 64bit or above

2 Software Environment##

Tips: (1) what software to use; (2) operating environment (3) development kit.

  1. Python:Python-2.7.6.tgz
  2. Scrapy:Scrapy-1.0.3.tar.gz
  3. Selenium:selenium (2.48.0)
  4. Phantomjs:phantomjs-1.9.8-linux-x86_64.tar.bz2
  5. MySQL-python:MySQL-python-1.2.5.zip
  6. MySQL:MySQL-5.6.27-1.linux_glibc2.5.x86_64.rpm-bundle.tar

3 installation steps##

1. Install dependent libraries###

yum install zlib-devel bzip2-devel ncurses-devel sqlite-devel readline-devel tk-devel mysql-devel gcc libxslt-devel libxml2-devel libffi-devel  openssl-devel python-devel

# yum install zlib-devel
# yum install bzip2-devel
# yum install openssl-devel
# yum install ncurses-devel
# yum install sqlite-devel
# yum install readline-devel
# yum install tk-devel
# yum install mysql-devel
# yum install gcc
# yum install make(centos may have its own, no need to install)

Scrapy must be installed:

# yum install libxslt-devel 
# yum install libxml2-devel 
# yum install libffi-devel

2. Upgrade Python

(Download address: https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz)
Centos6.5 system comes with python2.6.6 and needs to be upgraded to Python2.7
Install the library file: yum install zlib-devel openssl-devel sqlite-devel
Download: wget https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz
Unzip: tar zxvf Python-2.7.6.tgz
installation:

cd Python-2.7.6./configure --prefix=/usr/local/python
make
make install

Create a soft link: ln -sf /usr/local/python/bin/python2.7 /usr/bin/python
Fix yum: modify the first line of the file /usr/bin/yum (#!/usr/bin/python changed to #!/usr/bin/python2.6)

3. Install setuptools and pip

An error occurs when using pip to install the python module. It is recommended to update setuptools and pip to eliminate it.

Download link: https://pypi.python.org/packages/source/s/setuptools/setuptools-18.4.tar.gz
Install after decompression: python setup.py install (or pip install –upgrade setuptools)

Download link: https://pypi.python.org/packages/source/p/pip/pip-7.1.2.tar.gz
Install after decompression: python setup.py install (or pip install -upgrade pip)

4. Install scrapy+selenium+phantomjs

Download link: https://pypi.python.org/packages/source/S/Scrapy/Scrapy-1.0.3.tar.gz
Install after decompression: python setup.py install (you can also use the pip install scrapy command to install)
Note: When installing with pip install scrapy, there may be an error when the network is abnormal or other dependent libraries are downloaded and installed. You can download the dependent libraries separately for installation.

selenium+phantomjs is installed on demand, if you use a phantomjs browser to parse js, install it:
Download link: https://pypi.python.org/packages/source/s/selenium/selenium-2.48.0.tar.gz
Install after decompression: python setup.py install (you can also use the pip install selenium command to install)
download link:
https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-i686.tar.bz2
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-i686.tar.bz2

tar jxvf phantomjs-1.9.8-linux-i686.tar.bz2
mv phantomjs-1.9.8-linux-i686 /usr/local/src/phantomjs
ln -sf /usr/local/src/phantomjs/bin/phantomjs /usr/local/bin/phantomjs
chmod a+x phantomjs 

5. Install MySQL-python

Python uses MySQL database, and this module needs to be installed.
download link:
https://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.5.zip

Install after decompression: python setup.py install

pip install mysql-python

6. Install MySQL

download link:
http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-5.6.27-1.linux_glibc2.5.x86_64.rpm-bundle.tar
Install after decompression and install using rpm command

rpm MySQL-server-5.6.27-1.linux_glibc2.5.x86_64.rpm
rpm MySQL-client-5.6.27-1.linux_glibc2.5.x86_64.rpm
rpm MySQL-devel-5.6.27-1.linux_glibc2.5.x86_64.rpm
rpm MySQL-shared-5.6.27-1.linux_glibc2.5.x86_64.rpm

4 Deployment notes##

1、 Don't forget to modify environment variables

2、 After installing MySQL, you need to modify the default character set to utf8

Recommended Posts

Python and scrapy deployment in centos environment
Configure python3 environment on centos7 and
Centos-6.5 installation and deployment of LNMP environment
Some Centos Python production environment deployment commands
[CentOS environment deployment] Java7/Java8 deployment under CentOS
Python introduction and environment installation
centos7 install python3 and ipython
Centos 6.10 reinstall python and yum
CentOS7 install python3 and pip3
CentOS 6.9 compile and install python
CentOS 6 compile and install python 3
Centos7 deploys python3 virtual environment
Generators and iterators in Python
Rapid deployment of Kubernetes (k8s) cluster in CentOS7 environment
Centos6.5 installation and deployment of KVM
CentOS7 compile and install L(A|N)MP environment
CentOS quickly install Python3 and pip3
Install Python3 and ansible under CentOS8
Install Python3 and Py under CentOS7
CentOs7 installation and deployment Zabbix3.4 original
Install and configure FreeIPA in Centos7
FFmpeg environment deployment record under centos7
Erlang 20.2 installation and deployment under CentOS 7
CentOS 7 configure Python language development environment
PPTP environment deployment record under Centos
Tomcat configuration JMX in centos 6.5 environment
CentOS + Python3.6+
Centos 7.5 python3.6
How to use and and or in Python
MySQL 8.0 installation, deployment and configuration under CentOS 6/7
Centos7 installation and deployment of gitlab server
Installation and deployment of Nginx in Ubuntu
Centos python3 compile installation and compile gcc upgrade
Zabbix installation and deployment and localization under CentOS
Deploy Docker and configure Nginx in CentOS
Jenkins installation and deployment tutorial under CentOS 7
Compile and install nodejs and yum in Centos8
Centos7 installation and deployment of Airflow detailed
Centos6 install Python2.7.13
Installation and configuration of JDK in CentOS 7 system
Centos7 install Python 3.6.
Functions in python
CentOS install Python 3.6
Python - centos6 installation
Centos7 install Python2.7
The meaning and usage of lists in python
Build Discuz Forum in LNMP Environment under CentOS7
Install Python3 environment in a brand new Ubuntu
Python and Go
How to delete files and directories in python
Build Dedecms website in LNMP environment under CentOS7
Centos install Python3
Installation and configuration of CentOS 7 in VMware Workstation
Centos6.5 compile and install LNMP architecture web environment
CentOS7 Docker Nginx deployment and operation detailed explanation
MySQL 8.0 installation and deployment under CentOS, super detailed!
CentOS6.8 install python2.7
CentOS deployment Harbor
MySQL 8.0 installation, deployment and configuration tutorial on CentOS 8
Installation and use of SSH in Ubuntu environment
Common issues in IDC computer room and Centos8 installation