First, install the PHP5
PHP official website Www.php.net. Mainstream version 5.6,7.1.
If your program, PHP code can be used PHP7 7, can not be used with 5,PHP7 performance has greatly improved.
# cd/usr/local/src/
# wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
# tar ZXVF php-5.6.30.tar.gz
# CD php-5.6.30 to get into this, or./configure will not have that file.
#./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
Analytical:
--prefix=/usr/local/php Specifying the installation directory
--with-apxs2=/usr/local/apache2.4/bin/apxs Apache is a tool that allows the extension to be automatically placed in the Apache modules directory, and in the configuration file in a row lodmodule, automatically configured on , can httpd-m load out this module. can help you configure the expansion module automatically.
--WITH-CONFIG-FILE-PATH=/USR/LOCAL/PHP/ETC specifies the path where the configuration file is located, and the PHP configuration file is called PHP.ini
--WITH-MYSQL=/USR/LOCAL/MYSQL specifies the path to MySQL, three different MySQL drivers, or a library that specifies it, like a driver that needs to identify the NIC. The old version uses this one.
--with-pdo-mysql=/usr/local/mysql
--with-mysqli=/usr/local/mysql/bin/mysql_config new version with mysqli
--with-libxml-dir Follow these are some of the modules required to specify PHP, without special requirements to follow these compilations.
--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
install MySQL and Apache before you install PHP , because the parameters here are to point to them.
After the command has been lost, feedback has an error:
Configure:error:xml2-config not found. Please check your LIBXML2 installation.
# Yum List |grep XML2
# yum install-y libxml2-devel
#./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
Feedback on a configure:error:Cannot find OpenSSL ' s <evp.h>
# yum install-y openssl-devel
#./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
Feedback a configure:error:Please reinstall the BZIP2 distribution
# yum install-y bzip2-devel
#./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
Feedback a configure:error:jpeglib.h not found.
# yum Install-y libjpeg-devel (the actual name of this package is libjpeg-turbo-devel.x86_64, can be seen by Yum List |grep jpeg)
#./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
Feedback a configure:error:png.h not found.
# yum install-y libpng-devel
#./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
Feedback a configure:error:freetype-config not found.
# yum install-y freetype-devel
#./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
Feedback a configure:error:mcrypt.h not found. Please reinstall Libmcrypt.
# yum Install-y libmcrypt-devel (mcrypt This library in the extension source, if not installed first install epel-release)
#./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
See these, that this step has been executed successfully, you can also echo $? Look at this.
Now that you know what packages you need to install, you can install the 7 packages directly at the next installation and execute them again./configure's command
# Make && make install
After make install, you can see:
chmod 755/usr/local/apache2.4/modules/libphp5.so put libphp5.so under the modules.
[Activating module ' PHP5 ' in/usr/local/apache2.4/conf/httpd.conf] activates this configuration file
# ls/usr/local/php
Bin etc include Lib Php
[[email protected] php-5.6.30]# ls/usr/local/php/bin core binary file under Bin
Pear peardev pecl Phar Phar.phar php php-cgi php-config phpize
# du-sh/usr/local/apache2.4/modules/libphp5.so This file is the expansion module we want
37m/usr/local/apache2.4/modules/libphp5.so
The combination of Apache and PHP is implemented through this file.
#/usr/local/php/bin/php-m See what modules this PHP has loaded, similar to httpd-m.
PHP does not need to start with start like Apache and MySQL, because it exists as a module of Apache, and if libphp5.so this file is deleted, then Apache does not support PHP. PHP module is required to execute PHP.
PHP Module Files :/usr/local/apache2.4/modules/libphp5.so
# CP Php.ini-production/usr/local/php/etc/php.ini
PHP reference configuration file: Php.ini-production
php.ini- Production Production environment Use
php.ini- Development Development Environment
The path to the following configuration file is placed here because it was specified at the time of the previous compilation.
#/usr/local/php/bin/php-i |less
-I: This option can see the PHP information, compile parameters, the path of the configuration file (profile)
This line it to recognize the name is PHP.ini, copy came later only.
Second, installation PHP7
# CD/USR/LOCAL/SRC
# wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
# tar jxf 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
--with-mysql=/usr/local/mysql less of this parameter, the others are the same.
# Make && make install
A machine can be loaded with 2 PHP, but Apache calls PHP to be specified, is the configuration file modification.
# ls/usr/local/apache2.4/modules/libphp can see two PHP module files
Libphp5.so libphp7.so
#/usr/local/apache2.4/bin/apachectl-m See Apache loading php5 and PHP7 two.
Php5_module (Shared)
Php7_module (Shared)
# vim/usr/local/apache2.4/conf/httpd.conf want to use which in the configuration file change, no need to add a # at the beginning of the line comment off
#LoadModule php5_module modules/libphp5.so into the file, you can search it directly/php5.
LoadModule Php7_module modules/libphp7.so
Extended
what exactly is mysql,mysqli,mysqlnd,pdo in PHP? http://blog.csdn.net/u013785951/article/details/60876816
View Compilation Parameters http://ask.apelearn.com/question/1295
39, installation PHP5, installation PHP7