PHP5.3版本安装

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS PostgreSQL,集群系列 2核4GB
简介:

第1章 PHP安装

1.1 安装准备

1.1.1 检查Nginx的安装情况

[root@web01 ~]# ll/application/nginx

lrwxrwxrwx. 1 root root 25Apr  4 10:22 /application/nginx ->/application/nginx-1.8.1/

[root@web01 ~]# lsof -i :80

COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

nginx   1635 root   10u IPv4  11106      0t0 TCP *:http (LISTEN)

nginx   1639 nginx  10u  IPv4  11106     0t0  TCP *:http (LISTEN)

[root@web01 ~]#

1.1.2 检查安装PHP所需的lib库

[root@web01 ~]# rpm -qazlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel

zlib-devel-1.2.3-29.el6.x86_64

[root@web01 ~]# rpm -qafreetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel

[root@web01 ~]# yum install-y zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel

Loaded plugins:fastestmirror, security

Setting up Install Process

Loading mirror speeds fromcached hostfile

 * base: mirrors.opencas.cn

 * extras: mirrors.opencas.cn

 * updates: mirrors.opencas.cn

base                                                                                                                        | 3.7kB     00:00    

extras                                                                                                                      | 3.4 kB     00:00    

updates                                                                                                                     |3.4 kB     00:00    

updates/primary_db                                                                                                          | 4.6 MB     00:00    

Package zlib-devel-1.2.3-29.el6.x86_64already installed and latest version

No package libiconv-develavailable.

Resolving Dependencies

--> Running transactioncheck

---> Packagelibjpeg-turbo-devel.x86_64 0:1.2.1-3.el6_5 will be installed

---> Package libxml2-devel.x86_640:2.7.6-20.el6_7.1 will be installed

--> Processing Dependency:libxml2 = 2.7.6-20.el6_7.1 for package: libxml2-devel-2.7.6-20.el6_7.1.x86_64

--> Running transactioncheck

---> Packagelibxml2.x86_64 0:2.7.6-20.el6 will be updated

--> Processing Dependency:libxml2 = 2.7.6-20.el6 for package: libxml2-python-2.7.6-20.el6.x86_64

---> Packagelibxml2.x86_64 0:2.7.6-20.el6_7.1 will be an update

--> Running transactioncheck

---> Packagelibxml2-python.x86_64 0:2.7.6-20.el6 will be updated

---> Packagelibxml2-python.x86_64 0:2.7.6-20.el6_7.1 will be an update

--> Finished DependencyResolution

 

Dependencies Resolved

 

====================================================================================================================================================

 Package                                   Arch                         Version                                Repository                    Size

====================================================================================================================================================

Installing:

 libjpeg-turbo-devel                       x86_64                       1.2.1-3.el6_5                           base                           96 k

 libxml2-devel                             x86_64                       2.7.6-20.el6_7.1                        updates                       1.1 M

Updating for dependencies:

 libxml2                                   x86_64                       2.7.6-20.el6_7.1                        updates                       803 k

 libxml2-python                            x86_64                       2.7.6-20.el6_7.1                        updates                       323 k

 

Transaction Summary

====================================================================================================================================================

Install       2 Package(s)

Upgrade       2 Package(s)

 

Total download size: 2.3 M

Downloading Packages:

(1/4):libjpeg-turbo-devel-1.2.1-3.el6_5.x86_64.rpm                                                                         |  96 kB     00:00    

(2/4):libxml2-2.7.6-20.el6_7.1.x86_64.rpm                                                                                  | 803 kB     00:02    

(3/4):libxml2-devel-2.7.6-20.el6_7.1.x86_64.rpm                                                                            | 1.1 MB     00:00    

(4/4):libxml2-python-2.7.6-20.el6_7.1.x86_64.rpm                                                                            |323 kB     00:00    

----------------------------------------------------------------------------------------------------------------------------------------------------

