# 安裝 git
sudo yum install git -y
# 建立暫存目錄, 抓取 phpng
mkdir ~/tmp
cd ~/tmp
git clone https://git.php.net/repository/php-src.git
# 安裝相依套件 gcc,bison,libxml2-devel,openssl-devel,bzip2-devel,curl-devel,libpng-devel,libjpeg-devel,libXpm-devel,freetype-devel,gmp-devel,mysql-devel,aspell-devel,recode-devel,t1lib-devel,unixODBC-devel
sudo yum install autoconf gcc bison libxml2-devel openssl-devel bzip2-devel curl-devel libpng-devel libjpeg-devel libXpm-devel freetype-devel gmp-devel epel-release libmcrypt-devel mysql-devel aspell-devel recode-devel t1lib-devel unixODBC-devel -y
# 進行編譯
./buildconf
./configure \
--prefix=$HOME/tmp/usr \
--with-config-file-path=$HOME/tmp/usr/etc \
--enable-mbstring \
--enable-zip \
--enable-bcmath \
--enable-pcntl \
--enable-ftp \
--enable-exif \
--enable-calendar \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-curl \
--with-mcrypt \
--with-iconv \
--with-gmp \
--with-pspell \
--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 \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-openssl \
--with-mysql=/usr \
--with-pdo-mysql=/usr \
--with-gettext=/usr \
--with-zlib=/usr \
--with-bz2=/usr \
--with-recode=/usr \
--with-mysqli=/usr/bin/mysql_config
# 安裝(上面編譯會出現 t1lib 跟 mysql 的 warning, 已有回報bug, 目前無解)
make
sudo make install
# 設定 php.ini
vi $HOME/tmp/usr/etc/php.ini
# php.ini 內容
max_execution_time=600
memory_limit=128M
error_reporting=0
display_errors=0
log_errors=0
user_ini.filename=
realpath_cache_size=2M
cgi.check_shebang_line=0
zend_extension=opcache.so
opcache.enable_cli=1
opcache.save_comments=0
opcache.fast_shutdown=1
opcache.validate_timestamps=1
opcache.revalidate_freq=60
opcache.use_cwd=1
opcache.max_accelerated_files=100000
opcache.max_wasted_percentage=5
opcache.memory_consumption=128
opcache.consistency_checks=0
# 建立軟連結
ln -s /root/tmp/usr/bin/php /usr/bin/php
ln -s /root/tmp/usr/bin/phpize /usr/bin/phpize
# 安裝 re2c
rpm -Uvh http://mirrors.karan.org/epel7/Packages/re2c/20131231011915/0.13.5-1.el6.x86_64/re2c-0.13.5-1.el7.x86_64.rpm
# 安裝 xhprof
git clone https://github.com/Yaoguais/phpng-xhprof.git /root/tmp/php-src/ext/xhprof
cd /root/tmp/php-src/ext/xhprof
phpize
./configure --with-php-config=/root/tmp/usr/bin/php-config
make && make install
# 設定 extension
[xhprof]
extension = xhprof.so
xhprof.output_dir = /tmp/xhprof
參考連結
phpng(php7): https://wiki.php.net/phpng
xhprof(phpng版): https://github.com/Yaoguais/phpng-xhprof