Unpack, PHP7, and package across Linux distributions

Source: Internet
Author: User
Tags create directory gmp soap sapi unpack
Applicable environment: 64-bit Linux
Download Address (18MB): http://pan.baidu.com/s/1ntsrU8x
Md5sum PHP-7.0.0-DEV-20150502.TAR.XZ
5a4897aedc5ccf02da1f0340ac6013cb
PHP version is 7.0.0 development version, the code downloaded from GitHub on May 2, 2015.
Https://github.com/php/php-src/archive/master.zip

To create a user:
sudo groupadd-r png
sudo useradd-r-G png-s/usr/sbin/nologin-d/png/nonexistent-c "PNG user" png

Create directory settings permissions and unzip:
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 was compiling the packaged PHP7 on the 64-bit Ubuntu14.04, below is the PHP7 running under CentOS7.


Attached: Php packaging method across Linux distributions
Environment: 64-bit Ubuntu14.04

Install the development tools and libraries that compile PHP dependencies:
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

The./buildconf generates a configure file.
Export cflags= "-o3" turns on O3 compilation optimizations, resulting in smaller executables and higher performance.
The./configure_php.sh executes configure, and the script content is below.
sudo mkdir/png && sudo chown $USER: $USER/png
Make && make 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 the traditional init service script, and Php-fpm.service is the SYSTEMD service script.

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 the Linux distribution, you need to find out that PHP relies on the shared libraries packaged with PHP, the script pack.sh as follows:
Create/png/pack/libs and/png/pack/backup these directories beforehand.
pack.sh
#!/bin/bash
#运行 cd/png/pack &&./pack.sh
Php=/png/php/7.0.0-dev

#备份原有文件
Tar czf/png/pack/backup/php.tgz $PHP

#找出二进制和共享库
Php_bin_lib= "$ (Find $PHP-type f-exec file-i ' {} ' \; egrep ' x-executable; charset=binary|x-sharedlib; Charset=binary ') | Awk-f ":" ' {print $} ') "
echo "$PHP _bin_lib" > Bin_lib.txt

#复制库链接器
Cp/lib64/ld-linux-x86-64.so.2/png/pack/libs

#复制依赖库.
For i in ' cat bin_lib.txt '; Do
for j in $i; Do
List= "$ (ldd $j | awk-f" "' {print $} ' |grep '. so ')"
for k in $list; Do
Cp-n "$k"/png/pack/libs
Done
Done
Done

#设置二进制和共享库的rpath和interpreter
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

#打包库和修改后的程序
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.