Total                                                                                                               646kB/s | 2.3 MB     00:03    

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Updating  : libxml2-2.7.6-20.el6_7.1.x86_64                                                                                                 1/6

  Installing :libxml2-devel-2.7.6-20.el6_7.1.x86_64                                                                                           2/6

  Updating  : libxml2-python-2.7.6-20.el6_7.1.x86_64                                                                                          3/6

  Installing :libjpeg-turbo-devel-1.2.1-3.el6_5.x86_64                                                                                         4/6

  Cleanup   : libxml2-python-2.7.6-20.el6.x86_64                                                                                              5/6

  Cleanup   : libxml2-2.7.6-20.el6.x86_64                                                                                                      6/6

  Verifying : libxml2-devel-2.7.6-20.el6_7.1.x86_64                                                                                           1/6

  Verifying : libxml2-python-2.7.6-20.el6_7.1.x86_64                                                                                          2/6

  Verifying : libxml2-2.7.6-20.el6_7.1.x86_64                                                                                                 3/6

  Verifying : libjpeg-turbo-devel-1.2.1-3.el6_5.x86_64                                                                                        4/6

  Verifying : libxml2-2.7.6-20.el6.x86_64                                                                                                     5/6

  Verifying : libxml2-python-2.7.6-20.el6.x86_64                                                                                              6/6

 

Installed:

  libjpeg-turbo-devel.x86_640:1.2.1-3.el6_5                                libxml2-devel.x86_64 0:2.7.6-20.el6_7.1                               

 

Dependency Updated:

  libxml2.x86_64 0:2.7.6-20.el6_7.1                                    libxml2-python.x86_64 0:2.7.6-20.el6_7.1                                   

 

Complete!

[root@web01 ~]# yum install-y freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel

Loaded plugins:fastestmirror, security

Setting up Install Process

Loading mirror speeds fromcached hostfile

 * base: mirrors.btte.net

 * extras: mirrors.opencas.cn

 * updates: mirrors.opencas.cn

Resolving Dependencies

--> Running transactioncheck

---> Packagefreetype-devel.x86_64 0:2.3.11-15.el6_6.1 will be installed

---> Packagegd-devel.x86_64 0:2.0.35-11.el6 will be installed

--> Processing Dependency:gd = 2.0.35-11.el6 for package: gd-devel-2.0.35-11.el6.x86_64

--> Processing Dependency:libXpm-devel for package: gd-devel-2.0.35-11.el6.x86_64

--> Processing Dependency:libX11-devel for package: gd-devel-2.0.35-11.el6.x86_64

--> Processing Dependency:fontconfig-devel for package: gd-devel-2.0.35-11.el6.x86_64

--> Processing Dependency:libgd.so.2()(64bit) for package: gd-devel-2.0.35-11.el6.x86_64

---> Packagelibcurl-devel.x86_64 0:7.19.7-46.el6 will be installed

--> Processing Dependency:libidn-devel for package: libcurl-devel-7.19.7-46.el6.x86_64

---> Packagelibpng-devel.x86_64 2:1.2.49-2.el6_7 will be installed

--> Processing Dependency:libpng = 2:1.2.49-2.el6_7 for package: 2:libpng-devel-1.2.49-2.el6_7.x86_64

---> Packagelibxslt-devel.x86_64 0:1.1.26-2.el6_3.1 will be installed

--> Processing Dependency:libxslt = 1.1.26-2.el6_3.1 for package: libxslt-devel-1.1.26-2.el6_3.1.x86_64

--> Processing Dependency:libgcrypt-devel for package: libxslt-devel-1.1.26-2.el6_3.1.x86_64

--> Processing Dependency:libxslt.so.1()(64bit) for package: libxslt-devel-1.1.26-2.el6_3.1.x86_64

--> Processing Dependency:libexslt.so.0()(64bit) for package: libxslt-devel-1.1.26-2.el6_3.1.x86_64

--> Running transactioncheck

---> Packagefontconfig-devel.x86_64 0:2.8.0-5.el6 will be installed

---> Package gd.x86_640:2.0.35-11.el6 will be installed

--> Processing Dependency:libXpm.so.4()(64bit) for package: gd-2.0.35-11.el6.x86_64

---> PackagelibX11-devel.x86_64 0:1.6.0-6.el6 will be installed

--> Processing Dependency:pkgconfig(xcb) >= 1.1.92 for package: libX11-devel-1.6.0-6.el6.x86_64

--> Processing Dependency:pkgconfig(xproto) for package: libX11-devel-1.6.0-6.el6.x86_64

