申明

当前文章使用的 PHP 版本: 5.5.7 stable 下载

.bz2 解压命令 $ tar jxf file-name

.gz 解压命令 $ tar zxf file-name

推荐事先安装的一些依赖

$ yum install -y gcc gcc-c++ make cmake autoconf libtool \
libtool-ltdl-devel pcre pcre-devel gd-devel freetype-devel \
libxml2-devel libjpeg-devel libpng-devel openssl-devel \
curl-devel patch libmcrypt-devel libmhash-devel ncurses-devel \
sudo bzip2 bzip2-devel bison perl-devel perl-ExtUtils-Embed \
libcurl-devel libjpeg-devel libpng-devel freetype-devel \
t1lib-devel libicu-devel mhash libmcrypt libmcrypt libiconv \
libxslt-devel openldap-devel

安装re2c

re2c 下载地址

$ tar zxf re2c-file-name
$ cd re2c-file-folder
$ ./configure && make && make install > out

编译安装PHP

编译参数

$ ./configure \
--prefix=/usr/local/php \
--with-bz2 \
--with-config-file-path=/usr/local/etc/php \
--with-curl \
--with-freetype-dir \
--with-jpeg-dir=/usr/lib \
--with-png-dir=/usr/lib \
--with-gd \
--with-gettext \
--with-mhash \
--with-iconv-dir \
--with-libxml-dir \
--with-mcrypt \
--with-openssl-dir \
--with-openssl \
--with-pcre-dir \
--with-pcre-regex \
--with-pear \
--with-t1lib \
--with-zlib \
--with-pgsql=/usr/local/pgsql \
--with-pdo-pgsql=/usr/local/pgsql \
--enable-exif \
--enable-fpm \
--enable-ftp \
--enable-gd-native-ttf \
--enable-intl \
--enable-mbstring \
--enable-mod-charset \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-zip \
--enable-opcache \
--disable-ipv6 \
--disable-fileinfo > out

安装

$ make
$ make install

上面只是支持了pgsql数据库,如果需要支持mysql加上下面的编译参数

--with-mysql=/usr/local/mysql \
--with-pdo-mysql=/usr/local/mysql \
--with-mysql-sock=/tmp/mysqld.sock \
--with-mysqli=/usr/local/mysql/bin/mysql_config \

注意事项

1.如果内存不小于128M,可以尝试去除disable-fileinfo编译参数

--disable-fileinfo

2.如果碰到关于liconv的错误提示可以尝试:

$ make ZEND_EXTRA_LIBS='-liconv'

3.如果提示错误:

configure: error: libjpeg.(a|so) not found.
configure: error: libpng.(a|so) not found.

执行下面的语句

$ cp -frp /usr/lib64/libjpeg.* /usr/lib/
$ cp -frp /usr/lib64/libpng* /usr/lib/

4.如果碰到”configure: error: mcrypt.h not found. Please reinstall libmcrypt”,编译安装一下libmcrypt即可,步骤如下:

$ wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
$ tar zxf libmcrypt-2.5.8.tar.gz
$ cd libmcrypt-2.5.8
$ ./configure
$ make
$ make install

5.如果iconv即可满足编码转换的需求,可以去除mbstring编译选项:

--enable-mbstring \

配置文件

注意以下命令中的配置文件模板都存在于源码目录下

复制php.ini文件至编译时参数--with-config-file-path=PATH设定的配置文件目录

$ mkdir /usr/local/etc/php
$ cp php.ini-development /usr/local/etc/php/php.ini

复制php-fpm的配置文件

$ cp sapi/fpm/php-fpm.conf /usr/local/php/etc/php-fpm.conf

设置命令软链接

$ ln -s /usr/local/php/sbin/php-fpm /usr/local/bin
$ ln -s /usr/local/php/bin/pecl /usr/local/bin
$ ln -s /usr/local/php/bin/php /usr/local/bin

启动

$ php-fpm

MkkHou
515 声望8 粉丝

个人简介都不给


引用和评论

0 条评论