First, PHP5 installation
PHP, is the abbreviation of the English hypertext preprocessing language hypertext preprocessor. PHP is an HTML-embedded language that is a scripting language for embedded HTML documents executed on the server side. Official website: www.php.net
1. Download and unzip the source installation package
2. Configuration and Installation
[[email protected] src]# cd php-5.6.30/[[email protected] php-5.6.30]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/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
Parameter description:
–prefix=/usr/local/php the specified installation directory;
–with-apxs2=/usr/local/apache2/bin/apxs The file is a tool for Apache that can add extensions to the Apache module file;
–WITH-CONFIG-FILE-PATH=/USR/LOCAL/PHP/ETC specifies the path where the configuration file resides;
–WITH-MYSQL=/USR/LOCAL/MYSQL specifies the path to MySQL;
–with-mysqli=/usr/local/mysql/bin/mysql_config
–with-pdo-mysql=/usr/local/mysql–with-mysqli=/usr/local/mysql/bin/mysql_config the above two parameters is to specify the relevant MySQL library
–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
Installation may encounter problems with error 1:
configure: error: xml2-config not found. Please check your libxml2 installation.
Workaround:
[[email protected] php-5.6.30]# yum list | grep libxml2[[email protected] php-5.6.30]# yum install -y libxml2-devel
Error 2:
configure: error: Cannot find OpenSSL‘s <evp.h>
Workaround:
[[email protected] php-5.6.30]# yum install -y openssl-devel
Error 3:
configure: error: Please reinstall the BZip2 distribution
Workaround:
[[email protected] php-5.6.30]# yum install -y bzip2-devel
Error 4
configure: error: jpeglib.h not found.
Workaround:
[[email protected] php-5.6.30]# yum install -y libjpeg-devel
Error 5
configure: error: png.h not found.
Workaround:
[[email protected] php-5.6.30]# yum install -y libpng-devel
Error 6
configure: error: freetype-config not found.
Workaround:
[[email protected] php-5.6.30]# yum install -y freetype-devel
ERROR 7
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
Workaround:
[[email protected] php-5.6.30]# yum list |grep libmcryptlibmcrypt.x86_64 2.5.8-13.el7 epel libmcrypt-devel.x86_64 2.5.8-13.el7 epel [[email protected] php-5.6.30]# yum install -y libmcrypt-devel
If you do not have this installation package, you will need to install the following Yum expansion pack:
[[email protected] php-5.6.30]# yum install epel-release
3. Compile and install
[[email protected] php-5.6.30]# make //编译[[email protected] php-5.6.30]# echo $? //检查上一条命令是否正确[[email protected] php-5.6.30]# make install //安装[[email protected] php-5.6.30]# echo $? //检查上一条命令是否正确,也就是安装是否出错
4. Configuration files
[[email protected] php-5.6.30]# cp php.ini-php.ini-development php.ini-production [[email protected] php-5.6.30]# cp php.ini-production /usr/local/php/etc/php.ini //正常情况下使用php.ini-production,开发环境可以使用php.ini-development[[email protected] php-5.6.30]# /usr/local/php/bin/php -i | less
5. Check if Apache is properly called
[[email protected] php-5.6.30]# cat /usr/local/apache2/conf/httpd.conf | grep phpLoadModule php5_module modules/libphp5.so
Second, PHP7 installation
The installation process is similar to the PHP5 installation process.
It is important to note that:
Apache servers can have 2 versions of PHP, and close a version of the PHP module by commenting out the corresponding lines in the Apache configuration file.
[[email protected] ~]# vim /usr/local/apache2/conf/httpd.conf
If you do not use PHP7, add it in LoadMoudle
front #
.
Installing PHP5 and PHP7