System environment:
CentOS 6.5/7.0 x86_64
Fedora x86_64
Download PHP Source Package
# wget HTTP://CN2.PHP.NET/DISTRIBUTIONS/PHP-5.5.15.TAR.BZ2
# Tar XF php-5.5.15.tar.bz2-c/usr/local/src/
Add Epel Source
# RPM-UVH http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Installation dependencies
# yum Install GCC bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libxml2-devel libcurl-deve L Bzip2-devel readline-devel Libedit-devel
Create WWW user
# Groupadd www
# useradd-g Www-s/sbin/nologin-m www
Compiling the installation
# cd/usr/local/src/php-5.5.15/
#./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
Parameter description:
"" Installation Path "" "
--prefix=/usr/local/php \
"" "PHP.ini Configuration File path" ""
--WITH-CONFIG-FILE-PATH=/ETC \
"" Optimization Option "" "
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
"" "Enable Opcache, default is 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 \
"" Internationalization and character encoding support "" "
--with-gettext \
--enable-mbstring \
--with-iconv \
"" "Encryption Extension" ""
--with-mcrypt \
--with-mhash \
--WITH-OPENSSL \
"" "Mathematical Extension" ""
--enable-bcmath \
"" "Web Service, soap dependency libxml" ""
--ENABLE-SOAP \
--with-libxml-dir \
"" "process, signal and memory" ""
--ENABLE-PCNTL \
--ENABLE-SHMOP \
--ENABLE-SYSVMSG \
--enable-sysvsem \
--ENABLE-SYSVSHM \
"" "Socket & Curl" ""
--enable-sockets \
--with-curl \
"" "Compress and Archive" ""
--with-zlib \
--enable-zip \
--WITH-BZ2 \
"" "GNU Readline command line shortcut key binding" "
--with-readline \
"" Disables SQLite Support extension "" "
--without-sqlite3 \
--without-pdo-sqlite \
"" "more PHP extensions and Applications Library" "
--with-pear
If your Web Server is using Apache, add the similar:--with-apxs2=/usr/local/apache/bin/apxs parameter.
About MYSQLND Please see what is PHP's MySQL Native driver? or view MySQL official description: MySQL native driver for PHP, or installation on Unix.
For more compilation parameters, use the./configure--help to view.
# MAKE-J4
# make Install
If you want to reinstall:
# Make Clean
# Make Clean all
#./configure ...
# MAKE-J4
# make Install
Configure PHP
Configuration file:
# CP Php.ini-development/etc/php.ini
PHP-FPM Service
# 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
Start PHP-FPM
# service PHP-FPM Start
Starting php-fpm Done
PHP-FPM Available Parameters Start|stop|force-quit|restart|reload|status
Adding PHP commands to environment variables
Edit the ~/.bash_profile to:
Path= $PATH: $HOME/bin
Switch
Path= $PATH: $HOME/bin:/usr/local/php/bin
Make the PHP environment variable effective:
# . ~/.bash_profile
See PHP version
# php-v
PHP 5.5.15 (CLI) (Built:aug 3 2014 02:43:38)
Copyright (c) 1997-2014 the PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
CentOS Source Installation php5.5