--> Processing Dependency:pkgconfig(xcb) for package: libX11-devel-1.6.0-6.el6.x86_64

--> Processing Dependency:pkgconfig(kbproto) for package: libX11-devel-1.6.0-6.el6.x86_64

---> PackagelibXpm-devel.x86_64 0:3.5.10-2.el6 will be installed

--> Processing Dependency:libXt.so.6()(64bit) for package: libXpm-devel-3.5.10-2.el6.x86_64

---> Packagelibgcrypt-devel.x86_64 0:1.4.5-11.el6_4 will be installed

--> Processing Dependency:libgpg-error-devel for package: libgcrypt-devel-1.4.5-11.el6_4.x86_64

---> Packagelibidn-devel.x86_64 0:1.18-2.el6 will be installed

---> Package libpng.x86_642:1.2.49-1.el6_2 will be updated

---> Package libpng.x86_642:1.2.49-2.el6_7 will be an update

---> Packagelibxslt.x86_64 0:1.1.26-2.el6_3.1 will be installed

--> Running transactioncheck

---> Package libXpm.x86_640:3.5.10-2.el6 will be installed

---> Package libXt.x86_640:1.1.4-6.1.el6 will be installed

---> Packagelibgpg-error-devel.x86_64 0:1.7-4.el6 will be installed

---> Package libxcb-devel.x86_640:1.9.1-3.el6 will be installed

--> Processing Dependency:pkgconfig(xau) >= 0.99.2 for package: libxcb-devel-1.9.1-3.el6.x86_64

---> Packagexorg-x11-proto-devel.noarch 0:7.7-9.el6 will be installed

--> Running transactioncheck

---> PackagelibXau-devel.x86_64 0:1.0.6-4.el6 will be installed

--> Finished DependencyResolution

 

Dependencies Resolved

 

====================================================================================================================================================

 Package                                   Arch                        Version                                  Repository                    Size

====================================================================================================================================================

Installing:

 freetype-devel                            x86_64                      2.3.11-15.el6_6.1                         base                         365 k

 gd-devel                                  x86_64                      2.0.35-11.el6                             base                          78 k

 libcurl-devel                             x86_64                      7.19.7-46.el6                             base                         246 k

 libpng-devel                              x86_64                      2:1.2.49-2.el6_7                          updates                      112 k

 libxslt-devel                             x86_64                      1.1.26-2.el6_3.1                          base                         561 k

Installing for dependencies:

 fontconfig-devel                          x86_64                      2.8.0-5.el6                               base                         209 k

 gd                                        x86_64                      2.0.35-11.el6                             base                         142 k

 libX11-devel                              x86_64                      1.6.0-6.el6                               base                         983 k

 libXau-devel                              x86_64                      1.0.6-4.el6                               base                          14 k

 libXpm                                    x86_64                      3.5.10-2.el6                              base                          51 k

 libXpm-devel                              x86_64                      3.5.10-2.el6                              base                          33 k

 libXt                                    x86_64                     1.1.4-6.1.el6                            base                         165 k

 libgcrypt-devel                           x86_64                      1.4.5-11.el6_4                            base                         118 k

 libgpg-error-devel                        x86_64                      1.7-4.el6                                 base                          14 k

 libidn-devel                              x86_64                      1.18-2.el6                                base                         137 k

 libxcb-devel                              x86_64                      1.9.1-3.el6                               base                         1.0 M

 libxslt                                   x86_64                      1.1.26-2.el6_3.1                          base                         452 k

 xorg-x11-proto-devel                      noarch                      7.7-9.el6                                 base                         286 k

Updating for dependencies:

 libpng                                    x86_64                      2:1.2.49-2.el6_7                          updates                      182 k

 

Transaction Summary

====================================================================================================================================================

Install      18 Package(s)

Upgrade       1 Package(s)

 

Total download size: 5.0 M

Downloading Packages:

(1/19):fontconfig-devel-2.8.0-5.el6.x86_64.rpm                                                                             |209 kB     00:00    

(2/19):freetype-devel-2.3.11-15.el6_6.1.x86_64.rpm                                                                         | 365 kB     00:00    

(3/19): gd-2.0.35-11.el6.x86_64.rpm                                                                                         | 142 kB     00:00    

