centos6.9 Compiling and installing php5.6 (based on PHP-FPM mode)

Source: Internet
Author: User
Tags apc fpm zend

Write in front

CENTOS6 The default installation of httpd2.2 is not supported fcgi mode, then how to implement the FPM mode on 6, here need to compile the installation httpd2.4 (see the previous blog post).

Premise:

    1. Compiling and installing httpd2.4

    2. Binary installation mariadb5.5

    3. Yum Install related package group Bzip2-devel,libxml2-devel,libmcrypt-devel (Epel Source)

Compiling and installing PHP

] #tar xvf php-5.6.31.tar.xz] #cd php-5.6.31./configure--prefix=/app/php5--with-mysql=/usr/local/mysql-- With-openssl--with-mysqli=/usr/local/mysql/bin/mysql_config--enable-mbstring--with-freetype-dir--with-jpeg-dir --with-png-dir--with-zlib--with-libxml-dir=/usr--enable-xml--enable-sockets--enable-fpm--with-mcrypt-- WITH-CONFIG-FILE-PATH=/ETC/PHP5--with-config-file-scan-dir=/etc/php5.d--with-bz2] #make-j 4 && make install

Implementing PHP Configuration files and service scripts

] #mkdir/ETC/PHP5] #cd php-5.6.30/] #cp Php.ini-production/etc/php5/php.ini] #cp sapi/fpm/init.d.php-fpm/etc/rc.d/   INIT.D/PHP-FPM] #chmod +x/etc/rc.d/init.d/php-fpm] #chkconfig--add php-fpm] #chkconfig--list php-fpmphp-fpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Configuring the Environment

] #vim/etc/profile.d/httpd24.shexport path=/app/php5/bin/:/usr/local/mysql/bin/:/app/httpd24/bin: $PATH <=== httpd and MySQL are both compiled and installed, and the environment is configured here. ]#. /etc/profile.d/httpd24.sh

Edit PHP configuration file

] #cd/app/php5/etc] #cp php-fpm.conf.default php-fpm.conf <=== Some of the port information can be configured.

Modify the HTTPD24 configuration file

] #vim/etc/httpd24/httpd.confloadmodule proxy_module modules/mod_proxy.so <=== Uncomment the two lines LoadModule proxy_fcgi_ Module Modules/mod_proxy_fcgi.soaddtype application/x-httpd-php. Phpaddtype Application/x-httpd-php-source. Phpsproxyrequests off <=== Close forward proxy proxypassmatch ^/(. *\.php) $ fcgi://127.0.0.1:9000/app/httpd24/ Htdocs/$1<ifmodule dir_module> directoryindex index.php index.html <=== add index.php</ifmodule>] #serv Ice httpd24 restart

Test

] #vim/app/httpd24/htdocs/index.php<?php$mysqli=new mysqli ("localhost", "root", "CentOS"); if (mysqli_connect_ errno ()) {echo "Failed to connect to database!"; $mysqli =null;exit;} echo "Connect database successfully!"; $mysqli->close ();p hpinfo ();? >

650) this.width=650; "title=" Php-fpm.png "alt=" Wkiom1nfg0uygwm4aabsoy6ctli486.png "src=" https://s1.51cto.com/ Wyfs02/m00/08/53/wkiom1nfg0uygwm4aabsoy6ctli486.png "/>

] #ab-C 10-n time per request:14.981 [MS] (mean) time per request:1.498 [MS] (mean, across all Concurren T requests) Transfer rate:45934.30 [Kbytes/sec] Received

You can see the site performance is slightly worse than PHP7, but here support PHP5 Support Accelerator, here we introduce what accelerator is?

Accelerator for PHP

Special PHP-based extension mechanisms, such as opcode cache extensions, can also cache opcode in PHP's shared memory, allowing you to skip the compilation phase to improve performance when subsequent executions of the same piece of code are repeated. These accelerators do not really increase the speed of the opcode, but only after analyzing the opcode and rearranging them to achieve the purpose of fast execution.


The common PHP accelerators are:
1.APC (Alternative PHP cache): Follow the PHP license open source Framework, PHP opcode cache Accelerator, the current version is not available for PHP 5.4
Project Address Http://pecl.php.net/package/APC
2.eAccelerator: Originated from Turck MMCache, the earlier version contains a PHP encoder and PHP loader, currently encoder is not supported. Project Address http://eaccelerator.net/

3.XCache: fast and stable php opcode cache, rigorously tested and heavily used in production environments. Project address: http://xcache.lighttpd.net/, included Epel source
4.Zend Optimizer and Zend Guard loader:zend Optimizer is not a opcode accelerator, it is a free, closed-source PHP extension provided by Zend Technologies for PHP5.2 and previous versions, It can run encrypted PHP code or fuzzy code generated by Zend Guard. The Zend Guard loader, however, is an extension that is designed for PHP5.3 similar to Zend Optimizer functionality. Project Address Http://www.zend.com/en/products/guard/runtime-decoders
An open source PHP Accelerator for 5.NuSphere phpexpress:nusphere that supports loading PHP program files encoded by Nusphere PHP encoder and enables the execution of regular PHP files to be accelerated. Project Ground http://www.nusphere.com/products/phpexpress.htm

Here we highlight the XCache.

Installation method
1.RPM Package: from Epel source
2. Compiling the installation

RPM Package There is no need to say, we introduce the compilation installation

Premise

1. Official website Download package: http://xcache.lighttpd.net/wiki/ReleaseArchive

2. Install package Group: Php-devel

Steps:

] #tar xvf xcache-3.2.0.tar.bz2 cd xcache-3.2.0] #phpize <=== from Php-devel]#./configure--enable-xcach E--with-php-config=/app/php5/bin/php-config] #make && make install] #mkdir/etc/php5.d/] #cp xcache.ini/etc/   Php5.d/] #vim/etc/php5.d/xcache.ini extension =/app/php5/lib/php/extensions/no-debug-non-zts-20131226/xcache.so <=== This path will be prompted at the completion of the compilation, it is important to note that] #service php-fpm restart

Test

] #ab-C 10-n time per request:19.222 [MS] (mean) time per request:1.922 [MS] (mean, across all Concurren T requests) Transfer rate:35799.69 [Kbytes/sec] Received

650) this.width=650; "title=" Php-fpm2.png "alt=" Wkiol1nfg0qczzqfaaa2co9apqa034.png "src=" https://s1.51cto.com/ Wyfs02/m00/a7/0a/wkiol1nfg0qczzqfaaa2co9apqa034.png "/>

Refresh the page to see that it has accelerated, by testing the site performance than before there is a significant increase.


centos6.9 Compiling and installing php5.6 (based on PHP-FPM mode)

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.