lamp-Installing PHP 5/7

Source: Internet
Author: User
Tags soap mcrypt sapi unpack

the current mainstream PHP version is 5.6 and 7.1. compared to PHP 5,PHP 7 is a great boost for performance, has been optimized for its own processing speed, and has changed the use of some grammars. However, since many of the software is based on PHP 5, the installation and configuration of PHP 5 and 7 should be mastered.


Installing PHP 5

1. Download the installation package

[Email protected] src]# wget http://cn2.php.net/distributions/php-5.6.30.tar.gz--2017-07-21 07:39:35--/http Cn2.php.net/distributions/php-5.6.30.tar.gz parsing host cn2.php.net (cn2.php.net) ... 220.181.136.41, 220.181.136.30, 220.181.136.55, ... Connecting Cn2.php.net (cn2.php.net) |220.181.136.41|:80 ... is connected. An HTTP request has been made and is waiting for a response ... $ OK Length: 19274631 (18M) [application/x-gzip] saving to: "Php-5.6.30.tar.gz" 100%[======================================= =======>] 19,274,631 518kb/s spents 34s 2017-07-21 07:40:10 (552 kb/s)-Saved "php-5.6.30.tar.gz" [19274631/19274631])

2. Unpack the compressed package

[Email protected] src]# tar zxf php-5.6.30.tar.gz

3. Configure PHP

[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

During the configuration process, you will encounter a one-to-one configuration failure, which needs to be handled patiently.

Issue 1:configure:error:xml2-config not found. Please check your LIBXML2 installation.

[email protected] php-5.6.30]# Yum install-y libxml2-devel

Issue 2:Configure:error:Cannot find OpenSSL ' s <evp.h>

[email protected] php-5.6.30]# Yum install-y openssl-devel

Issue 3:configure:error:Please Reinstall the BZIP2 distribution

[email protected] php-5.6.30]# Yum install-y bzip2-devel

Issue 4:configure:error:jpeglib.h not found.

[email protected] php-5.6.30]# Yum install-y libjpeg-turbo-devel

Issue 5:configure:error:png.h not found.

[email protected] php-5.6.30]# Yum install-y libpng-devel

Issue 6:configure:error:freetype-config not found.

[email protected] php-5.6.30]# Yum install-y freetype-devel

Issue 7:configure:error:mcrypt.h not found. Please reinstall Libmcrypt.

[email protected] php-5.6.30]# Yum install-y libmcrypt-devel

After you have finished processing the above issues, reconfigure the following text:

Generating filesconfigure: creating ./config.statuscreating main/internal_ functions.ccreating main/internal_functions_cli.c+------------------------------------------------------- -------------+| license:                                                              | |  this software is subject to the php license, available in  this     | |  distribution in the file LICENSE.  By continuing this  installation | |  process, you are bound by the terms of this license  agreement.     | |  if you do not agree with the terms of this license,  you must abort | |  the installation process at this point.                              |+--------------------------------------------------------------------+thank you  for using PHP.config.status: creating php5.specconfig.status: creating  main/build-defs.hconfig.status: creating scripts/phpizeconfig.status: creating scripts/ man1/phpize.1config.status: creating scripts/php-configconfig.status: creating scripts/ man1/php-config.1config.status: creating sapi/cli/php.1config.status: creating sapi/cgi/ Php-cgi.1config.status: creating ext/phar/phar.1config.status: creating ext/phar/phar.phar.1config.status: creating main/php_config.hconfig.status: executing  Default commands

The above text content indicates the configuration is successful, if you are not at ease can use "echo $?" Confirm under.

4. Compiling and installing

[[email protected] php-5.6.30]# make &&make install[[email protected] php-5.6.30]# echo $?0[[email protected] php -5.6.30]# CP Php.ini-production/usr/local/php/etc/php.ini

5. Viewing and verifying

[Email protected] php-5.6.30]# du-sh/usr/local/apache2.4/modules/libphp5.so 37m/usr/local/apache2.4/modules/ Libphp5.so[[email protected] php-5.6.30]# cat/usr/local/apache2.4/conf/httpd.conf | Grep-i phploadmodule php5_module modules/libphp5.so[[email protected] php-5.6.30]#/usr/local/apache2.4/bin/httpd -M | Tail-1 Php5_module (Shared)

The previous chapters have said that PHP's role in the lamp architecture is only the bridge that Apache uses to communicate with MySQL. Therefore, as long as the apache2.4 modules file has libphp5.so files, and in the configuration file has a corresponding configuration. Even removing the PHP installation directory will not have much effect.


Installing PHP 7

1. Download the installation package

[Email protected] php-5.6.30]# cd/usr/local/src[[email protected] src]# wget http://cn2.php.net/distributions/ php-7.1.6.tar.bz2

2. Unpack the compressed package

[[Email protected] src]# tar jxf php-7.1.6.tar.bz2 tar (child): bzip2: Unable to exec: No file or directory tar (child): Error was not recovera  Ble:exiting Nowtar:child returned status 2tar:error is not recoverable:exiting now[[email protected] src]# yum Install -y bzip2[[email protected] src]# tar jxf php-7.1.6.tar.bz2

3. Configure PHP

[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/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[[email protected] php-7.1.6]# echo $?0

4. Compiling and installing

[[email protected] php-7.1.6]# make &&make install[[email protected] php-7.1.6]# echo $?0

5. Viewing and verifying

[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]# CP php.ini-production/usr/local/php7/etc/php.ini[[email protected] php-7.1.6]# cat/usr/ local/apache2.4/conf/httpd.conf | Grep-i phploadmodule php5_module modules/libphp5.soloadmodule php7_module modules/libphp7.so[[email Protect Ed] php-7.1.6]#/usr/local/apache2.4/bin/httpd-m | Tail-2 php5_module (Shared) php7_module (shared)


This article is from "a Man & A computer" blog, please be sure to keep this source http://juispan.blog.51cto.com/943137/1951599

lamp-Installing PHP 5/7

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.