系統環境:php
# wget http://cn2.php.net/distributions/php-5.5.9.tar.bz2
# tar xf php-5.5.9.tar.bz2 -C /usr/local/src/
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# yum install gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel
# groupadd www
# useradd -g www -s /sbin/nologin -M www
# cd /usr/local/src/php-5.5.9/
# ./configure \
--prefix=/usr/local/php \
--with-config-file-path=/etc \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-opcache \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-gettext \
--enable-mbstring \
--with-iconv \
--with-mcrypt \
--with-mhash \
--with-openssl \
--enable-bcmath \
--enable-soap \
--with-libxml-dir \
--enable-pcntl \
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-sockets \
--with-curl \
--with-zlib \
--enable-zip \
--with-bz2 \
--with-readline \
--without-sqlite3 \
--without-pdo-sqlite \
--with-pear
參數說明:mysql
""" 安裝路徑 """
--prefix=/usr/local/php \
""" php.ini 配置文件路徑 """
--with-config-file-path=/etc \
""" 優化選項 """
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
""" 啓用 opcache,默認爲 ZendOptimizer+(ZendOpcache) """
--enable-opcache \
""" FPM """
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
""" MySQL """
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
""" 國際化與字符編碼支持 """
--with-gettext \
--enable-mbstring \
--with-iconv \
""" 加密擴展 """
--with-mcrypt \
--with-mhash \
--with-openssl \
""" 數學擴展 """
--enable-bcmath \
""" Web 服務,soap 依賴 libxml """
--enable-soap \
--with-libxml-dir \
""" 進程,信號及內存 """
--enable-pcntl \
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
""" socket & curl """
--enable-sockets \
--with-curl \
""" 壓縮與歸檔 """
--with-zlib \
--enable-zip \
--with-bz2 \
""" GNU Readline 命令行快捷鍵綁定 """
--with-readline \
""" 禁用 SQLite 支持擴展 """
--without-sqlite3 \
--without-pdo-sqlite \
""" 更多 PHP 擴展與應用庫 """
--with-pear
若是你的 Web Server 使用的 Apache 請添加相似:--with-apxs2=/usr/local/apache/bin/apxs
參數。sql
關於 mysqlnd
請查看 什麼是 PHP 的 MySQL Native 驅動? 或查看 MySQL 官方介紹:MySQL native driver for PHP, 或 Installation on Unix。apache
更多編譯參數請使用 ./configure --help
查看。api
# make -j4
# make install
若是想從新安裝:bash
# make clean
# make clean all
# ./configure ...
# make -j4
# make install
配置文件:curl
# cp php.ini-development /etc/php.ini
php-fpm 服務socket
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# chmod +x /etc/init.d/php-fpm
啓動 php-fpmphp-fpm
# service php-fpm start
Starting php-fpm done
php-fpm 可用參數 start|stop|force-quit|restart|reload|status優化
編輯 ~/.bash_profile
,將:
PATH=$PATH:$HOME/bin
改成:
PATH=$PATH:$HOME/bin:/usr/local/php/bin
使 PHP 環境變量生效:
# . ~/.bash_profile
查看看 PHP 版本
# php -v
PHP 5.5.9 (cli) (built: Feb 7 2014 15:06:34)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies