PHP5, PHP7 installation

Source: Internet
Author: User
Tags mcrypt

PHP official website www.php.net Current mainstream version is 5.6/7.1 cd/usr/local/src/


Installing PHP5

#wget http://cn2.php.net/distributions/php-5.6.30.tar.gz

#tar ZXF php-5.6.30.tar.gz

#cd php-5.6.30


Initializing the installation

#./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache2.4/bin/apxs--with-config-file-path=/usr/ Local/php/etc--with-mysql=/usr/local/mysql--with-pdo-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/ Mysql_config--with-libxml-dir--with-gd--with-jpeg-dir--with-png-dir--with-freetype-dir--with-iconv-dir-- With-zlib-dir--with-bz2--with-openssl--with-mcrypt--enable-soap--enable-gd-native-ttf--enable-mbstring-- Enable-sockets--enable-exif


--prefix=/usr/local/php//Specify PHP installation path

--with-apxs2=/usr/local/apache2.4/bin/apxs//apache tool, let Apache support PHP, the use of apache2.0 above version, APXS represents the use of apache1.0 version Ben, Apxs function is to use the LoadModule directive in MOD_SO to load the specified module to Apache, which requires Apache to open the so module.

--WITH-CONFIG-FILE-PATH=/USR/LOCAL/PHP/ETC//Specifies the PHP configuration file.

--with-mysql=/usr/local/mysql//Specify the installation path for MySQL

--with-pdo-mysql=/usr/local/mysql//

--with-mysqli=/usr/local/mysql/bin/mysql_config//mysqli Extension technology can not only invoke MySQL's stored procedures, handle MySQL transactions, but also make access to the database work more stable.

--with-libxml-dir//Open support for LIBXML2 Library

--WITH-GD//Open GD library support

--with-jpeg-dir//Turn on support for JPEG images

--with-png-dir//Turn on support for PNG images

--with-freetype-dir//Open support for FreeType font library

--with-iconv-dir//For PHP compile time specify Iconv in the system path, otherwise the default path will be scanned.

--with-zlib-dir//Open Zlib Library support for HTTP compression transport

--WITH-BZ2//Open support for bz2 files

--with-openssl//OPENSSL Support, encrypted transmission of HTTPS when used

--with-mcrypt//mcrypt Algorithm Extension

--enable-soap

--ENABLE-GD-NATIVE-TTF//Support TrueType String function library

--enable-mbstring//multibyte, string support

--enable-sockets//Open Sockets support

--ENABLE-EXIF//Image meta-data support


If no special requirements, directly copy the above parameter initialization can be.


Error prompt, missing XML2 library, installation can be.


Because we compiled PHP parameters are more, all the packages to install more, here according to the prompt to install the line.

#yum install-y libxml2-devel.x86_64

#yum install-y Openssl-devel

#yum install-y bzip2-devel.x86_64

#yum install-y Libjpeg-devel

#yum install-y Libpng-devel

#yum install-y Freetype-devel

#yum Install Libmcrypt-devel


The above interface appears to be initialized, and you can start compiling. Make && make install


View PHP-loaded modules:/usr/local/php/bin/php-m These modules are static modules.

Viewing the Apache module, you can see the PHP5 dynamic module:/usr/local/apache2.4/bin/httpd-m




Look at the Apache configuration file, you can see a line to load the PHP module statement, if you do not want to load the PHP module can be commented out. Since we have specified the configuration file path, all of the PHP default reference configuration files are copied to the/usr/local/php/etc/directory. CP Php.ini-production/usr/local/php/etc/php.ini


If it is a development environment, you can use the Php.ini-development configuration file, and the Php.ini-production file is suitable for the build environment.

/usr/local/php/bin/php-i with Command | Less can view some PHP information, compile parameters, configure paths, and so on.





Installing PHP7

#cd/usr/local/src/

#wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2

#tar ZXF php-7.1.6.tar.bz2

#cd php-7.1.6

#./configure--PREFIX=/USR/LOCAL/PHP7--with-apxs2=/usr/local/apache2.4/bin/apxs--with-config-file-path=/usr/ Local/php7/etc--with-pdo-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config-- With-libxml-dir--with-gd--with-jpeg-dir--with-png-dir--with-freetype-dir--with-iconv-dir--with-zlib-dir-- with-bz2--with-openssl--with-mcrypt--enable-soap--enable-gd-native-ttf--enable-mbstring--enable-sockets-- Enable-exif

The same as PHP5, only the installation path and configuration file path are modified, others are unchanged.


#make && make Install

#ls/usr/local/apache2.4/modules/libphp7.so

#cp Php.ini-production/usr/local/php7/etc/php.ini

As for which version to use, it needs to be specified in the Apache configuration file, which is to comment out the unused version.


/usr/local/apache2.4/conf/httpd.conf

PHP5, PHP7 installation

Related Article

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.