System environment:
CentOS 6.5/7.0 x86_64
Fedora x86_64
Download PHP Source Package
# wget http://cn2.php.net/distributions/php-5.6.0.tar.xz# xz-d php-5.6.0.tar.xz# tar xf php-5.6.0.tar-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 Sqlite-devel
Note: If you are using a epel 7
source, there may not be a mcrypt mhash mhash-devel
few packages that are http://dl.fedoraproject.org/pub/epel/6/x86_64/
downloaded in, used yum localinstall xxx.rpm
or rpm -Uvh xxx.rpm
manually installed.
Create WWW user
# groupadd www# useradd-g www-s/sbin/nologin-m www
Compiling the installation
# cd/usr/local/src/php-5.6.0/#./configure \--prefix=/usr/local/php56 \--with-config-file-path=/usr/local/php56/ 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
parameter description:
" Installation path " "--prefix=/usr/local/php56 \" " php.ini Profile Path " "-- With-config-file-path=/usr/local/php56/etc \ "" " Optimization options " "--enable-inline-optimization \-- Disable-debug \--disable-rpath \--enable-shared \ "" " enable opcache, default = 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 \ "" " Math Extension " ""--enable-bcmath \ "" Web Service,soap dependent 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 \ "" " Compression and archive "" "--with-zlib \--enable-zip \--with-bz2 \" "" GNU Readline Command line accelerator bindings "" "--with-readline
If your Web Server is using Apache please add similar: --with-apxs2=/usr/local/apache-xx/bin/apxs
parameters.
See mysqlnd
What is PHP's MySQL Native driver? or view MySQL official description: MySQL Native driver for PHP, or installation on Unix.
PHP 5.6 Built-in phpdbg Interactive debugger, by --enable-phpdbg
opening, will PREFIX/bin
create a phpdbg command in the directory, interested can try.
For more compilation parameters, use ./configure --help
view.
# make-j8# make Install
If you want to reinstall:
# make clean# make clean all#/configure ... # make-j8# make install
Configure PHP
configuration file :
# CP Php.ini-development/usr/local/php56/etc/php.ini
PHP-FPM Service
# cp/usr/local/php56/etc/php-fpm.conf.default/usr/local/php56/etc/php-fpm.conf# CP sapi/fpm/init.d.php-fpm/etc/ init.d/php-fpm56# chmod +X/ETC/INIT.D/PHP-FPM56
Start PHP-FPM
# service Php-fpm56 startstarting php-fpm done
PHP-FPM Available Parameters Start|stop|force-quit|restart|reload|status
Adding PHP commands to environment variables
Editor ~/.bash_profile
, Will:
Path= $PATH: $HOME/bin change to: path= $PATH: $HOME/bin:/usr/local/php56/bin
Make the PHP environment variable effective:
# . ~/.bash_profile
See PHP version
# php-vphp 5.6.0 (CLI) (built:sep 03:44:18) Copyright (c) 1997-2014 the PHP groupzend Engine v2.6.0, Copyright ( c) 1998-2014 Zend Technologies
Reprint please indicate the source.
address of this article: http : //blog.aboutc.net/linux/65/compile-and-install-php-on-linux
Linux under compile and install PHP 5.6