(4/19):gd-devel-2.0.35-11.el6.x86_64.rpm                                                                                   |  78 kB    00:00    

(5/19):libX11-devel-1.6.0-6.el6.x86_64.rpm                                                                                 | 983 kB     00:00    

(6/19):libXau-devel-1.0.6-4.el6.x86_64.rpm                                                                                  |  14 kB    00:00    

(7/19):libXpm-3.5.10-2.el6.x86_64.rpm                                                                                      |  51 kB     00:00    

(8/19):libXpm-devel-3.5.10-2.el6.x86_64.rpm                                                                                |  33 kB     00:00    

(9/19):libXt-1.1.4-6.1.el6.x86_64.rpm                                                                                      | 165 kB     00:00    

(10/19):libcurl-devel-7.19.7-46.el6.x86_64.rpm                                                                             | 246 kB     00:00    

(11/19):libgcrypt-devel-1.4.5-11.el6_4.x86_64.rpm                                                                          | 118 kB     00:00    

(12/19):libgpg-error-devel-1.7-4.el6.x86_64.rpm                                                                            |  14 kB    00:00    

(13/19):libidn-devel-1.18-2.el6.x86_64.rpm                                                                                 | 137 kB     00:00    

(14/19):libpng-1.2.49-2.el6_7.x86_64.rpm                                                                                    |182 kB     00:00    

(15/19):libpng-devel-1.2.49-2.el6_7.x86_64.rpm                                                                             | 112 kB     00:00    

(16/19): libxcb-devel-1.9.1-3.el6.x86_64.rpm                                                                                | 1.0 MB     00:00    

(17/19):libxslt-1.1.26-2.el6_3.1.x86_64.rpm                                                                                | 452 kB     00:00    

(18/19):libxslt-devel-1.1.26-2.el6_3.1.x86_64.rpm                                                                          | 561 kB     00:00    

(19/19):xorg-x11-proto-devel-7.7-9.el6.noarch.rpm                                                                           | 286kB     00:00    

----------------------------------------------------------------------------------------------------------------------------------------------------

Total                                                                                                               2.6MB/s | 5.0 MB     00:01    

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Updating  : 2:libpng-1.2.49-2.el6_7.x86_64                                                                                                  1/20

  Installing : libXpm-3.5.10-2.el6.x86_64                                                                                                     2/20

  Installing : xorg-x11-proto-devel-7.7-9.el6.noarch                                                                                          3/20

  Installing :freetype-devel-2.3.11-15.el6_6.1.x86_64                                                                                        4/20

  Installing :fontconfig-devel-2.8.0-5.el6.x86_64                                                                                            5/20

  Installing :libXau-devel-1.0.6-4.el6.x86_64                                                                                                 6/20

  Installing :libxcb-devel-1.9.1-3.el6.x86_64                                                                                                7/20

  Installing : libX11-devel-1.6.0-6.el6.x86_64                                                                                                8/20

  Installing : gd-2.0.35-11.el6.x86_64                                                                                                        9/20

  Installing :2:libpng-devel-1.2.49-2.el6_7.x86_64                                                                                          10/20

  Installing :libgpg-error-devel-1.7-4.el6.x86_64                                                                                           11/20

  Installing :libgcrypt-devel-1.4.5-11.el6_4.x86_64                                                                                         12/20

  Installing : libXt-1.1.4-6.1.el6.x86_64                                                                                                    13/20

  Installing :libXpm-devel-3.5.10-2.el6.x86_64                                                                                              14/20

  Installing :libxslt-1.1.26-2.el6_3.1.x86_64                                                                                               15/20

  Installing :libidn-devel-1.18-2.el6.x86_64                                                                                                 16/20

  Installing :libcurl-devel-7.19.7-46.el6.x86_64                                                                                            17/20

  Installing : libxslt-devel-1.1.26-2.el6_3.1.x86_64                                                                                         18/20

  Installing :gd-devel-2.0.35-11.el6.x86_64                                                                                                 19/20

  Cleanup   : 2:libpng-1.2.49-1.el6_2.x86_64                                                                                                20/20

  Verifying : libgcrypt-devel-1.4.5-11.el6_4.x86_64                                                                                           1/20

  Verifying : libidn-devel-1.18-2.el6.x86_64                                                                                                 2/20

  Verifying : libxcb-devel-1.9.1-3.el6.x86_64                                                                                                3/20

  Verifying : libXpm-devel-3.5.10-2.el6.x86_64                                                                                               4/20

  Verifying : libXau-devel-1.0.6-4.el6.x86_64                                                                                                5/20

  Verifying : freetype-devel-2.3.11-15.el6_6.1.x86_64                                                                                        6/20

  Verifying : fontconfig-devel-2.8.0-5.el6.x86_64                                                                                            7/20

  Verifying : xorg-x11-proto-devel-7.7-9.el6.noarch                                                                                           8/20

  Verifying : libxslt-1.1.26-2.el6_3.1.x86_64                                                                                                9/20

  Verifying : libXpm-3.5.10-2.el6.x86_64                                                                                                    10/20

  Verifying : 2:libpng-devel-1.2.49-2.el6_7.x86_64                                                                                          11/20

  Verifying : libXt-1.1.4-6.1.el6.x86_64                                                                                                    12/20

  Verifying : libgpg-error-devel-1.7-4.el6.x86_64                                                                                            13/20

  Verifying : libcurl-devel-7.19.7-46.el6.x86_64                                                                                            14/20

  Verifying : libxslt-devel-1.1.26-2.el6_3.1.x86_64                                                                                         15/20

  Verifying : gd-devel-2.0.35-11.el6.x86_64                                                                                                 16/20

  Verifying : libX11-devel-1.6.0-6.el6.x86_64                                                                                               17/20

  Verifying : 2:libpng-1.2.49-2.el6_7.x86_64                                                                                                18/20

  Verifying : gd-2.0.35-11.el6.x86_64                                                                                                       19/20

  Verifying : 2:libpng-1.2.49-1.el6_2.x86_64                                                                                                20/20

 

