Linux under compile and install PHP 5.6

Source: Internet
Author: User
Tags gettext install php soap mcrypt zend

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-devel 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 Configuration File path" ""--With-Config-File-Path=/usr/Local/Php56/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 --enable-sockets --with-curl  "" "Compress and Archive" " Span class= "PLN" >--with-zlib --enable-zip --with-bz2  "" "GNU Readline command Line Accelerator binding" "--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改为:PATH=$PATH:$HOME/bin:/usr/local/php56/bin

Make the PHP environment variable effective:

# . ~/.bash_profile

See PHP version

# php-vPhp5.6.0 (Cli) (Built: Sep 23 2014 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.
This article address:http://blog.aboutc.net/linux/65/compile-and-install-php-on-linux

Linux under compile and install PHP 5.6

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.