Build PHP and Python's apns2 environment in CentOS

Source: Internet
Author: User
Tags install openssl openldap

Version:
Centos-6.5-x86_64
OpenSSL 1.0.2j
Curl 7.50.3
PHP php 7.0.12

1. Upgrade OpenSSL

Enter the OpenSSL source file
./config--PREFIX=/USR--shared
Make
Make depend
Make install

Note: openssl.cnf this file to replace the original system


2. Upgrade Curl

Curl to install NGHTTP2 first
Yum Install LIBNGHTTP2

(The online environment may not require the following two steps)
sudo yum groupinstall "Development Tools"
sudo yum install Libev libev-devel zlib zlib-devel OpenSSL openssl-devel git

Enter the Curl source file
./configure--prefix=/usr/local/curl \
--with-nghttp2=/usr/local \
--with-ssl=/usr/local/ssl

Make
Make install

Note: curl-config this file to replace the system's original


3. Upgrading PHP


3.1 (The online environment may not require the following steps)
Reinstall the LIBXML2 and Libxml2-devel packages
Yum Install LIBXML2
Yum Install Libxml2-devel-y
Yum install-y bzip2 Bzip2-devel

3.2
Enter PHP source file
./configure--prefix=/usr/local/php \
--WITH-SSL=/USR/LOCAL/SSL \
--WITH-OPENSSL \
--with-curl

Make && make install


To verify the upgrade results:
Curl--version
OpenSSL must be a newly upgraded version and must display the HTTP2 typeface

Phpinfo configuration must display the following information
CURL information = 7.50.3
HTTP2 = Yes
SSL Version = openssl/1.0.2j


Configuring the Python environment in CentOS


Pre-turn Dependency pack
sudo yum groupinstall "Development Tools"
sudo yum install Libev libev-devel zlib zlib-devel OpenSSL openssl-devel git

Yum Install LIBXML2
Yum Install Libxml2-devel-y
Yum install-y bzip2 Bzip2-devel

Yum Install Sqlite-devel
Yum Install openssl-devel.i686
Yum Install Readline-devel


Yum Install bzip2-devel.i686
Yum Install gdbm-devel.i686

Yum Install libdbi-devel.i686
Yum Install Ncurses-libs
Yum Install zlib-devel.i686

Yum-y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-deve L zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel Curl curl-devel e2fsprogs E2 Fsprogs-devel krb5 krb5-devel libidn libidn-devel OpenSSL openssl-devel openldap openldap-devel Nss_ldap Openldap-clients openldap-server libstdc++.so.6 libnspr4.so libssl.so.6


---the above online environment may not need to be installed-----

sudo yum install gcc libffi-devel python-devel openssl-devel (required)


(1) Upgrade the python2.6.6 to the 2.7 version first

CD Python-2.7.12
Vim Modules/setup.dist

Found it
# Socket Module helper for SSL support; You must comment out of the other
# socket line above, and possibly edit the SSL variable:
#SSL =/usr/local/ssl#_ssl _ssl.c \
#-duse_ssl-i$ (SSL)/include-i$ (SSL)/INCLUDE/OPENSSL \
#-l$ (SSL)/lib-lssl-lcrypto

Remove the previous # number and change it to
# Socket Module helper for SSL support; You must comment out of the other
# socket line above, and possibly edit the SSL variable:
Ssl=/usr/local/ssl # (This modifies the line as the actual path)
_ssl _ssl.c \
-duse_ssl-i$ (SSL)/include-i$ (SSL)/INCLUDE/OPENSSL \
-l$ (SSL)/lib-lssl-lcrypto


Installation
./configure

Make a && make install && make clean && make Distclean

5. View version Information
/usr/local/bin/python2.7-v

6. Establish a soft connection so that the system default Python points to python2.7
mv/usr/bin/python/usr/bin/python2.6.6
Ln-s/usr/local/bin/python2.7/usr/bin/python

7. Re-examine the Python version
Python-v

8 Resolve system Python soft link to Python2.7 version, since Yum is not compatible with Python 2.7, Yum does not work properly and we need to specify the Python version of Yum

Vi/usr/bin/yum
The file header is
#!/usr/bin/python

Change into
#!/usr/bin/python2.6.6

(2) then upgrade PIP
Download the latest version of PIP, then install

wget https://bootstrap.pypa.io/get-pip.py
Python get-pip.py
Find the location of the PIP

1
Whereis pip
Find the path to the pip2.7 and create a soft chain for it as the default startup version of the system

1
Ln-s/usr/local/bin/pip2.7/usr/bin/pip

(3) Install dependent libraries
Pip Install cryptography
Pip Install Pyopenssl
Pip Install Hyper

Verify that the environment is built successfully:
command line Input python

Import SSL
Print SSL. Openssl_version
(The version number of the newly installed OpenSSL will appear successfully)

Ssl. Has_alpn
(Success will return true)

Build PHP and Python's apns2 environment in CentOS

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.