Installed:

  freetype-devel.x86_640:2.3.11-15.el6_6.1         gd-devel.x86_64 0:2.0.35-11.el6                 libcurl-devel.x86_640:7.19.7-46.el6        

  libpng-devel.x86_64 2:1.2.49-2.el6_7               libxslt-devel.x86_640:1.1.26-2.el6_3.1        

 

Dependency Installed:

  fontconfig-devel.x86_64 0:2.8.0-5.el6            gd.x86_64 0:2.0.35-11.el6                        libX11-devel.x86_640:1.6.0-6.el6            

  libXau-devel.x86_64 0:1.0.6-4.el6                libXpm.x86_640:3.5.10-2.el6                    libXpm-devel.x86_64 0:3.5.10-2.el6           

  libXt.x86_64 0:1.1.4-6.1.el6                     libgcrypt-devel.x86_640:1.4.5-11.el6_4         libgpg-error-devel.x86_64 0:1.7-4.el6        

  libidn-devel.x86_64 0:1.18-2.el6                 libxcb-devel.x86_640:1.9.1-3.el6               libxslt.x86_64 0:1.1.26-2.el6_3.1            

  xorg-x11-proto-devel.noarch 0:7.7-9.el6        

 

Dependency Updated:

  libpng.x86_64 2:1.2.49-2.el6_7                                                                                                                   

 

Complete!

[root@web01 ~]# rpm -qa zlib-devellibxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel

libxml2-devel-2.7.6-20.el6_7.1.x86_64

libjpeg-turbo-devel-1.2.1-3.el6_5.x86_64

zlib-devel-1.2.3-29.el6.x86_64

[root@web01 ~]# rpm -qafreetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel

gd-devel-2.0.35-11.el6.x86_64

freetype-devel-2.3.11-15.el6_6.1.x86_64

libpng-devel-1.2.49-2.el6_7.x86_64

libxslt-devel-1.1.26-2.el6_3.1.x86_64

libcurl-devel-7.19.7-46.el6.x86_64

[root@web01 ~]#

从以上的结果看出,仅有libiconv-devel这个包装没有安装,因为默认的yum源没有此包。可以采用编译安装的方式安装。

1.1.3 安装libiconv库

wgethttp://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

 

    tar xf libiconv-1.14.tar.gz

    cd libiconv-1.14

    ./configure --prefix=/usr/local/libiconv

    make

