Decompress the package and package it in PHP7 across Linux releases.

Source: Internet
Author: User
Tags gmp sapi
Decompress the package and use it in a cross-Linux PHP7 package environment: 64-bit Linux
(18 MB): http://pan.baidu.com/s/1ntsrU8x
Md5sum php-7.0.0-dev-20150502.tar.xz
5a4897aedc5ccf02da1f0340ac6013cb
PHP is developed in version 7.0.0 and downloaded from Github in May 2, 2015.
Https://github.com/php/php-src/archive/master.zip

Create a user:
Sudo groupadd-r png
Sudo useradd-r-g png-s/usr/sbin/nologin-d/png/nonexistent-c "png user" png

Create a directory, set permissions, and decompress the package:
Sudo mkdir/png & sudo chown $ USER: $ USER/png
Tar xJf php-7.0.0-dev-20150502.tar.xz-C/

Test:
/Png/php/7.0.0-dev/bin/php-v
/Png/php/7.0.0-dev/bin/php-cgi-v
/Png/php/7.0.0-dev/sbin/php-fpm-v

I compiled and packaged PHP7 on 64-bit Ubuntu14.04, and the following is php7running under CentOS7.


Appendix: packaging of PHP across Linux releases
Environment: 64-bit Ubuntu14.04

Install and compile the development tools and libraries on which PHP depends:
Sudo apt-get install \
Build-essential \
Autoconf \
Libtool \
Re2c \
Libxml2-dev \
Openssl \
Libcurl4-openssl-dev \
Libbz2-dev \
Libjpeg-dev \
Libpng12-dev \
Libfreetype6-dev \
Libldap2-dev \
Libmcrypt-dev \
Libmysqlclient-dev \
Libxslt1-dev \
Libxt-dev \
Libpcre3-dev \
Libxpm-dev \
Libt1-dev \
Libgmp-dev \
Libpspell-dev \
Librecode-dev

Sudo ln-s/usr/lib/'arch '-linux-gnu/libldap. so/usr/lib/
Sudo ln-s/usr/lib/'arch '-linux-gnu/liblber. so/usr/lib/
Sudo ln-s/usr/include/'arch '-linux-gnu/gmp. h/usr/include/gmp. h

Wget-O php-7.0.0-dev.zip https://github.com/php/php-src/archive/master.zip

./Buildconf generate the configure file.
Export CFLAGS = "-O3" enables O3 compilation optimization. the generated executable file is smaller and the performance is higher.
./Configure_php.sh execute configure, and the script content is below.
Sudo mkdir/png & sudo chown $ USER: $ USER/png
Make & make install compile and install PHP.

Configuration File:
Cp/png/src/php-7.0.0-dev-20150502/php. ini-*/png/php/7.0.0-dev/lib/
Cp/png/php/7.0.0-dev/lib/php. ini-production/png/php/7.0.0-dev/lib/php. ini
Cp/png/php/7.0.0-dev/etc/php-fpm.conf.default/png/php/7.0.0-dev/etc/php-fpm.conf
Cp/png/php/7.0.0-dev/etc/php-fpm.d/www. conf. default/png/php/7.0.0-dev/etc/php-fpm.d/www. conf
PHP-FPM service management script:
Cp/png/src/php-7.0.0-dev-20150502/sapi/fpm/init. d. php-fpm/png/php/7.0.0-dev/png-fpm
Cp/png/src/php-7.0.0-dev-20150502/sapi/fpm/php-fpm.service/png/php/7.0.0-dev/
Init. d. php-fpm is a traditional init service script, while php-fpm.service is the service script of systemd.

Configure_php.sh
#! /Bin/bash
./Configure \
-- Prefix =/png/php/7.0.0-dev \
-- Enable-opcache \
-- Enable-fpm \
-- Enable-pdo \
-- Enable-sockets \
-- Enable-exif \
-- Enable-soap \
-- Enable-ftp \
-- Enable-wddx \
-- Enable-pcntl \
-- Enable-soap \
-- Enable-bcmath \
-- Enable-mbstring \
-- Enable-dba \
-- Enable-gd-native-ttf \
-- Enable-gd-jis-conv \
-- Enable-zip \
-- Enable-calendar \
-- Enable-shmop \
-- Enable-sysvmsg \
-- Enable-sysvsem \
-- Enable-sysvshm \
-- With-mysqli \
-- With-pdo-mysql \
-- With-pdo-sqlite \
-- With-iconv \
-- With-gmp \
-- With-pspell \
-- With-gettext \
-- With-xmlrpc \
-- With-openssl \
-- With-mhash \
-- With-mcrypt \
-- With-xsl \
-- With-curl \
-- With-pcre-regex \
-- With-gd \
-- With-jpeg-dir =/usr \
-- With-png-dir =/usr \
-- With-zlib-dir =/usr \
-- With-xpm-dir =/usr \
-- With-freetype-dir =/usr \
-- With-t1lib =/usr \
-- With-gettext =/usr \
-- With-zlib =/usr \
-- With-bz2 =/usr \
-- With-recode =/usr \
-- With-ldap \
-- With-pear \
-- With-readline \
-- With-fpm-user = png \
-- With-fpm-group = png \
-- With-apxs2 =/png/httpd/2.4.12P/bin/apxs

To make PHP cross-Linux releases, you need to find out the shared library on which PHP depends and pack it with PHP. the script pack. sh is as follows:
Create/png/pack/libs and/png/pack/backup directories in advance.
Pack. sh
#! /Bin/bash
# Run cd/png/pack &./pack. sh
PHP =/png/php/7.0.0-dev

# Back up original files
Tar czf/png/pack/backup/php. tgz $ PHP

# Finding out binary and shared libraries
PHP_BIN_LIB = "$ (find $ PHP-type f-exec file-I '{}' \; | egrep 'X-executable; charset = binary | x-sharedlib; charset = binary '| awk-F ":"' {print $1 }')"
Echo "$ PHP_BIN_LIB"> bin_lib.txt

# Copy the library linker
Cp/lib64/ld-linux-x86-64.so.2/png/pack/libs

# Copy the dependent database.
For I in 'cat bin_lib.txt '; do
For j in $ I; do
List = "$ (ldd $ j | awk-F" "'{print $3}' | grep '. so ')"
For k in $ list; do
Cp-n "$ k"/png/pack/libs
Done
Done
Done

# Set the rpath and interpreter of binary and shared libraries
For I in 'cat bin_lib.txt '; do
/Png/pack/patchelf -- set-rpath/png/pack/libs -- force-rpath $ I
/Png/pack/patchelf -- set-interpreter/png/pack/libs/ld-linux-x86-64.so.2 $ I
Done

# Package Library and modified program
Tar cJf/png/pack/png.tar. xz/png/pack/libs $ PHP

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.