PHP is actually an Apache extension module. (Final installation required)
PHP official website www.php.net
Current mainstream version is 5.6/7.1
cd/usr/local/src/
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
./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
Make && make install
CP Php.ini-production/usr/local/php/etc/php.ini
Experimental process:
[Email protected] src]# cd/usr/local/src/
[Email protected] src]# wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
[Email protected] src]# du-h php-5.6.30.tar.gz
19mphp-5.6.30.tar.gz
[Email protected] src]# tar zxvf php-5.6.30.tar.gz
[Email protected] php-5.6.30]# CD php-5.6.30/
[Email protected] php-5.6.30]#./configure
--prefix=/usr/local/php//Specify installation directory
--with-apxs2=/usr/local/apache2.4.7/bin/apxs//apache Tool module related (your Apache directory)
--WITH-CONFIG-FILE-PATH=/USR/LOCAL/PHP/ETC//Specify the path where the configuration file is located
--with-mysql=/usr/local/mysql//Specify the path to MySQL
--with-pdo-mysql=/usr/local/mysql//
--with-mysqli=/usr/local/mysql/bin/mysql_config//These two are MySQL drivers or libraries
--with-libxml-dir//Back These things are some modules, many need to be installed
--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
Detailed Error:
1 configure:error:xml2-config not found. Please check your LIBXML2 installation.
[email protected] php-5.6.30]# Yum install-y libxml2-devel
2 Configure:error:Cannot Find OpenSSL ' s <evp.h>
[email protected] php-5.6.30]# Yum install-y openssl-devel
3 Configure:error:Please Reinstall the BZIP2 distribution
[email protected] php-5.6.30]# Yum install-y bzip2-devel
4 configure:error:jpeglib.h not found.
[email protected] php-5.6.30]# Yum install-y libjpeg-turbo.x86_64 jpeginfo.x86_64 jpegoptim.x86_64 libjpeg-turbo-deve L.x86_64
5 Configure:error:freetype-config not found.
[email protected] php-5.6.30]# Yum install-y freetype freetype-devel
6 Configure:error:mcrypt.h not found. Please reinstall Libmcrypt.
[[email protected] php-5.6.30]# yum install-y epel-release//install extension source
[email protected] php-5.6.30]# Yum install-y libmcrypt-devel
Thank for using PHP.
Config.status:creating Php5.spec
Config.status:creating Main/build-defs.h
Config.status:creating scripts/phpize
Config.status:creating scripts/man1/phpize.1
Config.status:creating Scripts/php-config
Config.status:creating Scripts/man1/php-config.1
Config.status:creating SAPI/CLI/PHP.1
Config.status:creating SAPI/CGI/PHP-CGI.1
Config.status:creating Ext/phar/phar.1
Config.status:creating Ext/phar/phar.phar.1
Config.status:creating main/php_config.h
config.status:executing default Commands
[[email protected] php-5.6.30]# echo $?
0
[Email protected] php-5.6.30]#
Compile parameter configuration complete!!
[[email protected] php-5.6.30] #make
Make the time will be reported a lot of errors, basically are missing library files, directly download the corresponding library can
or copy and paste into search engine search
Build complete.
Don ' t forget to run ' make test '.
[[email protected] php-5.6.30]# echo $?
0
It's strange that I have no error.
[[email protected] php-5.6.30]# make install
[[email protected] php-5.6.30]# echo $?
0
[[email protected] php-5.6.30]# ls/usr/local/php///php Directory
Bin etc include Lib Php
[[email protected] php-5.6.30]# ls/usr/local/php/bin///bin is an important document
Pear peardev pecl Phar Phar.phar php php-cgi php-config phpize
[Email protected] php-5.6.30]# du-sh/usr/local/php/bin/php
36m/usr/local/php/bin/php
[Email protected] php-5.6.30]# du-sh/usr/local/apache2.4.7/modules/libphp5.so
37m/usr/local/apache2.4.7/modules/libphp5.so//37m This is the expansion module we want.
[[email protected] php-5.6.30]#/usr/local/php/bin/php-m//view PHP loaded modules are static modules
[PHP Modules]
..
Last copy of configuration file
[email protected] php-5.6.30]# CP Php.ini-production/usr/local/php/etc/php.ini
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
Make && make install
Ls/usr/local/apache2.4/modules/libphp7.so
CP Php.ini-production/usr/local/php7/etc/php.ini
Experiment
cd/usr/local/src/
[Email protected] src]# wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
[Email protected] src]# tar jxf php-7.1.6.tar.bz2
[Email protected] src]# CD php-7.1.6/
[Email protected] php-7.1.6]#/configure--PREFIX=/USR/LOCAL/PHP7--WITH-APXS2=/USR/LOCAL/APACHE2.4.7/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
A few minutes later
Thank for using PHP.
Config.status:creating Php7.spec
Config.status:creating Main/build-defs.h
Config.status:creating scripts/phpize
Config.status:creating scripts/man1/phpize.1
Config.status:creating Scripts/php-config
Config.status:creating Scripts/man1/php-config.1
Config.status:creating SAPI/CLI/PHP.1
Config.status:creating SAPI/CGI/PHP-CGI.1
Config.status:creating Ext/phar/phar.1
Config.status:creating Ext/phar/phar.phar.1
Config.status:creating main/php_config.h
config.status:executing default Commands
[[email protected] php-7.1.6]# echo $?
0
[Email protected] php-7.1.6]#/configure--PREFIX=/USR/LOCAL/PHP7--WITH-APXS2=/USR/LOCAL/APACHE2.4.7/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
[Roo[email protected] php-7.1.6]# make
[[email protected] php-7.1.6]# make install
Ok
The commands to view the compiler parameters for Nginx, Napache, MySQL, and PHP under Linux are as follows:
1, nginx compilation parameters:
#/usr/local/nginx/sbin/nginx-v
2, Apache compilation parameters:
# Cat/usr/local/apache/build/config.nice
3, PHP compilation parameters:
#/usr/local/php/bin/php-i |grep Configure
4. mysql Compilation parameters:
# Cat/usr/local/mysql/bin/mysqlbug|grep Configure
This article is from the "13348833" blog, please be sure to keep this source http://13358833.blog.51cto.com/13348833/1969422
Lamp Environment Build Three (CENTOS7) PHP5 and PHP7 installation