Linux 编译安装 PHP 7

安装前准备

Ubuntu

1
2
3
apt-get install build-essential
apt-get install libtool libmcrypt-dev libxml2 libxml2-dev libcurl4-gnutls-dev \
libjpeg-dev libpng-dev libfreetype6-dev libmcrypt-dev

CentOS

1
2
3
4
5
6
7
8
yum -y install gcc automake autoconf libtool make
yum -y install gcc gcc-c++ glibc

yum -y install libmcrypt-devel mhash-devel libxslt-devel \
libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel \
zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel \
ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel \
krb5 krb5-devel libidn libidn-devel openssl openssl-devel

编译安装 php-fpm

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
wget https://downloads.php.net/~ab/php-7.0.0beta2.tar.gz --no-check-certificate
tar zxvf php-7.0.0beta2.tar.gz
cd php-7.0.0beta2/

./configure --prefix=/usr/local/php7 \
--with-config-file-path=/usr/local/php7/etc --enable-fpm \
--with-fpm-user=www --with-fpm-group=www --with-mysqli \
--with-pdo-mysql --with-iconv-dir --with-freetype-dir \
--with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr \
--enable-xml --disable-rpath --enable-bcmath --enable-shmop \
--enable-sysvsem --enable-inline-optimization --with-curl \
--enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp \
--with-gd --enable-gd-native-ttf --with-openssl --with-mhash \
--enable-pcntl --enable-sockets --with-xmlrpc --enable-zip \
--enable-soap --without-pear --with-gettext --disable-fileinfo \
--enable-maintainer-zts

make
make install

安装好之后,做上软链接:

1
2
3
4
ln -s /usr/local/php7/bin/php /usr/bin/php7
ln -s /usr/local/php7/bin/php-config /usr/bin/php7-config
ln -s /usr/local/php7/bin/phpize /usr/bin/php7ize
ln -s /usr/local/php7/sbin/php-fpm /usr/sbin/php7-fpm

参考资料:http://www.frostsky.com/2011/11/php-configure-error/

(完)