Unpack, PHP7, and package across Linux distributions

Source: Internet
Author: User
Tags create directory gettext gmp sapi unpack

Applicable environment: 64-bit Linux
(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

Unpack, PHP7, and package across Linux distributions

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.