make install

 

1.1.4 安装libmcrypt库(非必须)

从repo源安装

   wget -O/etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

    yum install libmcrypt-devel -y

    rpm -qa libmcrypt

 

1.1.5 安装mhash、mcrypt加密扩展库

yum install mhash mhash-devel -y

   rpm -qa mhash mhash-devel

yum install mcrypt -y

   rpm -qa mcrypt

1.2 PHP安装

1.2.1 解压配置PHP

[root@web01tools]# tar xf php-5.3.27.tar.gz

[root@web01tools]# cd php-5.3.27

[root@web01php-5.3.27]#  ./configure \

>--prefix=/application/php5.3.27 \

>--with-mysql=mysqlnd \

>--with-iconv-dir=/usr/local/libiconv \

>--with-freetype-dir \

>--with-jpeg-dir \

>--with-png-dir \

>--with-zlib \

>--with-libxml-dir=/usr \

>--enable-xml \

>--disable-rpath \

>--enable-safe-mode \

>--enable-bcmath \

>--enable-shmop \

>--enable-sysvsem \

>--enable-inline-optimization \

>--with-curl \

>--with-curlwrappers \

>--enable-mbregex \

>--enable-fpm \

>--enable-mbstring \

>--with-mcrypt \

>--with-gd \

>--enable-gd-native-ttf \

>--with-openssl \

>--with-mhash \

>--enable-pcntl \

>--enable-sockets \

>--with-xmlrpc \

>--enable-zip \

>--enable-soap \

>--enable-short-tags \

>--enable-zend-multibyte \

>--enable-static \

>--with-xsl \

>--with-fpm-user=nginx \

>--with-fpm-group=nginx \

>--enable-ftp

--with-mysql=/application/mysql:表示需要指定MySQL的安装路径,安装PHP需要的MySQL相关内容。如果没有MySQL软件包,也可以不单独安装,这样的情况可使用—with-mysql=mysqlnd。

正确的提示如下图所示:

wKiom1eDMu2wYcDgAAB4NtSHQzY568.png-wh_50

1.2.2 编译PHP

[root@web01php-5.3.27]# make

出现下图所示表示编译正确

wKioL1eDMt6gZiAIAABpSWUvPfg907.png-wh_50

 

1.2.3 安装PHP文件到系统

[root@web01 php-5.3.27]# makeinstall

Installing PHP SAPImodule:       fpm

Installing PHP CLI binary:        /application/php5.3.27/bin/

Installing PHP CLI manpage:     /application/php5.3.27/man/man1/

Installing PHP FPMbinary:       /application/php5.3.27/sbin/

Installing PHP FPMconfig:       /application/php5.3.27/etc/

Installing PHP FPM manpage:     /application/php5.3.27/man/man8/

Installing PHP FPM statuspage:     /application/php5.3.27/share/php/fpm/

Installing buildenvironment:    /application/php5.3.27/lib/php/build/

Installing header files:          /application/php5.3.27/include/php/

Installing helperprograms:      /application/php5.3.27/bin/

  program: phpize

  program: php-config

Installing man pages:             /application/php5.3.27/man/man1/

  page: phpize.1

  page: php-config.1

Installing PEARenvironment:      /application/php5.3.27/lib/php/

[PEAR] Archive_Tar    - installed: 1.3.11

[PEAR] Console_Getopt -installed: 1.3.1

warning: pear/PEAR requirespackage "pear/Structures_Graph" (recommended version 1.0.4)

warning: pear/PEAR requirespackage "pear/XML_Util" (recommended version 1.2.1)

[PEAR] PEAR           - installed: 1.9.4

Wrote PEAR system config fileat: /application/php5.3.27/etc/pear.conf

You may want to add:/application/php5.3.27/lib/php to your php.ini include_path

[PEAR] Structures_Graph-installed: 1.0.4

[PEAR] XML_Util       - installed: 1.2.1

/home/local/tools/php-5.3.27/build/shtoolinstall -c ext/phar/phar.phar /application/php5.3.27/bin

ln -s -f/application/php5.3.27/bin/phar.phar /application/php5.3.27/bin/phar

Installing PDO headers:          /application/php5.3.27/include/php/ext/pdo/

