Linux 6 under Compile and install PHP 5.6

Source: Internet
Author: User
Tags install php mcrypt pear php cli

PHP (foreign name: Php:hypertext Preprocessor, Chinese name: "Hypertext Preprocessor") is a common open source scripting language. The grammar absorbs the C language, Java and Perl features, is conducive to learning, widely used, mainly for the field of web development. PHP with its development source code, free, fast, cross-platform, efficient, object-oriented, powerful dynamic image creation and other functions by the vast number of developers love. This document describes the installation of PHP 5.6.9 based on the CentOS 6.7 compiler.

One, related dependent package installation
1, demo environment# more/etc/redhat-releaseCentOS Release6.7(Final)2, Extended Support (MCrypt, Mhash extensions, and libevent) if you want the compiled PHP to support MCrypt, Mhash extensions, and libevent, you need to install the following package Libmcrypt libmcrypt-devel m Hash mhash-devel Description: MCrypt extension Library can implement encryption and decryption function, that is, both plaintext can be encrypted or ciphertext restore. Mhash is a non-reversible PHP encryption extension library based on discrete mathematical principles, which is not turned on by default. Mhash can be used to create checksum values, message summaries, message authentication codes, and key information that does not need to be saved (such as passwords). CentOS source can not install libmcrypt-devel, due to copyright reasons do not have their own MCrypt package can use a third-party source, so you can also use Yum to install third-party yum Source# wget Http://www.atomicorp.com/installers/atomic        # sh./atomicInstalling with the Yum command# yum Install php-mcrypt libmcrypt libmcrypt-devel mhash mhash-devel3, libevent related packages can be installed as required libevent, the system will usually bring libevent, but the version is somewhat low. So you can upgrade the installation of the following two RPM packages.# yum Install libevent libevent-develDescription: Libevent is an asynchronous event notification library file whose API provides a mechanism for executing a callback function when an event occurs on a file description or when it is timed out, primarily to replace theEvent LoopMechanism. For now, Libevent supports/dev/poll, Kqueue,Select, poll, Epoll, and Solaris.EventPorts4Supporting XML-related packages supporting XML RPM Package BZIP2 is a lossless compression software based on Burrows-wheeler transform can efficiently complete the compression of file data Libcurl The main function is to use different protocols to connect and communicate with different servers, That is, a fairly encapsulated sockphp Libcurl allows you to connect and communicate different servers with different protocols.# yum Install libxml2 libxml2-devel bzip2-devel libcurl-devel5, graphics-related RPM packages usually correspond to error hints: jis-mapped Japanese font supportinchGd# yum Install libjpeg-devel libpng-devel freetype-devel
Second, compile and install php-5.6.9
Download source package to local directory first, download location http://mirrors.sohu.com/php/# pwd/usr/Local/src# TAR-XF php-5.6. 9. tar.gz# CD. # LN-SV./src/php-5.6. 9php# CD php/#./configure--prefix=/usr/local/php \        --with-mysql=/usr/local/mysql \        --with-openssl \        --enable-fpm \        --enable-sockets \        --ENABLE-SYSVSHM \        --enable-ftp \        --with-mysqli=/usr/local/mysql/bin/mysql_config \        --enable-mbstring \        --with-freetype-dir \        --with-jpeg-dir \        --with-png-dir \        --with-zlib-dir \        --with-libxml-dir=/usr \        --enable-xml \        --with-mhash \        --with-mcrypt \        --with-config-file-path=/etc/php/php.ini \        --WITH-CONFIG-FILE-SCAN-DIR=/ETC/PHP/PHP.D \        --with-bz2 \        --with-curl \        --with-pear \        --WITH-GD# make && make install## #以下为安装完毕之后的提示信息 Installing shared extensions:/usr/Local/php/lib/php/extensions/no-Debug-non-zts-20131226/Installing PHP CLI binary:/usr/Local/php/bin/installing php CLI man page:/usr/Local/php/php/man/man1/installing php FPM binary:/usr/Local/php/sbin/installing php FPM config:/usr/Local/php/etc/installing php FPM man page:/usr/Local/php/php/man/man8/installing PHP FPM Status page:/usr/Local/php/php/php/fpm/installing php CGI binary:/usr/Local/php/bin/installing php CGI man page:/usr/Local/php/php/man/man1/installing Build Environment:/usr/Local/php/lib/php/build/installing Header files:/usr/Local/php/include/php/installing Helper Programs:/usr/Local/php/bin/program:phpize Program:php-config Installing man pages:/usr/Local/php/php/man/man1/page:phpize. 1# # Author:leshami Page:php-config. 1# # # Blog:http://blog.csdn.net/leshami Installing PEAR Environment:/usr/Local/php/lib/php/[PEAR] archive_tar-installed:1.3.[PEAR] Console_getopt-installed:1.3. 1[PEAR] Structures_graph-installed:1.0. 4[PEAR] Xml_util-installed:1.2. 3[PEAR] Pear-installed:1.9. 5Wrote PEAR system config file at:/usr/Local/php/etc/pear.conf want to add:/usr/Local/php/lib/php to your php.ini include_path/usr/Local/php/build/shtool install-c ext/phar/phar.phar/usr/Local/php/bin ln-s-f/usr/Local/php/bin/phar.phar/usr/Local/php/bin/phar Installing PDO headers:/usr/Local/php/include/php/ext/pdo/## #创建php配置目录 # mkdir-pv/etc/php/php.d## #php配置 php.ini is PHP running core configuration file PHP-FPM. Conf is the configuration file for the PHP-FPM process Service # cp/usr/Local/php/php.ini-production/etc/php/php.ini# cp/usr/Local/php/sapi/fpm/init.d.php-fpm/etc/init.d/php-fpm# chmod755/etc/init.d/php-fpm# cp/usr/Local/php/etc/php-fpm.conf.default/usr/Local/php/etc/php-fpm.conf## #测试php配置 #/usr/Local/php/sbin/php-fpm-t[ at-may- .  -:Geneva: the] Notice:configuration file/usr/Local/php/etc/php-fpm.conf test is successful# chkconfig--add php-fpm# chkconfig php-fpm on# service php-fpm start starting php-fpm done# ps-ef|grep php root45690 1 0  -: -?xx:xx:xxPhp-fpm:master Process (/usr/Local/php/etc/php-fpm.conf) Nobody45691  45690  0  -: -?xx:xx:xxPhp-fpm:pool www Nobody45692  45690  0  -: -?xx:xx:xxPhp-fpm:pool www Root45694   3441  0  -: -pts/4 xx:xx:xxgrep php# Netstat-nltp|grep9000Tcp0   0 127.0. 0. 1:9000   0.0. 0. 0:* LISTEN45690/php-fpm
Third, configure Apache to access PHP
# # #开启以下模块# vim/etc/httpd24/httpd.conf # # #注意此处, I'm here to compile the httpd2.4 version of the installation separately, so the paths are different        LoadModuleProxy_module modeles/mod_proxy.soLoadModuleProxy_fcgi_module modules/mod_proxy_fcgi.soAddTypeapplication/x-httpd-php. phpAddTypeApplication/x-httpd-php-source. Phpsproxyrequests Off     # # #关闭正向代理, turn on the downstream reverse proxy        Proxypassmatch^/(. *\.php) $ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/ $# service Httpd24 Restart        stopping httpd24:[OK]starting httpd24:[OK]
Iv. Verifying PHP
###编写一个php页面测试# echo "> > > <?php> phpinfo();> ?>> ###测试PHP# curl -I http://localhost:90/index.phpHTTP/1.1 200 OKDate: Fri, 15 Jul 2016 03:16:50 GMTServer: Apache/2.4.9 (Unix)X-Powered-By: PHP/5.6.9Content-Type: text/html; charset=UTF-8

Linux 6 under Compile and install PHP 5.6

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.