[TOC]
Install php511.10~11.2 install PHP51. Download the PHP5 installation package and unzip it
[[email protected] ~]# cd /usr/local/src/[[email protected] src]# wget http://cn2.php.net/distributions/php-5.6.30.tar[[email protected] src]# tar -xjf php-5.6.30.tar.bz2
This path decompression processing although not error, but no decompression process, echo view does not error. ==--because there's no-v== here.
[[email protected] ~]# cd /usr/local/src/[[email protected] src]# wget http://cn2.php.net/distributions/php-5.6.30.tar.gz[[email protected] src]#tar zxvf php-5.6.30.tar.gz
2 Configuring the 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.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
Parameter description:
–prefix=/usr/local/php 指定的安装目录; –with-apxs2=/usr/local/apache2/bin/apxs 该文件是Apache的一个工具,可以将扩展模块添加到Apache的module文件; –with-config-file-path=/usr/local/php/etc 指定配置文件所在路径; –with-mysql=/usr/local/mysql 指定mysql的路径; –with-mysqli=/usr/local/mysql/bin/mysql_config –with-pdo-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config 上面两项参数是指定相关mysql库 –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以上参数是指定PHP相关的一些模块(通用)。
3 Installation may encounter error 3.1 Configure:error:Cannot find OpenSSL ' s <evp.h>3.2 view yum list |grep-i OpenSSL
[[email protected] php-5.6.30]# echo $?1[[email protected] php-5.6.30]# yum list |grep OpenSSL
Note the capitalization problem here-I
[[email protected] php-5.6.30]# yum list |grep -i OpenSSL
Yum Install-y opensll-devel
[[email protected] php-5.6.30]# yum install -y openssl-devel
Continue typing./configure configuration content
configure: error: Please reinstall the BZip2 distribution[[email protected] php-5.6.30]# yum install -y bzip2-devel
3.3 Configure:error:jpeglib.h not found.
[[email protected] php-5.6.30]# yum install -y libjpeg-devel
Continue typing./configure configuration content
3.4 Configure:error:png.h not found.
[[email protected] php-5.6.30]# yum install -y libpng-devel
3.5 Configure:error:freetype-config not found
[email protected] php-5.6.30]# Yum install-y freetype-devel
3.6 Configure:error:mcrypt.h not found. Please reinstall Libmcrypt.
Because mcrypt.h this library is inside the epel-release extension source.
[[email protected] php-5.6.30]# yum install epel-release
3.7 Configure:error:mcrypt.h not found. Please reinstall Libmcrypt.
[[email protected] php-5.6.30]# yum install -y libmcrypt-devel
Display configuration Succeeded
4.make && make install can be viewed in two steps with or without errors
5. View the file/usr/local/php under production, where bin/is the core file
[[email protected] php-5.6.30]# ls /usr/local/phpbin etc include lib php[[email protected] php-5.6.30]# ls /usr/local/php/bin/pear peardev pecl phar phar.phar php php-cgi php-config phpize
6.du-sh to compare PHP files with Apache files, libphp5.so files are important files to connect PHP and Apache
[[email protected] php-5.6.30]# du -sh /usr/local/php/bin/php36M /usr/local/php/bin/php[[email protected] php-5.6.30]# du -sh /usr/local/apache2.4/modules/libphp5.so37M /usr/local/apache2.4/modules/libphp5.so
7. See what modules are loaded in PHP:/usr/local/php/bin/php-m, these are static modules
[[email protected] php-5.6.30]# /usr/local/php/bin/php -m[PHP Modules]bz2CorectypedatedomeregexiffileinfofiltergdhashiconvjsonlibxmlmbstringmcryptmysqlmysqliopensslpcrePDOpdo_mysqlpdo_sqlitePharposixReflectionsessionSimpleXMLsoapsocketsSPLsqlite3standardtokenizerxmlxmlreaderxmlwriterzlib[Zend Modules]
7.1 PHP as an Apache module exists
8. View the Apache module:/usr/local/apache2.4/bin/httpd-m
[[email protected] php-5.6.30]# /usr/local/apache2.4/bin/httpd -MAH00558: httpd: Could not reliably determine the server‘s fully qualified domain name, using fe80::1d7a:ffe8:8235:a2a5. Set the ‘ServerName‘ directive globally to suppress this messageLoaded Modules: core_module (static) so_module (static) http_module (static) mpm_event_module (static) authn_file_module (shared) authn_core_module (shared) authz_host_module (shared) authz_groupfile_module (shared) authz_user_module (shared) authz_core_module (shared) access_compat_module (shared) auth_basic_module (shared) reqtimeout_module (shared) filter_module (shared) mime_module (shared) log_config_module (shared) env_module (shared) headers_module (shared) setenvif_module (shared) version_module (shared) unixd_module (shared) status_module (shared) autoindex_module (shared) dir_module (shared) alias_module (shared) php5_module (shared)
8.1 php as a module of Apache exists
8.2 php module files in Apache
[[email protected] php-5.6.30]# ls -l /usr/local/apache2.4/modules/libphp5.so-rwxr-xr-x 1 root root 37752768 3月 2 13:02 /usr/local/apache2.4/modules/libphp
9. Open the Apache configuration file and enter/php5.so to find an additional line
[[email protected] php-5.6.30]# vim /usr/local/apache2.4/conf/httpd.conf
There are a lot of laodmoudle in the # annotations, which can be removed when you need to use them.
CP php.ini-production/usr/local/php/etc/php.ini10.1 View PHP information:/usr/local/php/bin/php-i |less
[[email protected] php-5.6.30]# /usr/local/php/bin/php -i |less
10.2 views ls/usr/local/php/etc no php.ini file
[[email protected] php-5.6.30]# ls /usr/local/php/etcpear.conf
Copy it.
[[email protected] php-5.6.30]# cp php.ini-production /usr/local/php/etc/php.ini
10.3 View/usr/local/php/bin/php-i |less loading succeeded
11.2 Installing PHP71. Download the installation package
[[email protected] php-5.6.30]# cd ..[[email protected] src]# wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
2. Decompression: TAR-JXVF php-7.1.6.tar.bz2
Do not display the decompression process without adding v.
3. Switch to the php-7.1.6 directory
Installing PHP-7
This PHP7 can be installed directly because all the dependent library files and installations are installed when the PHP5 is installed.
[[email protected] src]# cd php-7.1.6
4. Environment configuration
[[email protected] 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
Note: The main difference between the number of times and PHP-5 is that there is no "--with-mysql" option but with-mysqli.
5.make compilation and make install installation
6./usr/local/apache2.4/modules/libphp7.so
[[email protected] php-7.1.6]# ls /usr/local/apache2.4/modules/libphp7.so/usr/local/apache2.4/modules/libphp7.so[[email protected] php-7.1.6]# du -sh !$du -sh /usr/local/apache2.4/modules/libphp7.so37M /usr/local/apache2.4/modules/libphp7.so
7. View the PHP7 module:/usr/local/php7/bin/php-m
[[email protected] php-7.1.6]# /usr/local/php7/bin/php -m[PHP Modules]bz2CorectypedatedomexiffileinfofiltergdhashiconvjsonlibxmlmbstringmcryptmysqliopensslpcrePDOpdo_mysqlpdo_sqlitePharposixReflectionsessionSimpleXMLsoapsocketsSPLsqlite3standardtokenizerxmlxmlreaderxmlwriterzlib[Zend Modules]
8. View Apache-loaded PHP Modules: php5_module (Shared) php7_module (shared)
[Email protected] php-7.1.6]#/usr/local/apache2.4/bin/apachectl-m
AH00558:httpd:Could not reliably determine the server ' s fully qualified domain name, using FE80::1D7A:FFE8:8235:A2A5. Set the ' ServerName ' directive globally to suppress this message
Loaded Modules:
Core_module (Static)
So_module (Static)
.
.
.
Php5_module (Shared)
Php7_module (Shared)
9. When Apache loads two PHP modules by default, it is necessary to edit the Apache configuration file to specify which PHP module to invoke by default when it works (comment out one of the call parameters) for normal use:
[[email protected] php-7.1.6]# vim /usr/local/apache2.4/conf/httpd.conf
3. Installing PHP5 and PHP7