[root@web01 php-5.3.27]#

出现上述结果表示安装完成。

1.2.4 配置PHP引擎配置文件php.ini

1、设置软链接访问方式

[root@web01 php-5.3.27]# ln-s /application/php5.3.27/ /application/php

[root@web01 php-5.3.27]# ll/application/php

lrwxrwxrwx 1 root root 23 Apr13 20:34 /application/php -> /application/php5.3.27/

[root@web01 php-5.3.27]#

2、查看PHP配置默认模板文件,并复制到PHP默认目录。

[root@web01 php-5.3.27]# ll/application/php

lrwxrwxrwx 1 root root 23 Apr13 20:34 /application/php -> /application/php5.3.27/

[root@web01 php-5.3.27]# lsphp.ini*

php.ini-development  php.ini-production

[root@web01 php-5.3.27]#vimdiff php.ini-development php.ini-production

2 files to edit

[root@web01 php-5.3.27]# cpphp.ini-production /application/php/lib/php.ini

[root@web01 php-5.3.27]#

 

 

1.2.5 配置PHP服务(FastCGI)的配置文件php-fpm.conf

[root@web01 php-5.3.27]# cd/application/php/etc/

[root@web01 etc]# ls

pear.conf  php-fpm.conf.default

[root@web01 etc]# cpphp-fpm.conf.default php-fpm.conf

[root@web01 etc]#

 

1.2.6 启动PHP服务(FastCGI)方式

[root@web01 etc]# /application/php/sbin/php-fpm

[root@web01 etc]# ps -ef|grepphp-fpm

root     54582    1  0 20:48 ?        00:00:00 php-fpm: master process(/application/php5.3.27/etc/php-fpm.conf)

nginx    54583 54582 0 20:48 ?        00:00:00 php-fpm:pool www           

nginx    54584 54582 0 20:48 ?        00:00:00 php-fpm:pool www           

root     54586 1660  0 20:48 pts/0    00:00:00 grep php-fpm

[root@web01 etc]# lsof -i:9000

COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

php-fpm 54582  root   7u  IPv4  99975     0t0  TCP localhost:cslistener(LISTEN)

php-fpm 54583 nginx    0u IPv4  99975      0t0 TCP localhost:cslistener (LISTEN)

php-fpm 54584 nginx    0u IPv4  99975      0t0 TCP localhost:cslistener (LISTEN)

[root@web01 etc]#

 

1.3 配置Nginx支持PHP

1.3.1 修改Nginx配置文件

修改blog.conf文件内容为

[root@web01 extra]# catblog.conf

    server {

        listen       80;

        server_name  blog.yifeng.com;

        location / {

            root   html/blog;

            index  index.html index.htm;

        }

    

     location ~ .*\.(php|php5)?$ {

         root html/blog;

         fastcgi_pass127.0.0.1:9000;

         fastcgi_indexindex.php;

         include fastcgi.conf;

 

     }

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

access_loglogs/access_blog.log main;

    }

[root@web01 extra]#

1.3.2 检查并启动Nginx

[root@web01 extra]#/application/nginx/sbin/nginx -t

nginx: the configuration file/application/nginx-1.8.1//conf/nginx.conf syntax is ok

nginx: configuration file/application/nginx-1.8.1//conf/nginx.conf test is successful

[root@web01 extra]#/application/nginx/sbin/nginx -s reload

[root@web01 extra]# lsof -i:80

COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

nginx    1632 root   10u  IPv4 10879      0t0  TCP *:http (LISTEN)

nginx   54620 nginx  10u  IPv4  10879     0t0  TCP *:http (LISTEN)

[root@web01 extra]# lsof -i:9000

COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

php-fpm 54582  root   7u  IPv4  99975     0t0  TCP localhost:cslistener(LISTEN)

php-fpm 54583 nginx    0u IPv4  99975      0t0 TCP localhost:cslistener (LISTEN)

php-fpm 54584 nginx    0u IPv4  99975      0t0 TCP localhost:cslistener (LISTEN)

[root@web01 extra]#

          

1.4 测试

1.4.1 测试PHP请求是否正确解析

[root@web01 blog]# echo"<?php phpinfo();?>" >test_info.php

