解压即用,跨Linux发行版PHP7打包
适用环境: 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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio
