您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息
三六零分类信息网 > 鄂州分类信息网,免费分类信息发布

解压即用,跨Linux发行版PHP7打包

2024/3/23 23:30:33发布27次查看
适用环境: 64位linux
下载地址(18mb): http://pan.baidu.com/s/1ntsru8x
md5sum php-7.0.0-dev-20150502.tar.xz
5a4897aedc5ccf02da1f0340ac6013cb
php版本是7.0.0开发版,2015年5月2日从github下载的代码.
https://github.com/php/php-src/archive/master.zip
创建用户:
sudo groupadd -r png
sudo useradd -r -g png -s /usr/sbin/nologin -d /png/nonexistent -c png user png
创建目录设置权限并解压:
sudo mkdir /png && sudo chown $user:$user /png
tar xjf php-7.0.0-dev-20150502.tar.xz -c /
测试:
/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
我是在64位ubuntu14.04上编译打包的php7,下面的截图是跑在centos7下的php7.
附: 跨linux发行版php打包方法
环境: 64位ubuntu14.04
安装编译php依赖的开发工具和库:
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 生成configure文件.
export cflags=-o3 开启o3编译优化,生成的可执行文件更小,性能更高.
./configure_php.sh 执行configure,脚本内容在下方.
sudo mkdir /png && sudo chown $user:$user /png
make && make install 编译和安装php.
配置文件:
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服务管理脚本:
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是传统的init服务脚本,php-fpm.service则是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
要使php跨linux发行版,那就需要找出php依赖的共享库随php打包,脚本pack.sh如下:
事先创建好/png/pack/libs和/png/pack/backup这些目录.
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 $1}')
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 $3}'|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
鄂州分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录