Compile and install PHP5.6 in Linux

Source: Internet
Author: User
Compile and install the PHP5.6 system environment in Linux:

CentOS 6.5/7.0 x86_64

Fedora 20 x86_64

Download the PHP source code 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 an epel source
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Install dependency
# 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 the epel 7 source, there may be no mcrypt mhash-devel packages, download from the http://dl.fedoraproject.org/pub/epel/6/x86_64/, use yum localinstall xxx. rpm or rpm-Uvh xxx. you can install rpm manually.

Create a www user
# groupadd www# useradd -g www -s /sbin/nologin -M www

Compile and install
# 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, the default value 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 \ "support for internationalization and character encoding """-- with-gettext \ -- enable-mbstring \ -- with-iconv \ "encrypted extension" -- with-mcrypt \ -- with-mhash \ -- with-openssl \""" mathematical extension "-- enable-bcmath \" Web service, soap depends on 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 archiving" -- with-zlib \ -- enable-zip \ -- with-bz2 \ "GNU Readline command line shortcut bind "" -- with-readline

If your Web Server uses Apache, add a parameter similar to -- with-apxs2 =/usr/local/apache-xx/bin/apxs.

For details about mysqlnd, what is the MySQL Native driver of PHP? For more information, see MySQL official introduction: MySQL native driver for PHP, or Installation on Unix.

PHP 5.6? You have created a phpdbg interactive debugger and enabled it through -- enable-phpdbg. a phpdbg command is generated in the PREFIX/bin directory. if you are interested, try it.

For more compilation parameters, see./configure -- help.

# make -j8# make install

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 parameter start | stop | force-quit | restart | reload | status

Add PHP commands to environment variables

Edit ~ /. Bash_profile, which will:

PATH = $ PATH: $ HOME/bin to: PATH = $ PATH: $ HOME/bin:/usr/local/php56/bin

Make PHP environment variables take effect:

# . ~/.bash_profile

View PHP version

# php -vPHP 5.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

Indicate the source for reprinting.
Address: http://blog.aboutc.net/linux/65/compile-and-install-php-on-linux

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.