Install PHP 5.6.12 on CentOS 7
Environment: CentOS
Software Version: PHP 5.6.12
Download php5.6.12
wgethttp:
//cn2
.php.net
/distributions/php-5
.6.12.
tar
.gz
Decompress the php 5.6.12 source code package
tar
-zxvfphp-5.6.12.
tar
.gz-c
/src
Compile and install
cd
php-5.6.12/
.
/configure
--help
# View configuration parameters because the configuration parameters for each version are different
.
/configure
--prefix=
/usr/local/php-5
.6.12--with-config-
file
-path=
/usr/local/php5
.6.12
/etc
--
enable
-mb--
enable
-bcmath--
enable
-mbstring--
enable
-sockets-2--with-curl--
enable
-
ftp
--
enable
-sockets--disable-ipv6--with-gd--with-jpeg-
dir
--with-png-
dir
--with-freetype-
dir
--
enable
-gd-native-ttf--with-iconv-t--with-zlib--with-pdo-mysql=mysqlnd--with-mysqli=mysqlnd--with-mysql=mysqlnd--
enable
-dom--
enable
-xml--
enable
-fpm
323.
/configure
--prefix=
/usr/local/php-5
.6.12--with-config-
file
-path=
/usr/local/php5
.6.12
/etc
--
enable
-bcmath--
enable
-mbstring--
enable
-sockets--witrl--
enable
-
ftp
--
enable
-sockets--disable-ipv6--with-gd--with-jpeg-
dir
--with-png-
dir
--with-freetype-
dir
--
enable
-gd-native-ttf--with-iconv-
dir
=--enabib--with-pdo-mysql=mysqlnd--with-mysqli=mysqlnd--with-mysql=mysqlnd--
enable
-dom--
enable
-xml--
enable
-fpm
# This is a configuration parameter I wrote for reference. If some class libraries do not exist, install yum or source code.
For example, the libxml2 class library is missing in my system.
configure:error:xml2-confignotfound.Pleasecheckyourlibxml2installation.
# Yuminstall-ylibxml2libxml2-devel # can solve
Then re-compile
Thankyou
for
usingPHP.
# This identifier indicates that the compilation is successful.
make
&&
make
install
Configure php Environment Variables
echo
"PATH=$PATH:/usr/local/php/bin:/usr/local/php/sbin"
>>
/etc/profile
souce!$
# Refresh the system environment
Copy php. ini. production in the php5.6.12 decompress directory to the etc directory of the installation directory, and change the name to php. ini. ini, which is the php configuration file.
cp
php.ini-production
/usr/local/php/etc/php
.ini
Copy the php-fpm.conf.default from the installation directory to the local directory and change it to php-fpm.conf
cp
/src/php-5
.6.12
/sapi/fpm/init
.d.php-fpm
/etc/init
.d
/php-fpm
You can modify the profile php-fpm.conf
Copy the init. d. php-fpm file in the decompressed directory to/etc/init. d folder, modify the name, and modify the startup attribute.
cp
/src/php-5
.6.12
/sapi/fpm/init
.d.php-fpm
/etc/init
.d
/php-fpm
chmod
755
/etc/init
.d
/php-fpm
Test whether the configuration file is correct
[root@localhost~]
#/usr/local/php-5.6.12/sbin/php-fpm-t
[02-Sep-201517:53:34]NOTICE:configuration
file
/usr/local/php-5
.6.12
/etc/php-fpm
.conf
test
issuccessful
Same command
/usr/local/php/sbin/php-fpm
-c
/usr/local/php/etc/php
.ini-y
/usr/local/php/etc/php-fpm
.conf-t
Start and close php and view php status
servicephp-fpmstart
Or
/usr/local/php-5
.6.12
/sbin/php-fpm
servicephp-fpmstop
servicephp-fpmstatus
Usage:
/etc/init
.d
/php-fpm
{start|stop|force-quit|restart|reload|status}
Add php to system service and start it at random
chkconfig--addphp-fpm&&chkconfigphp-fpmon