PHP5.3版本安装

第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。

正确的提示如下图所示:

PHP5.3版本安装

1.2.2 编译PHP

[root@web01php-5.3.27]# make

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

PHP5.3版本安装

 

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,如需转载请自行联系原作者

上一篇:Windows下安装weblogic dev版本


下一篇:MSSQL · 最佳实践 · 使用非对称秘钥实现列加密