[root@web01 blog]# ll

total 8

-rw-r--r-- 1 root root 26Apr  6 06:52 index.html

-rw-r--r-- 1 root root 19 Apr13 21:05 test_info.php

[root@web01 blog]# cattest_info.php

<?php phpinfo();?>

1.4.2 测试PHP接连MySQL是否正确

[root@web01 blog]# cattest_mysql.php

<?php

 

     $link_id=mysql_connect('192.168.33.152','root','123456') ormysql_error();

     if($link_id){

            echo "mysql successful by root!";

     }else{

            echo mysql_error();

     }

 

 

 

?>

[root@web01 blog]#

 



本文转自 kesungang 51CTO博客,原文链接:http://blog.51cto.com/sgk2011/1825315,如需转载请自行联系原作者

相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
15天前
|
域名解析 关系型数据库 MySQL
基于PHPEnv的本地环境搭建—PHP第一个项目:HelloWorld(从安装到运行)
该文章指导如何使用PHPEnv搭建本地PHP开发环境,并通过一个简单的"Hello World"程序演示从安装到运行的全过程。
基于PHPEnv的本地环境搭建—PHP第一个项目:HelloWorld(从安装到运行)
|
5天前
|
tengine 应用服务中间件 Linux
Tengine、Nginx安装PHP命令教程
要在阿里云Linux上安装PHP,请先更新YUM源并启用PHP 8.0仓库,然后安装PHP及相关扩展。通过`php -v`命令验证安装成功后,需修改Nginx配置文件以支持PHP,并重启服务。最后,创建`phpinfo.php`文件测试安装是否成功。对于CentOS系统,还需安装EPEL源和Remi仓库,其余步骤类似。完成上述操作后,可通过浏览器访问`http://IP地址/phpinfo.php`测试安装结果。
|
18天前
|
IDE 安全 网络安全
Xdebug 在不同版本的 PHP 中配置方法有什么不同?
Xdebug 在不同版本的 PHP 中配置方法有什么不同?
|
14天前
|
PHP Windows
thinkPhP6.0安装教程图解--PHP框架安装
本文是一篇关于ThinkPHP 6.0安装教程的图解,包括环境检查、安装Composer、修改Composer镜像地址、安装ThinkPHP框架以及启动运行ThinkPHP的步骤。文章详细描述了每个步骤的操作方法,并提供了相应的命令和截图,帮助用户理解并顺利完成ThinkPHP 6.0的安装和运行。
thinkPhP6.0安装教程图解--PHP框架安装
|
15天前
|
PHP Apache 数据库
PHP做二次开发:本机安装ThinkCMF系统
文章详细说明了如何在本地环境中从零开始安装并配置ThinkCMF系统,包括环境准备、源代码获取、虚拟域名设置及数据库配置等步骤。
|
2月前
|
Linux PHP
Linux CentOS 宝塔 Suhosin禁用php5.6版本eval函数详细图文教程
【8月更文挑战第27天】本文介绍两种禁用PHP执行的方法:使用`PHP_diseval_extension`禁用和通过`suhosin`禁用。由于`suhosin`不支持PHP8,仅适用于PHP7及以下版本,若服务器安装了PHP5.6,则需对应安装`suhosin-0.9.38`版本。文章提供了详细的安装步骤,并强调了宝塔环境下与普通环境下的PHP路径差异。安装完成后,在`php.ini`中添加`suhosin.so`扩展并设置`executor.disable_eval = on`以禁用执行功能。最后通过测试代码验证是否成功禁用,并重启`php-fpm`服务生效。
28 2
|
2月前
|
Go PHP 数据安全/隐私保护
【应用服务 App Service】Azure App Service 中如何安装mcrypt - PHP
【应用服务 App Service】Azure App Service 中如何安装mcrypt - PHP
|
2月前
|
Shell PHP
PHP安装
PHP安装
67 6
|
2月前
|
PHP
PHP——oneinstack重新安装PHP的时候报错
PHP——oneinstack重新安装PHP的时候报错
41 4
|
2月前
|
Web App开发 关系型数据库 PHP
使用 Docker 快速搭建多版本 PHP 开发环境
使用 Docker 快速搭建多版本 PHP 开发环境
60 2